babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4312. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4473. static readonly GEQUAL: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/devTools" {
  4961. /** @hidden */
  4962. export class _DevTools {
  4963. static WarnImport(name: string): string;
  4964. }
  4965. }
  4966. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4967. /**
  4968. * Class used to evalaute queries containing `and` and `or` operators
  4969. */
  4970. export class AndOrNotEvaluator {
  4971. /**
  4972. * Evaluate a query
  4973. * @param query defines the query to evaluate
  4974. * @param evaluateCallback defines the callback used to filter result
  4975. * @returns true if the query matches
  4976. */
  4977. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4978. private static _HandleParenthesisContent;
  4979. private static _SimplifyNegation;
  4980. }
  4981. }
  4982. declare module "babylonjs/Misc/tags" {
  4983. /**
  4984. * Class used to store custom tags
  4985. */
  4986. export class Tags {
  4987. /**
  4988. * Adds support for tags on the given object
  4989. * @param obj defines the object to use
  4990. */
  4991. static EnableFor(obj: any): void;
  4992. /**
  4993. * Removes tags support
  4994. * @param obj defines the object to use
  4995. */
  4996. static DisableFor(obj: any): void;
  4997. /**
  4998. * Gets a boolean indicating if the given object has tags
  4999. * @param obj defines the object to use
  5000. * @returns a boolean
  5001. */
  5002. static HasTags(obj: any): boolean;
  5003. /**
  5004. * Gets the tags available on a given object
  5005. * @param obj defines the object to use
  5006. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5007. * @returns the tags
  5008. */
  5009. static GetTags(obj: any, asString?: boolean): any;
  5010. /**
  5011. * Adds tags to an object
  5012. * @param obj defines the object to use
  5013. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5014. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5015. */
  5016. static AddTagsTo(obj: any, tagsString: string): void;
  5017. /**
  5018. * @hidden
  5019. */
  5020. static _AddTagTo(obj: any, tag: string): void;
  5021. /**
  5022. * Removes specific tags from a specific object
  5023. * @param obj defines the object to use
  5024. * @param tagsString defines the tags to remove
  5025. */
  5026. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5027. /**
  5028. * @hidden
  5029. */
  5030. static _RemoveTagFrom(obj: any, tag: string): void;
  5031. /**
  5032. * Defines if tags hosted on an object match a given query
  5033. * @param obj defines the object to use
  5034. * @param tagsQuery defines the tag query
  5035. * @returns a boolean
  5036. */
  5037. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5038. }
  5039. }
  5040. declare module "babylonjs/Materials/materialDefines" {
  5041. /**
  5042. * Manages the defines for the Material
  5043. */
  5044. export class MaterialDefines {
  5045. private _keys;
  5046. private _isDirty;
  5047. /** @hidden */
  5048. _renderId: number;
  5049. /** @hidden */
  5050. _areLightsDirty: boolean;
  5051. /** @hidden */
  5052. _areAttributesDirty: boolean;
  5053. /** @hidden */
  5054. _areTexturesDirty: boolean;
  5055. /** @hidden */
  5056. _areFresnelDirty: boolean;
  5057. /** @hidden */
  5058. _areMiscDirty: boolean;
  5059. /** @hidden */
  5060. _areImageProcessingDirty: boolean;
  5061. /** @hidden */
  5062. _normals: boolean;
  5063. /** @hidden */
  5064. _uvs: boolean;
  5065. /** @hidden */
  5066. _needNormals: boolean;
  5067. /** @hidden */
  5068. _needUVs: boolean;
  5069. /**
  5070. * Specifies if the material needs to be re-calculated
  5071. */
  5072. readonly isDirty: boolean;
  5073. /**
  5074. * Marks the material to indicate that it has been re-calculated
  5075. */
  5076. markAsProcessed(): void;
  5077. /**
  5078. * Marks the material to indicate that it needs to be re-calculated
  5079. */
  5080. markAsUnprocessed(): void;
  5081. /**
  5082. * Marks the material to indicate all of its defines need to be re-calculated
  5083. */
  5084. markAllAsDirty(): void;
  5085. /**
  5086. * Marks the material to indicate that image processing needs to be re-calculated
  5087. */
  5088. markAsImageProcessingDirty(): void;
  5089. /**
  5090. * Marks the material to indicate the lights need to be re-calculated
  5091. */
  5092. markAsLightDirty(): void;
  5093. /**
  5094. * Marks the attribute state as changed
  5095. */
  5096. markAsAttributesDirty(): void;
  5097. /**
  5098. * Marks the texture state as changed
  5099. */
  5100. markAsTexturesDirty(): void;
  5101. /**
  5102. * Marks the fresnel state as changed
  5103. */
  5104. markAsFresnelDirty(): void;
  5105. /**
  5106. * Marks the misc state as changed
  5107. */
  5108. markAsMiscDirty(): void;
  5109. /**
  5110. * Rebuilds the material defines
  5111. */
  5112. rebuild(): void;
  5113. /**
  5114. * Specifies if two material defines are equal
  5115. * @param other - A material define instance to compare to
  5116. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5117. */
  5118. isEqual(other: MaterialDefines): boolean;
  5119. /**
  5120. * Clones this instance's defines to another instance
  5121. * @param other - material defines to clone values to
  5122. */
  5123. cloneTo(other: MaterialDefines): void;
  5124. /**
  5125. * Resets the material define values
  5126. */
  5127. reset(): void;
  5128. /**
  5129. * Converts the material define values to a string
  5130. * @returns - String of material define information
  5131. */
  5132. toString(): string;
  5133. }
  5134. }
  5135. declare module "babylonjs/Misc/performanceMonitor" {
  5136. /**
  5137. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5138. */
  5139. export class PerformanceMonitor {
  5140. private _enabled;
  5141. private _rollingFrameTime;
  5142. private _lastFrameTimeMs;
  5143. /**
  5144. * constructor
  5145. * @param frameSampleSize The number of samples required to saturate the sliding window
  5146. */
  5147. constructor(frameSampleSize?: number);
  5148. /**
  5149. * Samples current frame
  5150. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5151. */
  5152. sampleFrame(timeMs?: number): void;
  5153. /**
  5154. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5155. */
  5156. readonly averageFrameTime: number;
  5157. /**
  5158. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5159. */
  5160. readonly averageFrameTimeVariance: number;
  5161. /**
  5162. * Returns the frame time of the most recent frame
  5163. */
  5164. readonly instantaneousFrameTime: number;
  5165. /**
  5166. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5167. */
  5168. readonly averageFPS: number;
  5169. /**
  5170. * Returns the average framerate in frames per second using the most recent frame time
  5171. */
  5172. readonly instantaneousFPS: number;
  5173. /**
  5174. * Returns true if enough samples have been taken to completely fill the sliding window
  5175. */
  5176. readonly isSaturated: boolean;
  5177. /**
  5178. * Enables contributions to the sliding window sample set
  5179. */
  5180. enable(): void;
  5181. /**
  5182. * Disables contributions to the sliding window sample set
  5183. * Samples will not be interpolated over the disabled period
  5184. */
  5185. disable(): void;
  5186. /**
  5187. * Returns true if sampling is enabled
  5188. */
  5189. readonly isEnabled: boolean;
  5190. /**
  5191. * Resets performance monitor
  5192. */
  5193. reset(): void;
  5194. }
  5195. /**
  5196. * RollingAverage
  5197. *
  5198. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5199. */
  5200. export class RollingAverage {
  5201. /**
  5202. * Current average
  5203. */
  5204. average: number;
  5205. /**
  5206. * Current variance
  5207. */
  5208. variance: number;
  5209. protected _samples: Array<number>;
  5210. protected _sampleCount: number;
  5211. protected _pos: number;
  5212. protected _m2: number;
  5213. /**
  5214. * constructor
  5215. * @param length The number of samples required to saturate the sliding window
  5216. */
  5217. constructor(length: number);
  5218. /**
  5219. * Adds a sample to the sample set
  5220. * @param v The sample value
  5221. */
  5222. add(v: number): void;
  5223. /**
  5224. * Returns previously added values or null if outside of history or outside the sliding window domain
  5225. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5226. * @return Value previously recorded with add() or null if outside of range
  5227. */
  5228. history(i: number): number;
  5229. /**
  5230. * Returns true if enough samples have been taken to completely fill the sliding window
  5231. * @return true if sample-set saturated
  5232. */
  5233. isSaturated(): boolean;
  5234. /**
  5235. * Resets the rolling average (equivalent to 0 samples taken so far)
  5236. */
  5237. reset(): void;
  5238. /**
  5239. * Wraps a value around the sample range boundaries
  5240. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5241. * @return Wrapped position in sample range
  5242. */
  5243. protected _wrapPosition(i: number): number;
  5244. }
  5245. }
  5246. declare module "babylonjs/Misc/stringDictionary" {
  5247. import { Nullable } from "babylonjs/types";
  5248. /**
  5249. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5250. * The underlying implementation relies on an associative array to ensure the best performances.
  5251. * The value can be anything including 'null' but except 'undefined'
  5252. */
  5253. export class StringDictionary<T> {
  5254. /**
  5255. * This will clear this dictionary and copy the content from the 'source' one.
  5256. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5257. * @param source the dictionary to take the content from and copy to this dictionary
  5258. */
  5259. copyFrom(source: StringDictionary<T>): void;
  5260. /**
  5261. * Get a value based from its key
  5262. * @param key the given key to get the matching value from
  5263. * @return the value if found, otherwise undefined is returned
  5264. */
  5265. get(key: string): T | undefined;
  5266. /**
  5267. * Get a value from its key or add it if it doesn't exist.
  5268. * This method will ensure you that a given key/data will be present in the dictionary.
  5269. * @param key the given key to get the matching value from
  5270. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5271. * The factory will only be invoked if there's no data for the given key.
  5272. * @return the value corresponding to the key.
  5273. */
  5274. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5275. /**
  5276. * Get a value from its key if present in the dictionary otherwise add it
  5277. * @param key the key to get the value from
  5278. * @param val if there's no such key/value pair in the dictionary add it with this value
  5279. * @return the value corresponding to the key
  5280. */
  5281. getOrAdd(key: string, val: T): T;
  5282. /**
  5283. * Check if there's a given key in the dictionary
  5284. * @param key the key to check for
  5285. * @return true if the key is present, false otherwise
  5286. */
  5287. contains(key: string): boolean;
  5288. /**
  5289. * Add a new key and its corresponding value
  5290. * @param key the key to add
  5291. * @param value the value corresponding to the key
  5292. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5293. */
  5294. add(key: string, value: T): boolean;
  5295. /**
  5296. * Update a specific value associated to a key
  5297. * @param key defines the key to use
  5298. * @param value defines the value to store
  5299. * @returns true if the value was updated (or false if the key was not found)
  5300. */
  5301. set(key: string, value: T): boolean;
  5302. /**
  5303. * Get the element of the given key and remove it from the dictionary
  5304. * @param key defines the key to search
  5305. * @returns the value associated with the key or null if not found
  5306. */
  5307. getAndRemove(key: string): Nullable<T>;
  5308. /**
  5309. * Remove a key/value from the dictionary.
  5310. * @param key the key to remove
  5311. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5312. */
  5313. remove(key: string): boolean;
  5314. /**
  5315. * Clear the whole content of the dictionary
  5316. */
  5317. clear(): void;
  5318. /**
  5319. * Gets the current count
  5320. */
  5321. readonly count: number;
  5322. /**
  5323. * Execute a callback on each key/val of the dictionary.
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute on a given key/value pair
  5326. */
  5327. forEach(callback: (key: string, val: T) => void): void;
  5328. /**
  5329. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5330. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5331. * Note that you can remove any element in this dictionary in the callback implementation
  5332. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5333. * @returns the first item
  5334. */
  5335. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5336. private _count;
  5337. private _data;
  5338. }
  5339. }
  5340. declare module "babylonjs/Misc/promise" {
  5341. /**
  5342. * Helper class that provides a small promise polyfill
  5343. */
  5344. export class PromisePolyfill {
  5345. /**
  5346. * Static function used to check if the polyfill is required
  5347. * If this is the case then the function will inject the polyfill to window.Promise
  5348. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5349. */
  5350. static Apply(force?: boolean): void;
  5351. }
  5352. }
  5353. declare module "babylonjs/Meshes/buffer" {
  5354. import { Nullable, DataArray } from "babylonjs/types";
  5355. /**
  5356. * Class used to store data that will be store in GPU memory
  5357. */
  5358. export class Buffer {
  5359. private _engine;
  5360. private _buffer;
  5361. /** @hidden */
  5362. _data: Nullable<DataArray>;
  5363. private _updatable;
  5364. private _instanced;
  5365. /**
  5366. * Gets the byte stride.
  5367. */
  5368. readonly byteStride: number;
  5369. /**
  5370. * Constructor
  5371. * @param engine the engine
  5372. * @param data the data to use for this buffer
  5373. * @param updatable whether the data is updatable
  5374. * @param stride the stride (optional)
  5375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5376. * @param instanced whether the buffer is instanced (optional)
  5377. * @param useBytes set to true if the stride in in bytes (optional)
  5378. */
  5379. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5380. /**
  5381. * Create a new VertexBuffer based on the current buffer
  5382. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5383. * @param offset defines offset in the buffer (0 by default)
  5384. * @param size defines the size in floats of attributes (position is 3 for instance)
  5385. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5386. * @param instanced defines if the vertex buffer contains indexed data
  5387. * @param useBytes defines if the offset and stride are in bytes
  5388. * @returns the new vertex buffer
  5389. */
  5390. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5391. /**
  5392. * Gets a boolean indicating if the Buffer is updatable?
  5393. * @returns true if the buffer is updatable
  5394. */
  5395. isUpdatable(): boolean;
  5396. /**
  5397. * Gets current buffer's data
  5398. * @returns a DataArray or null
  5399. */
  5400. getData(): Nullable<DataArray>;
  5401. /**
  5402. * Gets underlying native buffer
  5403. * @returns underlying native buffer
  5404. */
  5405. getBuffer(): Nullable<WebGLBuffer>;
  5406. /**
  5407. * Gets the stride in float32 units (i.e. byte stride / 4).
  5408. * May not be an integer if the byte stride is not divisible by 4.
  5409. * DEPRECATED. Use byteStride instead.
  5410. * @returns the stride in float32 units
  5411. */
  5412. getStrideSize(): number;
  5413. /**
  5414. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5415. * @param data defines the data to store
  5416. */
  5417. create(data?: Nullable<DataArray>): void;
  5418. /** @hidden */
  5419. _rebuild(): void;
  5420. /**
  5421. * Update current buffer data
  5422. * @param data defines the data to store
  5423. */
  5424. update(data: DataArray): void;
  5425. /**
  5426. * Updates the data directly.
  5427. * @param data the new data
  5428. * @param offset the new offset
  5429. * @param vertexCount the vertex count (optional)
  5430. * @param useBytes set to true if the offset is in bytes
  5431. */
  5432. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5433. /**
  5434. * Release all resources
  5435. */
  5436. dispose(): void;
  5437. }
  5438. /**
  5439. * Specialized buffer used to store vertex data
  5440. */
  5441. export class VertexBuffer {
  5442. /** @hidden */
  5443. _buffer: Buffer;
  5444. private _kind;
  5445. private _size;
  5446. private _ownsBuffer;
  5447. private _instanced;
  5448. private _instanceDivisor;
  5449. /**
  5450. * The byte type.
  5451. */
  5452. static readonly BYTE: number;
  5453. /**
  5454. * The unsigned byte type.
  5455. */
  5456. static readonly UNSIGNED_BYTE: number;
  5457. /**
  5458. * The short type.
  5459. */
  5460. static readonly SHORT: number;
  5461. /**
  5462. * The unsigned short type.
  5463. */
  5464. static readonly UNSIGNED_SHORT: number;
  5465. /**
  5466. * The integer type.
  5467. */
  5468. static readonly INT: number;
  5469. /**
  5470. * The unsigned integer type.
  5471. */
  5472. static readonly UNSIGNED_INT: number;
  5473. /**
  5474. * The float type.
  5475. */
  5476. static readonly FLOAT: number;
  5477. /**
  5478. * Gets or sets the instance divisor when in instanced mode
  5479. */
  5480. instanceDivisor: number;
  5481. /**
  5482. * Gets the byte stride.
  5483. */
  5484. readonly byteStride: number;
  5485. /**
  5486. * Gets the byte offset.
  5487. */
  5488. readonly byteOffset: number;
  5489. /**
  5490. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5491. */
  5492. readonly normalized: boolean;
  5493. /**
  5494. * Gets the data type of each component in the array.
  5495. */
  5496. readonly type: number;
  5497. /**
  5498. * Constructor
  5499. * @param engine the engine
  5500. * @param data the data to use for this vertex buffer
  5501. * @param kind the vertex buffer kind
  5502. * @param updatable whether the data is updatable
  5503. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5504. * @param stride the stride (optional)
  5505. * @param instanced whether the buffer is instanced (optional)
  5506. * @param offset the offset of the data (optional)
  5507. * @param size the number of components (optional)
  5508. * @param type the type of the component (optional)
  5509. * @param normalized whether the data contains normalized data (optional)
  5510. * @param useBytes set to true if stride and offset are in bytes (optional)
  5511. */
  5512. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5513. /** @hidden */
  5514. _rebuild(): void;
  5515. /**
  5516. * Returns the kind of the VertexBuffer (string)
  5517. * @returns a string
  5518. */
  5519. getKind(): string;
  5520. /**
  5521. * Gets a boolean indicating if the VertexBuffer is updatable?
  5522. * @returns true if the buffer is updatable
  5523. */
  5524. isUpdatable(): boolean;
  5525. /**
  5526. * Gets current buffer's data
  5527. * @returns a DataArray or null
  5528. */
  5529. getData(): Nullable<DataArray>;
  5530. /**
  5531. * Gets underlying native buffer
  5532. * @returns underlying native buffer
  5533. */
  5534. getBuffer(): Nullable<WebGLBuffer>;
  5535. /**
  5536. * Gets the stride in float32 units (i.e. byte stride / 4).
  5537. * May not be an integer if the byte stride is not divisible by 4.
  5538. * DEPRECATED. Use byteStride instead.
  5539. * @returns the stride in float32 units
  5540. */
  5541. getStrideSize(): number;
  5542. /**
  5543. * Returns the offset as a multiple of the type byte length.
  5544. * DEPRECATED. Use byteOffset instead.
  5545. * @returns the offset in bytes
  5546. */
  5547. getOffset(): number;
  5548. /**
  5549. * Returns the number of components per vertex attribute (integer)
  5550. * @returns the size in float
  5551. */
  5552. getSize(): number;
  5553. /**
  5554. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5555. * @returns true if this buffer is instanced
  5556. */
  5557. getIsInstanced(): boolean;
  5558. /**
  5559. * Returns the instancing divisor, zero for non-instanced (integer).
  5560. * @returns a number
  5561. */
  5562. getInstanceDivisor(): number;
  5563. /**
  5564. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5565. * @param data defines the data to store
  5566. */
  5567. create(data?: DataArray): void;
  5568. /**
  5569. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5570. * This function will create a new buffer if the current one is not updatable
  5571. * @param data defines the data to store
  5572. */
  5573. update(data: DataArray): void;
  5574. /**
  5575. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5576. * Returns the directly updated WebGLBuffer.
  5577. * @param data the new data
  5578. * @param offset the new offset
  5579. * @param useBytes set to true if the offset is in bytes
  5580. */
  5581. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5582. /**
  5583. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5584. */
  5585. dispose(): void;
  5586. /**
  5587. * Enumerates each value of this vertex buffer as numbers.
  5588. * @param count the number of values to enumerate
  5589. * @param callback the callback function called for each value
  5590. */
  5591. forEach(count: number, callback: (value: number, index: number) => void): void;
  5592. /**
  5593. * Positions
  5594. */
  5595. static readonly PositionKind: string;
  5596. /**
  5597. * Normals
  5598. */
  5599. static readonly NormalKind: string;
  5600. /**
  5601. * Tangents
  5602. */
  5603. static readonly TangentKind: string;
  5604. /**
  5605. * Texture coordinates
  5606. */
  5607. static readonly UVKind: string;
  5608. /**
  5609. * Texture coordinates 2
  5610. */
  5611. static readonly UV2Kind: string;
  5612. /**
  5613. * Texture coordinates 3
  5614. */
  5615. static readonly UV3Kind: string;
  5616. /**
  5617. * Texture coordinates 4
  5618. */
  5619. static readonly UV4Kind: string;
  5620. /**
  5621. * Texture coordinates 5
  5622. */
  5623. static readonly UV5Kind: string;
  5624. /**
  5625. * Texture coordinates 6
  5626. */
  5627. static readonly UV6Kind: string;
  5628. /**
  5629. * Colors
  5630. */
  5631. static readonly ColorKind: string;
  5632. /**
  5633. * Matrix indices (for bones)
  5634. */
  5635. static readonly MatricesIndicesKind: string;
  5636. /**
  5637. * Matrix weights (for bones)
  5638. */
  5639. static readonly MatricesWeightsKind: string;
  5640. /**
  5641. * Additional matrix indices (for bones)
  5642. */
  5643. static readonly MatricesIndicesExtraKind: string;
  5644. /**
  5645. * Additional matrix weights (for bones)
  5646. */
  5647. static readonly MatricesWeightsExtraKind: string;
  5648. /**
  5649. * Deduces the stride given a kind.
  5650. * @param kind The kind string to deduce
  5651. * @returns The deduced stride
  5652. */
  5653. static DeduceStride(kind: string): number;
  5654. /**
  5655. * Gets the byte length of the given type.
  5656. * @param type the type
  5657. * @returns the number of bytes
  5658. */
  5659. static GetTypeByteLength(type: number): number;
  5660. /**
  5661. * Enumerates each value of the given parameters as numbers.
  5662. * @param data the data to enumerate
  5663. * @param byteOffset the byte offset of the data
  5664. * @param byteStride the byte stride of the data
  5665. * @param componentCount the number of components per element
  5666. * @param componentType the type of the component
  5667. * @param count the total number of components
  5668. * @param normalized whether the data is normalized
  5669. * @param callback the callback function called for each value
  5670. */
  5671. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5672. private static _GetFloatValue;
  5673. }
  5674. }
  5675. declare module "babylonjs/Maths/sphericalPolynomial" {
  5676. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5677. /**
  5678. * Class representing spherical polynomial coefficients to the 3rd degree
  5679. */
  5680. export class SphericalPolynomial {
  5681. /**
  5682. * The x coefficients of the spherical polynomial
  5683. */
  5684. x: Vector3;
  5685. /**
  5686. * The y coefficients of the spherical polynomial
  5687. */
  5688. y: Vector3;
  5689. /**
  5690. * The z coefficients of the spherical polynomial
  5691. */
  5692. z: Vector3;
  5693. /**
  5694. * The xx coefficients of the spherical polynomial
  5695. */
  5696. xx: Vector3;
  5697. /**
  5698. * The yy coefficients of the spherical polynomial
  5699. */
  5700. yy: Vector3;
  5701. /**
  5702. * The zz coefficients of the spherical polynomial
  5703. */
  5704. zz: Vector3;
  5705. /**
  5706. * The xy coefficients of the spherical polynomial
  5707. */
  5708. xy: Vector3;
  5709. /**
  5710. * The yz coefficients of the spherical polynomial
  5711. */
  5712. yz: Vector3;
  5713. /**
  5714. * The zx coefficients of the spherical polynomial
  5715. */
  5716. zx: Vector3;
  5717. /**
  5718. * Adds an ambient color to the spherical polynomial
  5719. * @param color the color to add
  5720. */
  5721. addAmbient(color: Color3): void;
  5722. /**
  5723. * Scales the spherical polynomial by the given amount
  5724. * @param scale the amount to scale
  5725. */
  5726. scale(scale: number): void;
  5727. /**
  5728. * Gets the spherical polynomial from harmonics
  5729. * @param harmonics the spherical harmonics
  5730. * @returns the spherical polynomial
  5731. */
  5732. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5733. /**
  5734. * Constructs a spherical polynomial from an array.
  5735. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5736. * @returns the spherical polynomial
  5737. */
  5738. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5739. }
  5740. /**
  5741. * Class representing spherical harmonics coefficients to the 3rd degree
  5742. */
  5743. export class SphericalHarmonics {
  5744. /**
  5745. * The l0,0 coefficients of the spherical harmonics
  5746. */
  5747. l00: Vector3;
  5748. /**
  5749. * The l1,-1 coefficients of the spherical harmonics
  5750. */
  5751. l1_1: Vector3;
  5752. /**
  5753. * The l1,0 coefficients of the spherical harmonics
  5754. */
  5755. l10: Vector3;
  5756. /**
  5757. * The l1,1 coefficients of the spherical harmonics
  5758. */
  5759. l11: Vector3;
  5760. /**
  5761. * The l2,-2 coefficients of the spherical harmonics
  5762. */
  5763. l2_2: Vector3;
  5764. /**
  5765. * The l2,-1 coefficients of the spherical harmonics
  5766. */
  5767. l2_1: Vector3;
  5768. /**
  5769. * The l2,0 coefficients of the spherical harmonics
  5770. */
  5771. l20: Vector3;
  5772. /**
  5773. * The l2,1 coefficients of the spherical harmonics
  5774. */
  5775. l21: Vector3;
  5776. /**
  5777. * The l2,2 coefficients of the spherical harmonics
  5778. */
  5779. lL22: Vector3;
  5780. /**
  5781. * Adds a light to the spherical harmonics
  5782. * @param direction the direction of the light
  5783. * @param color the color of the light
  5784. * @param deltaSolidAngle the delta solid angle of the light
  5785. */
  5786. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5787. /**
  5788. * Scales the spherical harmonics by the given amount
  5789. * @param scale the amount to scale
  5790. */
  5791. scale(scale: number): void;
  5792. /**
  5793. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5794. *
  5795. * ```
  5796. * E_lm = A_l * L_lm
  5797. * ```
  5798. *
  5799. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5800. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5801. * the scaling factors are given in equation 9.
  5802. */
  5803. convertIncidentRadianceToIrradiance(): void;
  5804. /**
  5805. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5806. *
  5807. * ```
  5808. * L = (1/pi) * E * rho
  5809. * ```
  5810. *
  5811. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5812. */
  5813. convertIrradianceToLambertianRadiance(): void;
  5814. /**
  5815. * Gets the spherical harmonics from polynomial
  5816. * @param polynomial the spherical polynomial
  5817. * @returns the spherical harmonics
  5818. */
  5819. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5820. /**
  5821. * Constructs a spherical harmonics from an array.
  5822. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5823. * @returns the spherical harmonics
  5824. */
  5825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5826. }
  5827. }
  5828. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5829. import { Nullable } from "babylonjs/types";
  5830. /**
  5831. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5832. */
  5833. export interface CubeMapInfo {
  5834. /**
  5835. * The pixel array for the front face.
  5836. * This is stored in format, left to right, up to down format.
  5837. */
  5838. front: Nullable<ArrayBufferView>;
  5839. /**
  5840. * The pixel array for the back face.
  5841. * This is stored in format, left to right, up to down format.
  5842. */
  5843. back: Nullable<ArrayBufferView>;
  5844. /**
  5845. * The pixel array for the left face.
  5846. * This is stored in format, left to right, up to down format.
  5847. */
  5848. left: Nullable<ArrayBufferView>;
  5849. /**
  5850. * The pixel array for the right face.
  5851. * This is stored in format, left to right, up to down format.
  5852. */
  5853. right: Nullable<ArrayBufferView>;
  5854. /**
  5855. * The pixel array for the up face.
  5856. * This is stored in format, left to right, up to down format.
  5857. */
  5858. up: Nullable<ArrayBufferView>;
  5859. /**
  5860. * The pixel array for the down face.
  5861. * This is stored in format, left to right, up to down format.
  5862. */
  5863. down: Nullable<ArrayBufferView>;
  5864. /**
  5865. * The size of the cubemap stored.
  5866. *
  5867. * Each faces will be size * size pixels.
  5868. */
  5869. size: number;
  5870. /**
  5871. * The format of the texture.
  5872. *
  5873. * RGBA, RGB.
  5874. */
  5875. format: number;
  5876. /**
  5877. * The type of the texture data.
  5878. *
  5879. * UNSIGNED_INT, FLOAT.
  5880. */
  5881. type: number;
  5882. /**
  5883. * Specifies whether the texture is in gamma space.
  5884. */
  5885. gammaSpace: boolean;
  5886. }
  5887. /**
  5888. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5889. */
  5890. export class PanoramaToCubeMapTools {
  5891. private static FACE_FRONT;
  5892. private static FACE_BACK;
  5893. private static FACE_RIGHT;
  5894. private static FACE_LEFT;
  5895. private static FACE_DOWN;
  5896. private static FACE_UP;
  5897. /**
  5898. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5899. *
  5900. * @param float32Array The source data.
  5901. * @param inputWidth The width of the input panorama.
  5902. * @param inputHeight The height of the input panorama.
  5903. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5904. * @return The cubemap data
  5905. */
  5906. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5907. private static CreateCubemapTexture;
  5908. private static CalcProjectionSpherical;
  5909. }
  5910. }
  5911. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5912. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5914. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5915. /**
  5916. * Helper class dealing with the extraction of spherical polynomial dataArray
  5917. * from a cube map.
  5918. */
  5919. export class CubeMapToSphericalPolynomialTools {
  5920. private static FileFaces;
  5921. /**
  5922. * Converts a texture to the according Spherical Polynomial data.
  5923. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5924. *
  5925. * @param texture The texture to extract the information from.
  5926. * @return The Spherical Polynomial data.
  5927. */
  5928. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5929. /**
  5930. * Converts a cubemap to the according Spherical Polynomial data.
  5931. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5932. *
  5933. * @param cubeInfo The Cube map to extract the information from.
  5934. * @return The Spherical Polynomial data.
  5935. */
  5936. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5937. }
  5938. }
  5939. declare module "babylonjs/Engines/engineStore" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Engine } from "babylonjs/Engines/engine";
  5942. import { Scene } from "babylonjs/scene";
  5943. /**
  5944. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5945. * during the life time of the application.
  5946. */
  5947. export class EngineStore {
  5948. /** Gets the list of created engines */
  5949. static Instances: import("babylonjs/Engines/engine").Engine[];
  5950. /**
  5951. * Gets the latest created engine
  5952. */
  5953. static readonly LastCreatedEngine: Nullable<Engine>;
  5954. /**
  5955. * Gets the latest created scene
  5956. */
  5957. static readonly LastCreatedScene: Nullable<Scene>;
  5958. }
  5959. }
  5960. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5961. /**
  5962. * Define options used to create a render target texture
  5963. */
  5964. export class RenderTargetCreationOptions {
  5965. /**
  5966. * Specifies is mipmaps must be generated
  5967. */
  5968. generateMipMaps?: boolean;
  5969. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5970. generateDepthBuffer?: boolean;
  5971. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5972. generateStencilBuffer?: boolean;
  5973. /** Defines texture type (int by default) */
  5974. type?: number;
  5975. /** Defines sampling mode (trilinear by default) */
  5976. samplingMode?: number;
  5977. /** Defines format (RGBA by default) */
  5978. format?: number;
  5979. }
  5980. }
  5981. declare module "babylonjs/States/alphaCullingState" {
  5982. /**
  5983. * @hidden
  5984. **/
  5985. export class _AlphaState {
  5986. private _isAlphaBlendDirty;
  5987. private _isBlendFunctionParametersDirty;
  5988. private _isBlendEquationParametersDirty;
  5989. private _isBlendConstantsDirty;
  5990. private _alphaBlend;
  5991. private _blendFunctionParameters;
  5992. private _blendEquationParameters;
  5993. private _blendConstants;
  5994. /**
  5995. * Initializes the state.
  5996. */
  5997. constructor();
  5998. readonly isDirty: boolean;
  5999. alphaBlend: boolean;
  6000. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6001. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6002. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6003. reset(): void;
  6004. apply(gl: WebGLRenderingContext): void;
  6005. }
  6006. }
  6007. declare module "babylonjs/States/depthCullingState" {
  6008. import { Nullable } from "babylonjs/types";
  6009. /**
  6010. * @hidden
  6011. **/
  6012. export class _DepthCullingState {
  6013. private _isDepthTestDirty;
  6014. private _isDepthMaskDirty;
  6015. private _isDepthFuncDirty;
  6016. private _isCullFaceDirty;
  6017. private _isCullDirty;
  6018. private _isZOffsetDirty;
  6019. private _isFrontFaceDirty;
  6020. private _depthTest;
  6021. private _depthMask;
  6022. private _depthFunc;
  6023. private _cull;
  6024. private _cullFace;
  6025. private _zOffset;
  6026. private _frontFace;
  6027. /**
  6028. * Initializes the state.
  6029. */
  6030. constructor();
  6031. readonly isDirty: boolean;
  6032. zOffset: number;
  6033. cullFace: Nullable<number>;
  6034. cull: Nullable<boolean>;
  6035. depthFunc: Nullable<number>;
  6036. depthMask: boolean;
  6037. depthTest: boolean;
  6038. frontFace: Nullable<number>;
  6039. reset(): void;
  6040. apply(gl: WebGLRenderingContext): void;
  6041. }
  6042. }
  6043. declare module "babylonjs/States/stencilState" {
  6044. /**
  6045. * @hidden
  6046. **/
  6047. export class _StencilState {
  6048. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6049. static readonly ALWAYS: number;
  6050. /** Passed to stencilOperation to specify that stencil value must be kept */
  6051. static readonly KEEP: number;
  6052. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6053. static readonly REPLACE: number;
  6054. private _isStencilTestDirty;
  6055. private _isStencilMaskDirty;
  6056. private _isStencilFuncDirty;
  6057. private _isStencilOpDirty;
  6058. private _stencilTest;
  6059. private _stencilMask;
  6060. private _stencilFunc;
  6061. private _stencilFuncRef;
  6062. private _stencilFuncMask;
  6063. private _stencilOpStencilFail;
  6064. private _stencilOpDepthFail;
  6065. private _stencilOpStencilDepthPass;
  6066. readonly isDirty: boolean;
  6067. stencilFunc: number;
  6068. stencilFuncRef: number;
  6069. stencilFuncMask: number;
  6070. stencilOpStencilFail: number;
  6071. stencilOpDepthFail: number;
  6072. stencilOpStencilDepthPass: number;
  6073. stencilMask: number;
  6074. stencilTest: boolean;
  6075. constructor();
  6076. reset(): void;
  6077. apply(gl: WebGLRenderingContext): void;
  6078. }
  6079. }
  6080. declare module "babylonjs/States/index" {
  6081. export * from "babylonjs/States/alphaCullingState";
  6082. export * from "babylonjs/States/depthCullingState";
  6083. export * from "babylonjs/States/stencilState";
  6084. }
  6085. declare module "babylonjs/Instrumentation/timeToken" {
  6086. import { Nullable } from "babylonjs/types";
  6087. /**
  6088. * @hidden
  6089. **/
  6090. export class _TimeToken {
  6091. _startTimeQuery: Nullable<WebGLQuery>;
  6092. _endTimeQuery: Nullable<WebGLQuery>;
  6093. _timeElapsedQuery: Nullable<WebGLQuery>;
  6094. _timeElapsedQueryEnded: boolean;
  6095. }
  6096. }
  6097. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6098. import { Nullable } from "babylonjs/types";
  6099. /**
  6100. * Internal interface used to track InternalTexture already bound to the GL context
  6101. */
  6102. export interface IInternalTextureTracker {
  6103. /**
  6104. * Gets or set the previous tracker in the list
  6105. */
  6106. previous: Nullable<IInternalTextureTracker>;
  6107. /**
  6108. * Gets or set the next tracker in the list
  6109. */
  6110. next: Nullable<IInternalTextureTracker>;
  6111. }
  6112. /**
  6113. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6114. */
  6115. export class DummyInternalTextureTracker {
  6116. /**
  6117. * Gets or set the previous tracker in the list
  6118. */
  6119. previous: Nullable<IInternalTextureTracker>;
  6120. /**
  6121. * Gets or set the next tracker in the list
  6122. */
  6123. next: Nullable<IInternalTextureTracker>;
  6124. }
  6125. }
  6126. declare module "babylonjs/Materials/Textures/internalTexture" {
  6127. import { Observable } from "babylonjs/Misc/observable";
  6128. import { Nullable, int } from "babylonjs/types";
  6129. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6130. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6131. import { Engine } from "babylonjs/Engines/engine";
  6132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6133. /**
  6134. * Class used to store data associated with WebGL texture data for the engine
  6135. * This class should not be used directly
  6136. */
  6137. export class InternalTexture implements IInternalTextureTracker {
  6138. /** hidden */
  6139. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6140. /**
  6141. * The source of the texture data is unknown
  6142. */
  6143. static DATASOURCE_UNKNOWN: number;
  6144. /**
  6145. * Texture data comes from an URL
  6146. */
  6147. static DATASOURCE_URL: number;
  6148. /**
  6149. * Texture data is only used for temporary storage
  6150. */
  6151. static DATASOURCE_TEMP: number;
  6152. /**
  6153. * Texture data comes from raw data (ArrayBuffer)
  6154. */
  6155. static DATASOURCE_RAW: number;
  6156. /**
  6157. * Texture content is dynamic (video or dynamic texture)
  6158. */
  6159. static DATASOURCE_DYNAMIC: number;
  6160. /**
  6161. * Texture content is generated by rendering to it
  6162. */
  6163. static DATASOURCE_RENDERTARGET: number;
  6164. /**
  6165. * Texture content is part of a multi render target process
  6166. */
  6167. static DATASOURCE_MULTIRENDERTARGET: number;
  6168. /**
  6169. * Texture data comes from a cube data file
  6170. */
  6171. static DATASOURCE_CUBE: number;
  6172. /**
  6173. * Texture data comes from a raw cube data
  6174. */
  6175. static DATASOURCE_CUBERAW: number;
  6176. /**
  6177. * Texture data come from a prefiltered cube data file
  6178. */
  6179. static DATASOURCE_CUBEPREFILTERED: number;
  6180. /**
  6181. * Texture content is raw 3D data
  6182. */
  6183. static DATASOURCE_RAW3D: number;
  6184. /**
  6185. * Texture content is a depth texture
  6186. */
  6187. static DATASOURCE_DEPTHTEXTURE: number;
  6188. /**
  6189. * Texture data comes from a raw cube data encoded with RGBD
  6190. */
  6191. static DATASOURCE_CUBERAW_RGBD: number;
  6192. /**
  6193. * Defines if the texture is ready
  6194. */
  6195. isReady: boolean;
  6196. /**
  6197. * Defines if the texture is a cube texture
  6198. */
  6199. isCube: boolean;
  6200. /**
  6201. * Defines if the texture contains 3D data
  6202. */
  6203. is3D: boolean;
  6204. /**
  6205. * Gets the URL used to load this texture
  6206. */
  6207. url: string;
  6208. /**
  6209. * Gets the sampling mode of the texture
  6210. */
  6211. samplingMode: number;
  6212. /**
  6213. * Gets a boolean indicating if the texture needs mipmaps generation
  6214. */
  6215. generateMipMaps: boolean;
  6216. /**
  6217. * Gets the number of samples used by the texture (WebGL2+ only)
  6218. */
  6219. samples: number;
  6220. /**
  6221. * Gets the type of the texture (int, float...)
  6222. */
  6223. type: number;
  6224. /**
  6225. * Gets the format of the texture (RGB, RGBA...)
  6226. */
  6227. format: number;
  6228. /**
  6229. * Observable called when the texture is loaded
  6230. */
  6231. onLoadedObservable: Observable<InternalTexture>;
  6232. /**
  6233. * Gets the width of the texture
  6234. */
  6235. width: number;
  6236. /**
  6237. * Gets the height of the texture
  6238. */
  6239. height: number;
  6240. /**
  6241. * Gets the depth of the texture
  6242. */
  6243. depth: number;
  6244. /**
  6245. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6246. */
  6247. baseWidth: number;
  6248. /**
  6249. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6250. */
  6251. baseHeight: number;
  6252. /**
  6253. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6254. */
  6255. baseDepth: number;
  6256. /**
  6257. * Gets a boolean indicating if the texture is inverted on Y axis
  6258. */
  6259. invertY: boolean;
  6260. /**
  6261. * Gets or set the previous tracker in the list
  6262. */
  6263. previous: Nullable<IInternalTextureTracker>;
  6264. /**
  6265. * Gets or set the next tracker in the list
  6266. */
  6267. next: Nullable<IInternalTextureTracker>;
  6268. /** @hidden */
  6269. _invertVScale: boolean;
  6270. /** @hidden */
  6271. _initialSlot: number;
  6272. /** @hidden */
  6273. _designatedSlot: number;
  6274. /** @hidden */
  6275. _dataSource: number;
  6276. /** @hidden */
  6277. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6278. /** @hidden */
  6279. _bufferView: Nullable<ArrayBufferView>;
  6280. /** @hidden */
  6281. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6282. /** @hidden */
  6283. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6284. /** @hidden */
  6285. _size: number;
  6286. /** @hidden */
  6287. _extension: string;
  6288. /** @hidden */
  6289. _files: Nullable<string[]>;
  6290. /** @hidden */
  6291. _workingCanvas: HTMLCanvasElement;
  6292. /** @hidden */
  6293. _workingContext: CanvasRenderingContext2D;
  6294. /** @hidden */
  6295. _framebuffer: Nullable<WebGLFramebuffer>;
  6296. /** @hidden */
  6297. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6298. /** @hidden */
  6299. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6300. /** @hidden */
  6301. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6302. /** @hidden */
  6303. _attachments: Nullable<number[]>;
  6304. /** @hidden */
  6305. _cachedCoordinatesMode: Nullable<number>;
  6306. /** @hidden */
  6307. _cachedWrapU: Nullable<number>;
  6308. /** @hidden */
  6309. _cachedWrapV: Nullable<number>;
  6310. /** @hidden */
  6311. _cachedWrapR: Nullable<number>;
  6312. /** @hidden */
  6313. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6314. /** @hidden */
  6315. _isDisabled: boolean;
  6316. /** @hidden */
  6317. _compression: Nullable<string>;
  6318. /** @hidden */
  6319. _generateStencilBuffer: boolean;
  6320. /** @hidden */
  6321. _generateDepthBuffer: boolean;
  6322. /** @hidden */
  6323. _comparisonFunction: number;
  6324. /** @hidden */
  6325. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6326. /** @hidden */
  6327. _lodGenerationScale: number;
  6328. /** @hidden */
  6329. _lodGenerationOffset: number;
  6330. /** @hidden */
  6331. _lodTextureHigh: BaseTexture;
  6332. /** @hidden */
  6333. _lodTextureMid: BaseTexture;
  6334. /** @hidden */
  6335. _lodTextureLow: BaseTexture;
  6336. /** @hidden */
  6337. _isRGBD: boolean;
  6338. /** @hidden */
  6339. _webGLTexture: Nullable<WebGLTexture>;
  6340. /** @hidden */
  6341. _references: number;
  6342. private _engine;
  6343. /**
  6344. * Gets the Engine the texture belongs to.
  6345. * @returns The babylon engine
  6346. */
  6347. getEngine(): Engine;
  6348. /**
  6349. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6350. */
  6351. readonly dataSource: number;
  6352. /**
  6353. * Creates a new InternalTexture
  6354. * @param engine defines the engine to use
  6355. * @param dataSource defines the type of data that will be used
  6356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6357. */
  6358. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6359. /**
  6360. * Increments the number of references (ie. the number of Texture that point to it)
  6361. */
  6362. incrementReferences(): void;
  6363. /**
  6364. * Change the size of the texture (not the size of the content)
  6365. * @param width defines the new width
  6366. * @param height defines the new height
  6367. * @param depth defines the new depth (1 by default)
  6368. */
  6369. updateSize(width: int, height: int, depth?: int): void;
  6370. /** @hidden */
  6371. _rebuild(): void;
  6372. /** @hidden */
  6373. _swapAndDie(target: InternalTexture): void;
  6374. /**
  6375. * Dispose the current allocated resources
  6376. */
  6377. dispose(): void;
  6378. }
  6379. }
  6380. declare module "babylonjs/Animations/easing" {
  6381. /**
  6382. * This represents the main contract an easing function should follow.
  6383. * Easing functions are used throughout the animation system.
  6384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6385. */
  6386. export interface IEasingFunction {
  6387. /**
  6388. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6389. * of the easing function.
  6390. * The link below provides some of the most common examples of easing functions.
  6391. * @see https://easings.net/
  6392. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6393. * @returns the corresponding value on the curve defined by the easing function
  6394. */
  6395. ease(gradient: number): number;
  6396. }
  6397. /**
  6398. * Base class used for every default easing function.
  6399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6400. */
  6401. export class EasingFunction implements IEasingFunction {
  6402. /**
  6403. * Interpolation follows the mathematical formula associated with the easing function.
  6404. */
  6405. static readonly EASINGMODE_EASEIN: number;
  6406. /**
  6407. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6408. */
  6409. static readonly EASINGMODE_EASEOUT: number;
  6410. /**
  6411. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6412. */
  6413. static readonly EASINGMODE_EASEINOUT: number;
  6414. private _easingMode;
  6415. /**
  6416. * Sets the easing mode of the current function.
  6417. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6418. */
  6419. setEasingMode(easingMode: number): void;
  6420. /**
  6421. * Gets the current easing mode.
  6422. * @returns the easing mode
  6423. */
  6424. getEasingMode(): number;
  6425. /**
  6426. * @hidden
  6427. */
  6428. easeInCore(gradient: number): number;
  6429. /**
  6430. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6431. * of the easing function.
  6432. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6433. * @returns the corresponding value on the curve defined by the easing function
  6434. */
  6435. ease(gradient: number): number;
  6436. }
  6437. /**
  6438. * Easing function with a circle shape (see link below).
  6439. * @see https://easings.net/#easeInCirc
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export class CircleEase extends EasingFunction implements IEasingFunction {
  6443. /** @hidden */
  6444. easeInCore(gradient: number): number;
  6445. }
  6446. /**
  6447. * Easing function with a ease back shape (see link below).
  6448. * @see https://easings.net/#easeInBack
  6449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6450. */
  6451. export class BackEase extends EasingFunction implements IEasingFunction {
  6452. /** Defines the amplitude of the function */
  6453. amplitude: number;
  6454. /**
  6455. * Instantiates a back ease easing
  6456. * @see https://easings.net/#easeInBack
  6457. * @param amplitude Defines the amplitude of the function
  6458. */
  6459. constructor(
  6460. /** Defines the amplitude of the function */
  6461. amplitude?: number);
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with a bouncing shape (see link below).
  6467. * @see https://easings.net/#easeInBounce
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class BounceEase extends EasingFunction implements IEasingFunction {
  6471. /** Defines the number of bounces */
  6472. bounces: number;
  6473. /** Defines the amplitude of the bounce */
  6474. bounciness: number;
  6475. /**
  6476. * Instantiates a bounce easing
  6477. * @see https://easings.net/#easeInBounce
  6478. * @param bounces Defines the number of bounces
  6479. * @param bounciness Defines the amplitude of the bounce
  6480. */
  6481. constructor(
  6482. /** Defines the number of bounces */
  6483. bounces?: number,
  6484. /** Defines the amplitude of the bounce */
  6485. bounciness?: number);
  6486. /** @hidden */
  6487. easeInCore(gradient: number): number;
  6488. }
  6489. /**
  6490. * Easing function with a power of 3 shape (see link below).
  6491. * @see https://easings.net/#easeInCubic
  6492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6493. */
  6494. export class CubicEase extends EasingFunction implements IEasingFunction {
  6495. /** @hidden */
  6496. easeInCore(gradient: number): number;
  6497. }
  6498. /**
  6499. * Easing function with an elastic shape (see link below).
  6500. * @see https://easings.net/#easeInElastic
  6501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6502. */
  6503. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6504. /** Defines the number of oscillations*/
  6505. oscillations: number;
  6506. /** Defines the amplitude of the oscillations*/
  6507. springiness: number;
  6508. /**
  6509. * Instantiates an elastic easing function
  6510. * @see https://easings.net/#easeInElastic
  6511. * @param oscillations Defines the number of oscillations
  6512. * @param springiness Defines the amplitude of the oscillations
  6513. */
  6514. constructor(
  6515. /** Defines the number of oscillations*/
  6516. oscillations?: number,
  6517. /** Defines the amplitude of the oscillations*/
  6518. springiness?: number);
  6519. /** @hidden */
  6520. easeInCore(gradient: number): number;
  6521. }
  6522. /**
  6523. * Easing function with an exponential shape (see link below).
  6524. * @see https://easings.net/#easeInExpo
  6525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6526. */
  6527. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6528. /** Defines the exponent of the function */
  6529. exponent: number;
  6530. /**
  6531. * Instantiates an exponential easing function
  6532. * @see https://easings.net/#easeInExpo
  6533. * @param exponent Defines the exponent of the function
  6534. */
  6535. constructor(
  6536. /** Defines the exponent of the function */
  6537. exponent?: number);
  6538. /** @hidden */
  6539. easeInCore(gradient: number): number;
  6540. }
  6541. /**
  6542. * Easing function with a power shape (see link below).
  6543. * @see https://easings.net/#easeInQuad
  6544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6545. */
  6546. export class PowerEase extends EasingFunction implements IEasingFunction {
  6547. /** Defines the power of the function */
  6548. power: number;
  6549. /**
  6550. * Instantiates an power base easing function
  6551. * @see https://easings.net/#easeInQuad
  6552. * @param power Defines the power of the function
  6553. */
  6554. constructor(
  6555. /** Defines the power of the function */
  6556. power?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 2 shape (see link below).
  6562. * @see https://easings.net/#easeInQuad
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with a power of 4 shape (see link below).
  6571. * @see https://easings.net/#easeInQuart
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 5 shape (see link below).
  6580. * @see https://easings.net/#easeInQuint
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a sin shape (see link below).
  6589. * @see https://easings.net/#easeInSine
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class SineEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with a bezier shape (see link below).
  6598. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the x component of the start tangent in the bezier curve */
  6603. x1: number;
  6604. /** Defines the y component of the start tangent in the bezier curve */
  6605. y1: number;
  6606. /** Defines the x component of the end tangent in the bezier curve */
  6607. x2: number;
  6608. /** Defines the y component of the end tangent in the bezier curve */
  6609. y2: number;
  6610. /**
  6611. * Instantiates a bezier function
  6612. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6613. * @param x1 Defines the x component of the start tangent in the bezier curve
  6614. * @param y1 Defines the y component of the start tangent in the bezier curve
  6615. * @param x2 Defines the x component of the end tangent in the bezier curve
  6616. * @param y2 Defines the y component of the end tangent in the bezier curve
  6617. */
  6618. constructor(
  6619. /** Defines the x component of the start tangent in the bezier curve */
  6620. x1?: number,
  6621. /** Defines the y component of the start tangent in the bezier curve */
  6622. y1?: number,
  6623. /** Defines the x component of the end tangent in the bezier curve */
  6624. x2?: number,
  6625. /** Defines the y component of the end tangent in the bezier curve */
  6626. y2?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. }
  6631. declare module "babylonjs/Animations/animationKey" {
  6632. /**
  6633. * Defines an interface which represents an animation key frame
  6634. */
  6635. export interface IAnimationKey {
  6636. /**
  6637. * Frame of the key frame
  6638. */
  6639. frame: number;
  6640. /**
  6641. * Value at the specifies key frame
  6642. */
  6643. value: any;
  6644. /**
  6645. * The input tangent for the cubic hermite spline
  6646. */
  6647. inTangent?: any;
  6648. /**
  6649. * The output tangent for the cubic hermite spline
  6650. */
  6651. outTangent?: any;
  6652. /**
  6653. * The animation interpolation type
  6654. */
  6655. interpolation?: AnimationKeyInterpolation;
  6656. }
  6657. /**
  6658. * Enum for the animation key frame interpolation type
  6659. */
  6660. export enum AnimationKeyInterpolation {
  6661. /**
  6662. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6663. */
  6664. STEP = 1
  6665. }
  6666. }
  6667. declare module "babylonjs/Animations/animationRange" {
  6668. /**
  6669. * Represents the range of an animation
  6670. */
  6671. export class AnimationRange {
  6672. /**The name of the animation range**/
  6673. name: string;
  6674. /**The starting frame of the animation */
  6675. from: number;
  6676. /**The ending frame of the animation*/
  6677. to: number;
  6678. /**
  6679. * Initializes the range of an animation
  6680. * @param name The name of the animation range
  6681. * @param from The starting frame of the animation
  6682. * @param to The ending frame of the animation
  6683. */
  6684. constructor(
  6685. /**The name of the animation range**/
  6686. name: string,
  6687. /**The starting frame of the animation */
  6688. from: number,
  6689. /**The ending frame of the animation*/
  6690. to: number);
  6691. /**
  6692. * Makes a copy of the animation range
  6693. * @returns A copy of the animation range
  6694. */
  6695. clone(): AnimationRange;
  6696. }
  6697. }
  6698. declare module "babylonjs/Animations/animationEvent" {
  6699. /**
  6700. * Composed of a frame, and an action function
  6701. */
  6702. export class AnimationEvent {
  6703. /** The frame for which the event is triggered **/
  6704. frame: number;
  6705. /** The event to perform when triggered **/
  6706. action: (currentFrame: number) => void;
  6707. /** Specifies if the event should be triggered only once**/
  6708. onlyOnce?: boolean | undefined;
  6709. /**
  6710. * Specifies if the animation event is done
  6711. */
  6712. isDone: boolean;
  6713. /**
  6714. * Initializes the animation event
  6715. * @param frame The frame for which the event is triggered
  6716. * @param action The event to perform when triggered
  6717. * @param onlyOnce Specifies if the event should be triggered only once
  6718. */
  6719. constructor(
  6720. /** The frame for which the event is triggered **/
  6721. frame: number,
  6722. /** The event to perform when triggered **/
  6723. action: (currentFrame: number) => void,
  6724. /** Specifies if the event should be triggered only once**/
  6725. onlyOnce?: boolean | undefined);
  6726. /** @hidden */
  6727. _clone(): AnimationEvent;
  6728. }
  6729. }
  6730. declare module "babylonjs/Behaviors/behavior" {
  6731. import { Nullable } from "babylonjs/types";
  6732. /**
  6733. * Interface used to define a behavior
  6734. */
  6735. export interface Behavior<T> {
  6736. /** gets or sets behavior's name */
  6737. name: string;
  6738. /**
  6739. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6740. */
  6741. init(): void;
  6742. /**
  6743. * Called when the behavior is attached to a target
  6744. * @param target defines the target where the behavior is attached to
  6745. */
  6746. attach(target: T): void;
  6747. /**
  6748. * Called when the behavior is detached from its target
  6749. */
  6750. detach(): void;
  6751. }
  6752. /**
  6753. * Interface implemented by classes supporting behaviors
  6754. */
  6755. export interface IBehaviorAware<T> {
  6756. /**
  6757. * Attach a behavior
  6758. * @param behavior defines the behavior to attach
  6759. * @returns the current host
  6760. */
  6761. addBehavior(behavior: Behavior<T>): T;
  6762. /**
  6763. * Remove a behavior from the current object
  6764. * @param behavior defines the behavior to detach
  6765. * @returns the current host
  6766. */
  6767. removeBehavior(behavior: Behavior<T>): T;
  6768. /**
  6769. * Gets a behavior using its name to search
  6770. * @param name defines the name to search
  6771. * @returns the behavior or null if not found
  6772. */
  6773. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/intersectionInfo" {
  6777. import { Nullable } from "babylonjs/types";
  6778. /**
  6779. * @hidden
  6780. */
  6781. export class IntersectionInfo {
  6782. bu: Nullable<number>;
  6783. bv: Nullable<number>;
  6784. distance: number;
  6785. faceId: number;
  6786. subMeshId: number;
  6787. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6788. }
  6789. }
  6790. declare module "babylonjs/Culling/boundingSphere" {
  6791. import { DeepImmutable } from "babylonjs/types";
  6792. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6793. /**
  6794. * Class used to store bounding sphere information
  6795. */
  6796. export class BoundingSphere {
  6797. /**
  6798. * Gets the center of the bounding sphere in local space
  6799. */
  6800. readonly center: Vector3;
  6801. /**
  6802. * Radius of the bounding sphere in local space
  6803. */
  6804. radius: number;
  6805. /**
  6806. * Gets the center of the bounding sphere in world space
  6807. */
  6808. readonly centerWorld: Vector3;
  6809. /**
  6810. * Radius of the bounding sphere in world space
  6811. */
  6812. radiusWorld: number;
  6813. /**
  6814. * Gets the minimum vector in local space
  6815. */
  6816. readonly minimum: Vector3;
  6817. /**
  6818. * Gets the maximum vector in local space
  6819. */
  6820. readonly maximum: Vector3;
  6821. private _worldMatrix;
  6822. private static readonly TmpVector3;
  6823. /**
  6824. * Creates a new bounding sphere
  6825. * @param min defines the minimum vector (in local space)
  6826. * @param max defines the maximum vector (in local space)
  6827. * @param worldMatrix defines the new world matrix
  6828. */
  6829. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6830. /**
  6831. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6832. * @param min defines the new minimum vector (in local space)
  6833. * @param max defines the new maximum vector (in local space)
  6834. * @param worldMatrix defines the new world matrix
  6835. */
  6836. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6837. /**
  6838. * Scale the current bounding sphere by applying a scale factor
  6839. * @param factor defines the scale factor to apply
  6840. * @returns the current bounding box
  6841. */
  6842. scale(factor: number): BoundingSphere;
  6843. /**
  6844. * Gets the world matrix of the bounding box
  6845. * @returns a matrix
  6846. */
  6847. getWorldMatrix(): DeepImmutable<Matrix>;
  6848. /** @hidden */
  6849. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Tests if the bounding sphere is intersecting the frustum planes
  6852. * @param frustumPlanes defines the frustum planes to test
  6853. * @returns true if there is an intersection
  6854. */
  6855. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6856. /**
  6857. * Tests if the bounding sphere center is in between the frustum planes.
  6858. * Used for optimistic fast inclusion.
  6859. * @param frustumPlanes defines the frustum planes to test
  6860. * @returns true if the sphere center is in between the frustum planes
  6861. */
  6862. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6863. /**
  6864. * Tests if a point is inside the bounding sphere
  6865. * @param point defines the point to test
  6866. * @returns true if the point is inside the bounding sphere
  6867. */
  6868. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6869. /**
  6870. * Checks if two sphere intersct
  6871. * @param sphere0 sphere 0
  6872. * @param sphere1 sphere 1
  6873. * @returns true if the speres intersect
  6874. */
  6875. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6876. }
  6877. }
  6878. declare module "babylonjs/Culling/boundingBox" {
  6879. import { DeepImmutable } from "babylonjs/types";
  6880. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6881. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6882. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6883. /**
  6884. * Class used to store bounding box information
  6885. */
  6886. export class BoundingBox implements ICullable {
  6887. /**
  6888. * Gets the 8 vectors representing the bounding box in local space
  6889. */
  6890. readonly vectors: Vector3[];
  6891. /**
  6892. * Gets the center of the bounding box in local space
  6893. */
  6894. readonly center: Vector3;
  6895. /**
  6896. * Gets the center of the bounding box in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Gets the extend size in local space
  6901. */
  6902. readonly extendSize: Vector3;
  6903. /**
  6904. * Gets the extend size in world space
  6905. */
  6906. readonly extendSizeWorld: Vector3;
  6907. /**
  6908. * Gets the OBB (object bounding box) directions
  6909. */
  6910. readonly directions: Vector3[];
  6911. /**
  6912. * Gets the 8 vectors representing the bounding box in world space
  6913. */
  6914. readonly vectorsWorld: Vector3[];
  6915. /**
  6916. * Gets the minimum vector in world space
  6917. */
  6918. readonly minimumWorld: Vector3;
  6919. /**
  6920. * Gets the maximum vector in world space
  6921. */
  6922. readonly maximumWorld: Vector3;
  6923. /**
  6924. * Gets the minimum vector in local space
  6925. */
  6926. readonly minimum: Vector3;
  6927. /**
  6928. * Gets the maximum vector in local space
  6929. */
  6930. readonly maximum: Vector3;
  6931. private _worldMatrix;
  6932. private static readonly TmpVector3;
  6933. /**
  6934. * @hidden
  6935. */
  6936. _tag: number;
  6937. /**
  6938. * Creates a new bounding box
  6939. * @param min defines the minimum vector (in local space)
  6940. * @param max defines the maximum vector (in local space)
  6941. * @param worldMatrix defines the new world matrix
  6942. */
  6943. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6944. /**
  6945. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6946. * @param min defines the new minimum vector (in local space)
  6947. * @param max defines the new maximum vector (in local space)
  6948. * @param worldMatrix defines the new world matrix
  6949. */
  6950. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6951. /**
  6952. * Scale the current bounding box by applying a scale factor
  6953. * @param factor defines the scale factor to apply
  6954. * @returns the current bounding box
  6955. */
  6956. scale(factor: number): BoundingBox;
  6957. /**
  6958. * Gets the world matrix of the bounding box
  6959. * @returns a matrix
  6960. */
  6961. getWorldMatrix(): DeepImmutable<Matrix>;
  6962. /** @hidden */
  6963. _update(world: DeepImmutable<Matrix>): void;
  6964. /**
  6965. * Tests if the bounding box is intersecting the frustum planes
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if the bounding box is entirely inside the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an inclusion
  6974. */
  6975. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if a point is inside the bounding box
  6978. * @param point defines the point to test
  6979. * @returns true if the point is inside the bounding box
  6980. */
  6981. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6982. /**
  6983. * Tests if the bounding box intersects with a bounding sphere
  6984. * @param sphere defines the sphere to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6988. /**
  6989. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6990. * @param min defines the min vector to use
  6991. * @param max defines the max vector to use
  6992. * @returns true if there is an intersection
  6993. */
  6994. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if two bounding boxes are intersections
  6997. * @param box0 defines the first box to test
  6998. * @param box1 defines the second box to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7002. /**
  7003. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7004. * @param minPoint defines the minimum vector of the bounding box
  7005. * @param maxPoint defines the maximum vector of the bounding box
  7006. * @param sphereCenter defines the sphere center
  7007. * @param sphereRadius defines the sphere radius
  7008. * @returns true if there is an intersection
  7009. */
  7010. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7011. /**
  7012. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7013. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7014. * @param frustumPlanes defines the frustum planes to test
  7015. * @return true if there is an inclusion
  7016. */
  7017. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7018. /**
  7019. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7020. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @return true if there is an intersection
  7023. */
  7024. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. }
  7026. }
  7027. declare module "babylonjs/Collisions/collider" {
  7028. import { Nullable, IndicesArray } from "babylonjs/types";
  7029. import { Vector3, Plane } from "babylonjs/Maths/math";
  7030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7031. /** @hidden */
  7032. export class Collider {
  7033. /** Define if a collision was found */
  7034. collisionFound: boolean;
  7035. /**
  7036. * Define last intersection point in local space
  7037. */
  7038. intersectionPoint: Vector3;
  7039. /**
  7040. * Define last collided mesh
  7041. */
  7042. collidedMesh: Nullable<AbstractMesh>;
  7043. private _collisionPoint;
  7044. private _planeIntersectionPoint;
  7045. private _tempVector;
  7046. private _tempVector2;
  7047. private _tempVector3;
  7048. private _tempVector4;
  7049. private _edge;
  7050. private _baseToVertex;
  7051. private _destinationPoint;
  7052. private _slidePlaneNormal;
  7053. private _displacementVector;
  7054. /** @hidden */
  7055. _radius: Vector3;
  7056. /** @hidden */
  7057. _retry: number;
  7058. private _velocity;
  7059. private _basePoint;
  7060. private _epsilon;
  7061. /** @hidden */
  7062. _velocityWorldLength: number;
  7063. /** @hidden */
  7064. _basePointWorld: Vector3;
  7065. private _velocityWorld;
  7066. private _normalizedVelocity;
  7067. /** @hidden */
  7068. _initialVelocity: Vector3;
  7069. /** @hidden */
  7070. _initialPosition: Vector3;
  7071. private _nearestDistance;
  7072. private _collisionMask;
  7073. collisionMask: number;
  7074. /**
  7075. * Gets the plane normal used to compute the sliding response (in local space)
  7076. */
  7077. readonly slidePlaneNormal: Vector3;
  7078. /** @hidden */
  7079. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7080. /** @hidden */
  7081. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7082. /** @hidden */
  7083. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7084. /** @hidden */
  7085. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7086. /** @hidden */
  7087. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7088. /** @hidden */
  7089. _getResponse(pos: Vector3, vel: Vector3): void;
  7090. }
  7091. }
  7092. declare module "babylonjs/Culling/boundingInfo" {
  7093. import { DeepImmutable } from "babylonjs/types";
  7094. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7095. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7096. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7097. import { Collider } from "babylonjs/Collisions/collider";
  7098. /**
  7099. * Interface for cullable objects
  7100. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7101. */
  7102. export interface ICullable {
  7103. /**
  7104. * Checks if the object or part of the object is in the frustum
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isInFrustum(frustumPlanes: Plane[]): boolean;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7116. }
  7117. /**
  7118. * Info for a bounding data of a mesh
  7119. */
  7120. export class BoundingInfo implements ICullable {
  7121. /**
  7122. * Bounding box for the mesh
  7123. */
  7124. readonly boundingBox: BoundingBox;
  7125. /**
  7126. * Bounding sphere for the mesh
  7127. */
  7128. readonly boundingSphere: BoundingSphere;
  7129. private _isLocked;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Constructs bounding info
  7133. * @param minimum min vector of the bounding box/sphere
  7134. * @param maximum max vector of the bounding box/sphere
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * min vector of the bounding box/sphere
  7147. */
  7148. readonly minimum: Vector3;
  7149. /**
  7150. * max vector of the bounding box/sphere
  7151. */
  7152. readonly maximum: Vector3;
  7153. /**
  7154. * If the info is locked and won't be updated to avoid perf overhead
  7155. */
  7156. isLocked: boolean;
  7157. /**
  7158. * Updates the bounding sphere and box
  7159. * @param world world matrix to be used to update
  7160. */
  7161. update(world: DeepImmutable<Matrix>): void;
  7162. /**
  7163. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7164. * @param center New center of the bounding info
  7165. * @param extend New extend of the bounding info
  7166. * @returns the current bounding info
  7167. */
  7168. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7169. /**
  7170. * Scale the current bounding info by applying a scale factor
  7171. * @param factor defines the scale factor to apply
  7172. * @returns the current bounding info
  7173. */
  7174. scale(factor: number): BoundingInfo;
  7175. /**
  7176. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7177. * @param frustumPlanes defines the frustum to test
  7178. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7179. * @returns true if the bounding info is in the frustum planes
  7180. */
  7181. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7182. /**
  7183. * Gets the world distance between the min and max points of the bounding box
  7184. */
  7185. readonly diagonalLength: number;
  7186. /**
  7187. * Checks if a cullable object (mesh...) is in the camera frustum
  7188. * Unlike isInFrustum this cheks the full bounding box
  7189. * @param frustumPlanes Camera near/planes
  7190. * @returns true if the object is in frustum otherwise false
  7191. */
  7192. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7193. /** @hidden */
  7194. _checkCollision(collider: Collider): boolean;
  7195. /**
  7196. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7197. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7198. * @param point the point to check intersection with
  7199. * @returns if the point intersects
  7200. */
  7201. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7202. /**
  7203. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param boundingInfo the bounding info to check intersection with
  7206. * @param precise if the intersection should be done using OBB
  7207. * @returns if the bounding info intersects
  7208. */
  7209. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7210. }
  7211. }
  7212. declare module "babylonjs/Misc/smartArray" {
  7213. /**
  7214. * Defines an array and its length.
  7215. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7216. */
  7217. export interface ISmartArrayLike<T> {
  7218. /**
  7219. * The data of the array.
  7220. */
  7221. data: Array<T>;
  7222. /**
  7223. * The active length of the array.
  7224. */
  7225. length: number;
  7226. }
  7227. /**
  7228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7229. */
  7230. export class SmartArray<T> implements ISmartArrayLike<T> {
  7231. /**
  7232. * The full set of data from the array.
  7233. */
  7234. data: Array<T>;
  7235. /**
  7236. * The active length of the array.
  7237. */
  7238. length: number;
  7239. protected _id: number;
  7240. /**
  7241. * Instantiates a Smart Array.
  7242. * @param capacity defines the default capacity of the array.
  7243. */
  7244. constructor(capacity: number);
  7245. /**
  7246. * Pushes a value at the end of the active data.
  7247. * @param value defines the object to push in the array.
  7248. */
  7249. push(value: T): void;
  7250. /**
  7251. * Iterates over the active data and apply the lambda to them.
  7252. * @param func defines the action to apply on each value.
  7253. */
  7254. forEach(func: (content: T) => void): void;
  7255. /**
  7256. * Sorts the full sets of data.
  7257. * @param compareFn defines the comparison function to apply.
  7258. */
  7259. sort(compareFn: (a: T, b: T) => number): void;
  7260. /**
  7261. * Resets the active data to an empty array.
  7262. */
  7263. reset(): void;
  7264. /**
  7265. * Releases all the data from the array as well as the array.
  7266. */
  7267. dispose(): void;
  7268. /**
  7269. * Concats the active data with a given array.
  7270. * @param array defines the data to concatenate with.
  7271. */
  7272. concat(array: any): void;
  7273. /**
  7274. * Returns the position of a value in the active data.
  7275. * @param value defines the value to find the index for
  7276. * @returns the index if found in the active data otherwise -1
  7277. */
  7278. indexOf(value: T): number;
  7279. /**
  7280. * Returns whether an element is part of the active data.
  7281. * @param value defines the value to look for
  7282. * @returns true if found in the active data otherwise false
  7283. */
  7284. contains(value: T): boolean;
  7285. private static _GlobalId;
  7286. }
  7287. /**
  7288. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7289. * The data in this array can only be present once
  7290. */
  7291. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7292. private _duplicateId;
  7293. /**
  7294. * Pushes a value at the end of the active data.
  7295. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7296. * @param value defines the object to push in the array.
  7297. */
  7298. push(value: T): void;
  7299. /**
  7300. * Pushes a value at the end of the active data.
  7301. * If the data is already present, it won t be added again
  7302. * @param value defines the object to push in the array.
  7303. * @returns true if added false if it was already present
  7304. */
  7305. pushNoDuplicate(value: T): boolean;
  7306. /**
  7307. * Resets the active data to an empty array.
  7308. */
  7309. reset(): void;
  7310. /**
  7311. * Concats the active data with a given array.
  7312. * This ensures no dupplicate will be present in the result.
  7313. * @param array defines the data to concatenate with.
  7314. */
  7315. concatWithNoDuplicate(array: any): void;
  7316. }
  7317. }
  7318. declare module "babylonjs/Materials/multiMaterial" {
  7319. import { Nullable } from "babylonjs/types";
  7320. import { Scene } from "babylonjs/scene";
  7321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7322. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7324. import { Material } from "babylonjs/Materials/material";
  7325. /**
  7326. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7327. * separate meshes. This can be use to improve performances.
  7328. * @see http://doc.babylonjs.com/how_to/multi_materials
  7329. */
  7330. export class MultiMaterial extends Material {
  7331. private _subMaterials;
  7332. /**
  7333. * Gets or Sets the list of Materials used within the multi material.
  7334. * They need to be ordered according to the submeshes order in the associated mesh
  7335. */
  7336. subMaterials: Nullable<Material>[];
  7337. /**
  7338. * Function used to align with Node.getChildren()
  7339. * @returns the list of Materials used within the multi material
  7340. */
  7341. getChildren(): Nullable<Material>[];
  7342. /**
  7343. * Instantiates a new Multi Material
  7344. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7345. * separate meshes. This can be use to improve performances.
  7346. * @see http://doc.babylonjs.com/how_to/multi_materials
  7347. * @param name Define the name in the scene
  7348. * @param scene Define the scene the material belongs to
  7349. */
  7350. constructor(name: string, scene: Scene);
  7351. private _hookArray;
  7352. /**
  7353. * Get one of the submaterial by its index in the submaterials array
  7354. * @param index The index to look the sub material at
  7355. * @returns The Material if the index has been defined
  7356. */
  7357. getSubMaterial(index: number): Nullable<Material>;
  7358. /**
  7359. * Get the list of active textures for the whole sub materials list.
  7360. * @returns All the textures that will be used during the rendering
  7361. */
  7362. getActiveTextures(): BaseTexture[];
  7363. /**
  7364. * Gets the current class name of the material e.g. "MultiMaterial"
  7365. * Mainly use in serialization.
  7366. * @returns the class name
  7367. */
  7368. getClassName(): string;
  7369. /**
  7370. * Checks if the material is ready to render the requested sub mesh
  7371. * @param mesh Define the mesh the submesh belongs to
  7372. * @param subMesh Define the sub mesh to look readyness for
  7373. * @param useInstances Define whether or not the material is used with instances
  7374. * @returns true if ready, otherwise false
  7375. */
  7376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7377. /**
  7378. * Clones the current material and its related sub materials
  7379. * @param name Define the name of the newly cloned material
  7380. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7381. * @returns the cloned material
  7382. */
  7383. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7384. /**
  7385. * Serializes the materials into a JSON representation.
  7386. * @returns the JSON representation
  7387. */
  7388. serialize(): any;
  7389. /**
  7390. * Dispose the material and release its associated resources
  7391. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7392. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7393. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7394. */
  7395. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7396. /**
  7397. * Creates a MultiMaterial from parsed MultiMaterial data.
  7398. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7399. * @param scene defines the hosting scene
  7400. * @returns a new MultiMaterial
  7401. */
  7402. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7403. }
  7404. }
  7405. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7406. /**
  7407. * Class used to represent data loading progression
  7408. */
  7409. export class SceneLoaderFlags {
  7410. private static _ForceFullSceneLoadingForIncremental;
  7411. private static _ShowLoadingScreen;
  7412. private static _CleanBoneMatrixWeights;
  7413. private static _loggingLevel;
  7414. /**
  7415. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7416. */
  7417. static ForceFullSceneLoadingForIncremental: boolean;
  7418. /**
  7419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7420. */
  7421. static ShowLoadingScreen: boolean;
  7422. /**
  7423. * Defines the current logging level (while loading the scene)
  7424. * @ignorenaming
  7425. */
  7426. static loggingLevel: number;
  7427. /**
  7428. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7429. */
  7430. static CleanBoneMatrixWeights: boolean;
  7431. }
  7432. }
  7433. declare module "babylonjs/Meshes/transformNode" {
  7434. import { DeepImmutable } from "babylonjs/types";
  7435. import { Observable } from "babylonjs/Misc/observable";
  7436. import { Nullable } from "babylonjs/types";
  7437. import { Camera } from "babylonjs/Cameras/camera";
  7438. import { Scene } from "babylonjs/scene";
  7439. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7440. import { Node } from "babylonjs/node";
  7441. import { Bone } from "babylonjs/Bones/bone";
  7442. /**
  7443. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  7444. * @see https://doc.babylonjs.com/how_to/transformnode
  7445. */
  7446. export class TransformNode extends Node {
  7447. /**
  7448. * Object will not rotate to face the camera
  7449. */
  7450. static BILLBOARDMODE_NONE: number;
  7451. /**
  7452. * Object will rotate to face the camera but only on the x axis
  7453. */
  7454. static BILLBOARDMODE_X: number;
  7455. /**
  7456. * Object will rotate to face the camera but only on the y axis
  7457. */
  7458. static BILLBOARDMODE_Y: number;
  7459. /**
  7460. * Object will rotate to face the camera but only on the z axis
  7461. */
  7462. static BILLBOARDMODE_Z: number;
  7463. /**
  7464. * Object will rotate to face the camera
  7465. */
  7466. static BILLBOARDMODE_ALL: number;
  7467. private _forward;
  7468. private _forwardInverted;
  7469. private _up;
  7470. private _right;
  7471. private _rightInverted;
  7472. private _position;
  7473. private _rotation;
  7474. private _rotationQuaternion;
  7475. protected _scaling: Vector3;
  7476. protected _isDirty: boolean;
  7477. private _transformToBoneReferal;
  7478. /**
  7479. * Set the billboard mode. Default is 0.
  7480. *
  7481. * | Value | Type | Description |
  7482. * | --- | --- | --- |
  7483. * | 0 | BILLBOARDMODE_NONE | |
  7484. * | 1 | BILLBOARDMODE_X | |
  7485. * | 2 | BILLBOARDMODE_Y | |
  7486. * | 4 | BILLBOARDMODE_Z | |
  7487. * | 7 | BILLBOARDMODE_ALL | |
  7488. *
  7489. */
  7490. billboardMode: number;
  7491. /**
  7492. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  7493. */
  7494. scalingDeterminant: number;
  7495. /**
  7496. * Sets the distance of the object to max, often used by skybox
  7497. */
  7498. infiniteDistance: boolean;
  7499. /**
  7500. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7501. * By default the system will update normals to compensate
  7502. */
  7503. ignoreNonUniformScaling: boolean;
  7504. /** @hidden */
  7505. _poseMatrix: Matrix;
  7506. /** @hidden */
  7507. _localMatrix: Matrix;
  7508. private _absolutePosition;
  7509. private _pivotMatrix;
  7510. private _pivotMatrixInverse;
  7511. protected _postMultiplyPivotMatrix: boolean;
  7512. protected _isWorldMatrixFrozen: boolean;
  7513. /** @hidden */
  7514. _indexInSceneTransformNodesArray: number;
  7515. /**
  7516. * An event triggered after the world matrix is updated
  7517. */
  7518. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7519. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7520. /**
  7521. * Gets a string identifying the name of the class
  7522. * @returns "TransformNode" string
  7523. */
  7524. getClassName(): string;
  7525. /**
  7526. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7527. */
  7528. position: Vector3;
  7529. /**
  7530. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7531. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7532. */
  7533. rotation: Vector3;
  7534. /**
  7535. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7536. */
  7537. scaling: Vector3;
  7538. /**
  7539. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7540. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7541. */
  7542. rotationQuaternion: Nullable<Quaternion>;
  7543. /**
  7544. * The forward direction of that transform in world space.
  7545. */
  7546. readonly forward: Vector3;
  7547. /**
  7548. * The up direction of that transform in world space.
  7549. */
  7550. readonly up: Vector3;
  7551. /**
  7552. * The right direction of that transform in world space.
  7553. */
  7554. readonly right: Vector3;
  7555. /**
  7556. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7557. * @param matrix the matrix to copy the pose from
  7558. * @returns this TransformNode.
  7559. */
  7560. updatePoseMatrix(matrix: Matrix): TransformNode;
  7561. /**
  7562. * Returns the mesh Pose matrix.
  7563. * @returns the pose matrix
  7564. */
  7565. getPoseMatrix(): Matrix;
  7566. /** @hidden */
  7567. _isSynchronized(): boolean;
  7568. /** @hidden */
  7569. _initCache(): void;
  7570. /**
  7571. * Flag the transform node as dirty (Forcing it to update everything)
  7572. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7573. * @returns this transform node
  7574. */
  7575. markAsDirty(property: string): TransformNode;
  7576. /**
  7577. * Returns the current mesh absolute position.
  7578. * Returns a Vector3.
  7579. */
  7580. readonly absolutePosition: Vector3;
  7581. /**
  7582. * Sets a new matrix to apply before all other transformation
  7583. * @param matrix defines the transform matrix
  7584. * @returns the current TransformNode
  7585. */
  7586. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7587. /**
  7588. * Sets a new pivot matrix to the current node
  7589. * @param matrix defines the new pivot matrix to use
  7590. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  7591. * @returns the current TransformNode
  7592. */
  7593. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7594. /**
  7595. * Returns the mesh pivot matrix.
  7596. * Default : Identity.
  7597. * @returns the matrix
  7598. */
  7599. getPivotMatrix(): Matrix;
  7600. /**
  7601. * Prevents the World matrix to be computed any longer.
  7602. * @returns the TransformNode.
  7603. */
  7604. freezeWorldMatrix(): TransformNode;
  7605. /**
  7606. * Allows back the World matrix computation.
  7607. * @returns the TransformNode.
  7608. */
  7609. unfreezeWorldMatrix(): this;
  7610. /**
  7611. * True if the World matrix has been frozen.
  7612. */
  7613. readonly isWorldMatrixFrozen: boolean;
  7614. /**
  7615. * Retuns the mesh absolute position in the World.
  7616. * @returns a Vector3.
  7617. */
  7618. getAbsolutePosition(): Vector3;
  7619. /**
  7620. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7621. * @param absolutePosition the absolute position to set
  7622. * @returns the TransformNode.
  7623. */
  7624. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7625. /**
  7626. * Sets the mesh position in its local space.
  7627. * @param vector3 the position to set in localspace
  7628. * @returns the TransformNode.
  7629. */
  7630. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7631. /**
  7632. * Returns the mesh position in the local space from the current World matrix values.
  7633. * @returns a new Vector3.
  7634. */
  7635. getPositionExpressedInLocalSpace(): Vector3;
  7636. /**
  7637. * Translates the mesh along the passed Vector3 in its local space.
  7638. * @param vector3 the distance to translate in localspace
  7639. * @returns the TransformNode.
  7640. */
  7641. locallyTranslate(vector3: Vector3): TransformNode;
  7642. private static _lookAtVectorCache;
  7643. /**
  7644. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7645. * @param targetPoint the position (must be in same space as current mesh) to look at
  7646. * @param yawCor optional yaw (y-axis) correction in radians
  7647. * @param pitchCor optional pitch (x-axis) correction in radians
  7648. * @param rollCor optional roll (z-axis) correction in radians
  7649. * @param space the choosen space of the target
  7650. * @returns the TransformNode.
  7651. */
  7652. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7653. /**
  7654. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7655. * This Vector3 is expressed in the World space.
  7656. * @param localAxis axis to rotate
  7657. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7658. */
  7659. getDirection(localAxis: Vector3): Vector3;
  7660. /**
  7661. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7662. * localAxis is expressed in the mesh local space.
  7663. * result is computed in the Wordl space from the mesh World matrix.
  7664. * @param localAxis axis to rotate
  7665. * @param result the resulting transformnode
  7666. * @returns this TransformNode.
  7667. */
  7668. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7669. /**
  7670. * Sets this transform node rotation to the given local axis.
  7671. * @param localAxis the axis in local space
  7672. * @param yawCor optional yaw (y-axis) correction in radians
  7673. * @param pitchCor optional pitch (x-axis) correction in radians
  7674. * @param rollCor optional roll (z-axis) correction in radians
  7675. * @returns this TransformNode
  7676. */
  7677. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7678. /**
  7679. * Sets a new pivot point to the current node
  7680. * @param point defines the new pivot point to use
  7681. * @param space defines if the point is in world or local space (local by default)
  7682. * @returns the current TransformNode
  7683. */
  7684. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7685. /**
  7686. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7687. * @returns the pivot point
  7688. */
  7689. getPivotPoint(): Vector3;
  7690. /**
  7691. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7692. * @param result the vector3 to store the result
  7693. * @returns this TransformNode.
  7694. */
  7695. getPivotPointToRef(result: Vector3): TransformNode;
  7696. /**
  7697. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7698. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7699. */
  7700. getAbsolutePivotPoint(): Vector3;
  7701. /**
  7702. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7703. * @param result vector3 to store the result
  7704. * @returns this TransformNode.
  7705. */
  7706. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7707. /**
  7708. * Defines the passed node as the parent of the current node.
  7709. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7710. * @param node the node ot set as the parent
  7711. * @returns this TransformNode.
  7712. */
  7713. setParent(node: Nullable<Node>): TransformNode;
  7714. private _nonUniformScaling;
  7715. /**
  7716. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7717. */
  7718. readonly nonUniformScaling: boolean;
  7719. /** @hidden */
  7720. _updateNonUniformScalingState(value: boolean): boolean;
  7721. /**
  7722. * Attach the current TransformNode to another TransformNode associated with a bone
  7723. * @param bone Bone affecting the TransformNode
  7724. * @param affectedTransformNode TransformNode associated with the bone
  7725. * @returns this object
  7726. */
  7727. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7728. /**
  7729. * Detach the transform node if its associated with a bone
  7730. * @returns this object
  7731. */
  7732. detachFromBone(): TransformNode;
  7733. private static _rotationAxisCache;
  7734. /**
  7735. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7736. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7737. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7738. * The passed axis is also normalized.
  7739. * @param axis the axis to rotate around
  7740. * @param amount the amount to rotate in radians
  7741. * @param space Space to rotate in (Default: local)
  7742. * @returns the TransformNode.
  7743. */
  7744. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7745. /**
  7746. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7747. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7748. * The passed axis is also normalized. .
  7749. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7750. * @param point the point to rotate around
  7751. * @param axis the axis to rotate around
  7752. * @param amount the amount to rotate in radians
  7753. * @returns the TransformNode
  7754. */
  7755. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7756. /**
  7757. * Translates the mesh along the axis vector for the passed distance in the given space.
  7758. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7759. * @param axis the axis to translate in
  7760. * @param distance the distance to translate
  7761. * @param space Space to rotate in (Default: local)
  7762. * @returns the TransformNode.
  7763. */
  7764. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7765. /**
  7766. * Adds a rotation step to the mesh current rotation.
  7767. * x, y, z are Euler angles expressed in radians.
  7768. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7769. * This means this rotation is made in the mesh local space only.
  7770. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7771. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7772. * ```javascript
  7773. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7774. * ```
  7775. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7776. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  7777. * @param x Rotation to add
  7778. * @param y Rotation to add
  7779. * @param z Rotation to add
  7780. * @returns the TransformNode.
  7781. */
  7782. addRotation(x: number, y: number, z: number): TransformNode;
  7783. /**
  7784. * Computes the world matrix of the node
  7785. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7786. * @returns the world matrix
  7787. */
  7788. computeWorldMatrix(force?: boolean): Matrix;
  7789. protected _afterComputeWorldMatrix(): void;
  7790. /**
  7791. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7792. * @param func callback function to add
  7793. *
  7794. * @returns the TransformNode.
  7795. */
  7796. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7797. /**
  7798. * Removes a registered callback function.
  7799. * @param func callback function to remove
  7800. * @returns the TransformNode.
  7801. */
  7802. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7803. /**
  7804. * Gets the position of the current mesh in camera space
  7805. * @param camera defines the camera to use
  7806. * @returns a position
  7807. */
  7808. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7809. /**
  7810. * Returns the distance from the mesh to the active camera
  7811. * @param camera defines the camera to use
  7812. * @returns the distance
  7813. */
  7814. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7815. /**
  7816. * Clone the current transform node
  7817. * @param name Name of the new clone
  7818. * @param newParent New parent for the clone
  7819. * @param doNotCloneChildren Do not clone children hierarchy
  7820. * @returns the new transform node
  7821. */
  7822. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7823. /**
  7824. * Serializes the objects information.
  7825. * @param currentSerializationObject defines the object to serialize in
  7826. * @returns the serialized object
  7827. */
  7828. serialize(currentSerializationObject?: any): any;
  7829. /**
  7830. * Returns a new TransformNode object parsed from the source provided.
  7831. * @param parsedTransformNode is the source.
  7832. * @param scene the scne the object belongs to
  7833. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7834. * @returns a new TransformNode object parsed from the source provided.
  7835. */
  7836. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7837. /**
  7838. * Get all child-transformNodes of this node
  7839. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  7840. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  7841. * @returns an array of TransformNode
  7842. */
  7843. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7844. /**
  7845. * Releases resources associated with this transform node.
  7846. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7847. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7848. */
  7849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7850. }
  7851. }
  7852. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7853. /**
  7854. * Class used to override all child animations of a given target
  7855. */
  7856. export class AnimationPropertiesOverride {
  7857. /**
  7858. * Gets or sets a value indicating if animation blending must be used
  7859. */
  7860. enableBlending: boolean;
  7861. /**
  7862. * Gets or sets the blending speed to use when enableBlending is true
  7863. */
  7864. blendingSpeed: number;
  7865. /**
  7866. * Gets or sets the default loop mode to use
  7867. */
  7868. loopMode: number;
  7869. }
  7870. }
  7871. declare module "babylonjs/Bones/bone" {
  7872. import { Skeleton } from "babylonjs/Bones/skeleton";
  7873. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7874. import { Nullable } from "babylonjs/types";
  7875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7876. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7877. import { Node } from "babylonjs/node";
  7878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7879. /**
  7880. * Class used to store bone information
  7881. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7882. */
  7883. export class Bone extends Node {
  7884. /**
  7885. * defines the bone name
  7886. */
  7887. name: string;
  7888. private static _tmpVecs;
  7889. private static _tmpQuat;
  7890. private static _tmpMats;
  7891. /**
  7892. * Gets the list of child bones
  7893. */
  7894. children: Bone[];
  7895. /** Gets the animations associated with this bone */
  7896. animations: import("babylonjs/Animations/animation").Animation[];
  7897. /**
  7898. * Gets or sets bone length
  7899. */
  7900. length: number;
  7901. /**
  7902. * @hidden Internal only
  7903. * Set this value to map this bone to a different index in the transform matrices
  7904. * Set this value to -1 to exclude the bone from the transform matrices
  7905. */
  7906. _index: Nullable<number>;
  7907. private _skeleton;
  7908. private _localMatrix;
  7909. private _restPose;
  7910. private _baseMatrix;
  7911. private _absoluteTransform;
  7912. private _invertedAbsoluteTransform;
  7913. private _parent;
  7914. private _scalingDeterminant;
  7915. private _worldTransform;
  7916. private _localScaling;
  7917. private _localRotation;
  7918. private _localPosition;
  7919. private _needToDecompose;
  7920. private _needToCompose;
  7921. /** @hidden */
  7922. _linkedTransformNode: Nullable<TransformNode>;
  7923. /** @hidden */
  7924. /** @hidden */
  7925. _matrix: Matrix;
  7926. /**
  7927. * Create a new bone
  7928. * @param name defines the bone name
  7929. * @param skeleton defines the parent skeleton
  7930. * @param parentBone defines the parent (can be null if the bone is the root)
  7931. * @param localMatrix defines the local matrix
  7932. * @param restPose defines the rest pose matrix
  7933. * @param baseMatrix defines the base matrix
  7934. * @param index defines index of the bone in the hiearchy
  7935. */
  7936. constructor(
  7937. /**
  7938. * defines the bone name
  7939. */
  7940. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7941. /**
  7942. * Gets the current object class name.
  7943. * @return the class name
  7944. */
  7945. getClassName(): string;
  7946. /**
  7947. * Gets the parent skeleton
  7948. * @returns a skeleton
  7949. */
  7950. getSkeleton(): Skeleton;
  7951. /**
  7952. * Gets parent bone
  7953. * @returns a bone or null if the bone is the root of the bone hierarchy
  7954. */
  7955. getParent(): Nullable<Bone>;
  7956. /**
  7957. * Returns an array containing the root bones
  7958. * @returns an array containing the root bones
  7959. */
  7960. getChildren(): Array<Bone>;
  7961. /**
  7962. * Sets the parent bone
  7963. * @param parent defines the parent (can be null if the bone is the root)
  7964. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7965. */
  7966. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7967. /**
  7968. * Gets the local matrix
  7969. * @returns a matrix
  7970. */
  7971. getLocalMatrix(): Matrix;
  7972. /**
  7973. * Gets the base matrix (initial matrix which remains unchanged)
  7974. * @returns a matrix
  7975. */
  7976. getBaseMatrix(): Matrix;
  7977. /**
  7978. * Gets the rest pose matrix
  7979. * @returns a matrix
  7980. */
  7981. getRestPose(): Matrix;
  7982. /**
  7983. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7984. */
  7985. getWorldMatrix(): Matrix;
  7986. /**
  7987. * Sets the local matrix to rest pose matrix
  7988. */
  7989. returnToRest(): void;
  7990. /**
  7991. * Gets the inverse of the absolute transform matrix.
  7992. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7993. * @returns a matrix
  7994. */
  7995. getInvertedAbsoluteTransform(): Matrix;
  7996. /**
  7997. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7998. * @returns a matrix
  7999. */
  8000. getAbsoluteTransform(): Matrix;
  8001. /**
  8002. * Links with the given transform node.
  8003. * The local matrix of this bone is copied from the transform node every frame.
  8004. * @param transformNode defines the transform node to link to
  8005. */
  8006. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8007. /** Gets or sets current position (in local space) */
  8008. position: Vector3;
  8009. /** Gets or sets current rotation (in local space) */
  8010. rotation: Vector3;
  8011. /** Gets or sets current rotation quaternion (in local space) */
  8012. rotationQuaternion: Quaternion;
  8013. /** Gets or sets current scaling (in local space) */
  8014. scaling: Vector3;
  8015. /**
  8016. * Gets the animation properties override
  8017. */
  8018. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8019. private _decompose;
  8020. private _compose;
  8021. /**
  8022. * Update the base and local matrices
  8023. * @param matrix defines the new base or local matrix
  8024. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8025. * @param updateLocalMatrix defines if the local matrix should be updated
  8026. */
  8027. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8028. /** @hidden */
  8029. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8030. /**
  8031. * Flag the bone as dirty (Forcing it to update everything)
  8032. */
  8033. markAsDirty(): void;
  8034. private _markAsDirtyAndCompose;
  8035. private _markAsDirtyAndDecompose;
  8036. /**
  8037. * Translate the bone in local or world space
  8038. * @param vec The amount to translate the bone
  8039. * @param space The space that the translation is in
  8040. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8041. */
  8042. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8043. /**
  8044. * Set the postion of the bone in local or world space
  8045. * @param position The position to set the bone
  8046. * @param space The space that the position is in
  8047. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8048. */
  8049. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8050. /**
  8051. * Set the absolute position of the bone (world space)
  8052. * @param position The position to set the bone
  8053. * @param mesh The mesh that this bone is attached to
  8054. */
  8055. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8056. /**
  8057. * Scale the bone on the x, y and z axes (in local space)
  8058. * @param x The amount to scale the bone on the x axis
  8059. * @param y The amount to scale the bone on the y axis
  8060. * @param z The amount to scale the bone on the z axis
  8061. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8062. */
  8063. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8064. /**
  8065. * Set the bone scaling in local space
  8066. * @param scale defines the scaling vector
  8067. */
  8068. setScale(scale: Vector3): void;
  8069. /**
  8070. * Gets the current scaling in local space
  8071. * @returns the current scaling vector
  8072. */
  8073. getScale(): Vector3;
  8074. /**
  8075. * Gets the current scaling in local space and stores it in a target vector
  8076. * @param result defines the target vector
  8077. */
  8078. getScaleToRef(result: Vector3): void;
  8079. /**
  8080. * Set the yaw, pitch, and roll of the bone in local or world space
  8081. * @param yaw The rotation of the bone on the y axis
  8082. * @param pitch The rotation of the bone on the x axis
  8083. * @param roll The rotation of the bone on the z axis
  8084. * @param space The space that the axes of rotation are in
  8085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8086. */
  8087. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8088. /**
  8089. * Add a rotation to the bone on an axis in local or world space
  8090. * @param axis The axis to rotate the bone on
  8091. * @param amount The amount to rotate the bone
  8092. * @param space The space that the axis is in
  8093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8094. */
  8095. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8096. /**
  8097. * Set the rotation of the bone to a particular axis angle in local or world space
  8098. * @param axis The axis to rotate the bone on
  8099. * @param angle The angle that the bone should be rotated to
  8100. * @param space The space that the axis is in
  8101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8102. */
  8103. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8104. /**
  8105. * Set the euler rotation of the bone in local of world space
  8106. * @param rotation The euler rotation that the bone should be set to
  8107. * @param space The space that the rotation is in
  8108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8109. */
  8110. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8111. /**
  8112. * Set the quaternion rotation of the bone in local of world space
  8113. * @param quat The quaternion rotation that the bone should be set to
  8114. * @param space The space that the rotation is in
  8115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8116. */
  8117. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8118. /**
  8119. * Set the rotation matrix of the bone in local of world space
  8120. * @param rotMat The rotation matrix that the bone should be set to
  8121. * @param space The space that the rotation is in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. */
  8124. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8125. private _rotateWithMatrix;
  8126. private _getNegativeRotationToRef;
  8127. /**
  8128. * Get the position of the bone in local or world space
  8129. * @param space The space that the returned position is in
  8130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8131. * @returns The position of the bone
  8132. */
  8133. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8134. /**
  8135. * Copy the position of the bone to a vector3 in local or world space
  8136. * @param space The space that the returned position is in
  8137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8138. * @param result The vector3 to copy the position to
  8139. */
  8140. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8141. /**
  8142. * Get the absolute position of the bone (world space)
  8143. * @param mesh The mesh that this bone is attached to
  8144. * @returns The absolute position of the bone
  8145. */
  8146. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8147. /**
  8148. * Copy the absolute position of the bone (world space) to the result param
  8149. * @param mesh The mesh that this bone is attached to
  8150. * @param result The vector3 to copy the absolute position to
  8151. */
  8152. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8153. /**
  8154. * Compute the absolute transforms of this bone and its children
  8155. */
  8156. computeAbsoluteTransforms(): void;
  8157. /**
  8158. * Get the world direction from an axis that is in the local space of the bone
  8159. * @param localAxis The local direction that is used to compute the world direction
  8160. * @param mesh The mesh that this bone is attached to
  8161. * @returns The world direction
  8162. */
  8163. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8164. /**
  8165. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8166. * @param localAxis The local direction that is used to compute the world direction
  8167. * @param mesh The mesh that this bone is attached to
  8168. * @param result The vector3 that the world direction will be copied to
  8169. */
  8170. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8171. /**
  8172. * Get the euler rotation of the bone in local or world space
  8173. * @param space The space that the rotation should be in
  8174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8175. * @returns The euler rotation
  8176. */
  8177. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8178. /**
  8179. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8180. * @param space The space that the rotation should be in
  8181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8182. * @param result The vector3 that the rotation should be copied to
  8183. */
  8184. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8185. /**
  8186. * Get the quaternion rotation of the bone in either local or world space
  8187. * @param space The space that the rotation should be in
  8188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8189. * @returns The quaternion rotation
  8190. */
  8191. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8192. /**
  8193. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8194. * @param space The space that the rotation should be in
  8195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8196. * @param result The quaternion that the rotation should be copied to
  8197. */
  8198. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8199. /**
  8200. * Get the rotation matrix of the bone in local or world space
  8201. * @param space The space that the rotation should be in
  8202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8203. * @returns The rotation matrix
  8204. */
  8205. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8206. /**
  8207. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8208. * @param space The space that the rotation should be in
  8209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8210. * @param result The quaternion that the rotation should be copied to
  8211. */
  8212. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8213. /**
  8214. * Get the world position of a point that is in the local space of the bone
  8215. * @param position The local position
  8216. * @param mesh The mesh that this bone is attached to
  8217. * @returns The world position
  8218. */
  8219. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8220. /**
  8221. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8222. * @param position The local position
  8223. * @param mesh The mesh that this bone is attached to
  8224. * @param result The vector3 that the world position should be copied to
  8225. */
  8226. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8227. /**
  8228. * Get the local position of a point that is in world space
  8229. * @param position The world position
  8230. * @param mesh The mesh that this bone is attached to
  8231. * @returns The local position
  8232. */
  8233. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8234. /**
  8235. * Get the local position of a point that is in world space and copy it to the result param
  8236. * @param position The world position
  8237. * @param mesh The mesh that this bone is attached to
  8238. * @param result The vector3 that the local position should be copied to
  8239. */
  8240. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8241. }
  8242. }
  8243. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8244. import { Nullable } from "babylonjs/types";
  8245. import { Scene } from "babylonjs/scene";
  8246. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8248. /**
  8249. * Class for creating a cube texture
  8250. */
  8251. export class CubeTexture extends BaseTexture {
  8252. private _delayedOnLoad;
  8253. /**
  8254. * The url of the texture
  8255. */
  8256. url: string;
  8257. /**
  8258. * Gets or sets the center of the bounding box associated with the cube texture.
  8259. * It must define where the camera used to render the texture was set
  8260. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8261. */
  8262. boundingBoxPosition: Vector3;
  8263. private _boundingBoxSize;
  8264. /**
  8265. * Gets or sets the size of the bounding box associated with the cube texture
  8266. * When defined, the cubemap will switch to local mode
  8267. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8268. * @example https://www.babylonjs-playground.com/#RNASML
  8269. */
  8270. /**
  8271. * Returns the bounding box size
  8272. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8273. */
  8274. boundingBoxSize: Vector3;
  8275. protected _rotationY: number;
  8276. /**
  8277. * Sets texture matrix rotation angle around Y axis in radians.
  8278. */
  8279. /**
  8280. * Gets texture matrix rotation angle around Y axis radians.
  8281. */
  8282. rotationY: number;
  8283. /**
  8284. * Are mip maps generated for this texture or not.
  8285. */
  8286. readonly noMipmap: boolean;
  8287. private _noMipmap;
  8288. private _files;
  8289. private _extensions;
  8290. private _textureMatrix;
  8291. private _format;
  8292. private _createPolynomials;
  8293. /** @hidden */
  8294. _prefiltered: boolean;
  8295. /**
  8296. * Creates a cube texture from an array of image urls
  8297. * @param files defines an array of image urls
  8298. * @param scene defines the hosting scene
  8299. * @param noMipmap specifies if mip maps are not used
  8300. * @returns a cube texture
  8301. */
  8302. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8303. /**
  8304. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8305. * @param url defines the url of the prefiltered texture
  8306. * @param scene defines the scene the texture is attached to
  8307. * @param forcedExtension defines the extension of the file if different from the url
  8308. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8309. * @return the prefiltered texture
  8310. */
  8311. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8312. /**
  8313. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8314. * as prefiltered data.
  8315. * @param rootUrl defines the url of the texture or the root name of the six images
  8316. * @param scene defines the scene the texture is attached to
  8317. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8318. * @param noMipmap defines if mipmaps should be created or not
  8319. * @param files defines the six files to load for the different faces
  8320. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8321. * @param onError defines a callback triggered in case of error during load
  8322. * @param format defines the internal format to use for the texture once loaded
  8323. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8324. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8325. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8326. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8327. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8328. * @return the cube texture
  8329. */
  8330. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  8331. /**
  8332. * Get the current class name of the texture useful for serialization or dynamic coding.
  8333. * @returns "CubeTexture"
  8334. */
  8335. getClassName(): string;
  8336. /**
  8337. * Update the url (and optional buffer) of this texture if url was null during construction.
  8338. * @param url the url of the texture
  8339. * @param forcedExtension defines the extension to use
  8340. * @param onLoad callback called when the texture is loaded (defaults to null)
  8341. */
  8342. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8343. /**
  8344. * Delays loading of the cube texture
  8345. * @param forcedExtension defines the extension to use
  8346. */
  8347. delayLoad(forcedExtension?: string): void;
  8348. /**
  8349. * Returns the reflection texture matrix
  8350. * @returns the reflection texture matrix
  8351. */
  8352. getReflectionTextureMatrix(): Matrix;
  8353. /**
  8354. * Sets the reflection texture matrix
  8355. * @param value Reflection texture matrix
  8356. */
  8357. setReflectionTextureMatrix(value: Matrix): void;
  8358. /**
  8359. * Parses text to create a cube texture
  8360. * @param parsedTexture define the serialized text to read from
  8361. * @param scene defines the hosting scene
  8362. * @param rootUrl defines the root url of the cube texture
  8363. * @returns a cube texture
  8364. */
  8365. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8366. /**
  8367. * Makes a clone, or deep copy, of the cube texture
  8368. * @returns a new cube texture
  8369. */
  8370. clone(): CubeTexture;
  8371. }
  8372. }
  8373. declare module "babylonjs/Shaders/postprocess.vertex" {
  8374. /** @hidden */
  8375. export var postprocessVertexShader: {
  8376. name: string;
  8377. shader: string;
  8378. };
  8379. }
  8380. declare module "babylonjs/Cameras/targetCamera" {
  8381. import { Nullable } from "babylonjs/types";
  8382. import { Camera } from "babylonjs/Cameras/camera";
  8383. import { Scene } from "babylonjs/scene";
  8384. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8385. /**
  8386. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8387. * This is the base of the follow, arc rotate cameras and Free camera
  8388. * @see http://doc.babylonjs.com/features/cameras
  8389. */
  8390. export class TargetCamera extends Camera {
  8391. private static _RigCamTransformMatrix;
  8392. private static _TargetTransformMatrix;
  8393. private static _TargetFocalPoint;
  8394. /**
  8395. * Define the current direction the camera is moving to
  8396. */
  8397. cameraDirection: Vector3;
  8398. /**
  8399. * Define the current rotation the camera is rotating to
  8400. */
  8401. cameraRotation: Vector2;
  8402. /**
  8403. * When set, the up vector of the camera will be updated by the rotation of the camera
  8404. */
  8405. updateUpVectorFromRotation: boolean;
  8406. private _tmpQuaternion;
  8407. /**
  8408. * Define the current rotation of the camera
  8409. */
  8410. rotation: Vector3;
  8411. /**
  8412. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8413. */
  8414. rotationQuaternion: Quaternion;
  8415. /**
  8416. * Define the current speed of the camera
  8417. */
  8418. speed: number;
  8419. /**
  8420. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8421. * around all axis.
  8422. */
  8423. noRotationConstraint: boolean;
  8424. /**
  8425. * Define the current target of the camera as an object or a position.
  8426. */
  8427. lockedTarget: any;
  8428. /** @hidden */
  8429. _currentTarget: Vector3;
  8430. /** @hidden */
  8431. _initialFocalDistance: number;
  8432. /** @hidden */
  8433. _viewMatrix: Matrix;
  8434. /** @hidden */
  8435. _camMatrix: Matrix;
  8436. /** @hidden */
  8437. _cameraTransformMatrix: Matrix;
  8438. /** @hidden */
  8439. _cameraRotationMatrix: Matrix;
  8440. /** @hidden */
  8441. _referencePoint: Vector3;
  8442. /** @hidden */
  8443. _transformedReferencePoint: Vector3;
  8444. protected _globalCurrentTarget: Vector3;
  8445. protected _globalCurrentUpVector: Vector3;
  8446. /** @hidden */
  8447. _reset: () => void;
  8448. private _defaultUp;
  8449. /**
  8450. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8451. * This is the base of the follow, arc rotate cameras and Free camera
  8452. * @see http://doc.babylonjs.com/features/cameras
  8453. * @param name Defines the name of the camera in the scene
  8454. * @param position Defines the start position of the camera in the scene
  8455. * @param scene Defines the scene the camera belongs to
  8456. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8457. */
  8458. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8459. /**
  8460. * Gets the position in front of the camera at a given distance.
  8461. * @param distance The distance from the camera we want the position to be
  8462. * @returns the position
  8463. */
  8464. getFrontPosition(distance: number): Vector3;
  8465. /** @hidden */
  8466. _getLockedTargetPosition(): Nullable<Vector3>;
  8467. private _storedPosition;
  8468. private _storedRotation;
  8469. private _storedRotationQuaternion;
  8470. /**
  8471. * Store current camera state of the camera (fov, position, rotation, etc..)
  8472. * @returns the camera
  8473. */
  8474. storeState(): Camera;
  8475. /**
  8476. * Restored camera state. You must call storeState() first
  8477. * @returns whether it was successful or not
  8478. * @hidden
  8479. */
  8480. _restoreStateValues(): boolean;
  8481. /** @hidden */
  8482. _initCache(): void;
  8483. /** @hidden */
  8484. _updateCache(ignoreParentClass?: boolean): void;
  8485. /** @hidden */
  8486. _isSynchronizedViewMatrix(): boolean;
  8487. /** @hidden */
  8488. _computeLocalCameraSpeed(): number;
  8489. /**
  8490. * Defines the target the camera should look at.
  8491. * This will automatically adapt alpha beta and radius to fit within the new target.
  8492. * @param target Defines the new target as a Vector or a mesh
  8493. */
  8494. setTarget(target: Vector3): void;
  8495. /**
  8496. * Return the current target position of the camera. This value is expressed in local space.
  8497. * @returns the target position
  8498. */
  8499. getTarget(): Vector3;
  8500. /** @hidden */
  8501. _decideIfNeedsToMove(): boolean;
  8502. /** @hidden */
  8503. _updatePosition(): void;
  8504. /** @hidden */
  8505. _checkInputs(): void;
  8506. protected _updateCameraRotationMatrix(): void;
  8507. /**
  8508. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8509. * @returns the current camera
  8510. */
  8511. private _rotateUpVectorWithCameraRotationMatrix;
  8512. private _cachedRotationZ;
  8513. private _cachedQuaternionRotationZ;
  8514. /** @hidden */
  8515. _getViewMatrix(): Matrix;
  8516. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8517. /**
  8518. * @hidden
  8519. */
  8520. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8521. /**
  8522. * @hidden
  8523. */
  8524. _updateRigCameras(): void;
  8525. private _getRigCamPositionAndTarget;
  8526. /**
  8527. * Gets the current object class name.
  8528. * @return the class name
  8529. */
  8530. getClassName(): string;
  8531. }
  8532. }
  8533. declare module "babylonjs/Cameras/cameraInputsManager" {
  8534. import { Nullable } from "babylonjs/types";
  8535. import { Camera } from "babylonjs/Cameras/camera";
  8536. /**
  8537. * @ignore
  8538. * This is a list of all the different input types that are available in the application.
  8539. * Fo instance: ArcRotateCameraGamepadInput...
  8540. */
  8541. export var CameraInputTypes: {};
  8542. /**
  8543. * This is the contract to implement in order to create a new input class.
  8544. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8545. */
  8546. export interface ICameraInput<TCamera extends Camera> {
  8547. /**
  8548. * Defines the camera the input is attached to.
  8549. */
  8550. camera: Nullable<TCamera>;
  8551. /**
  8552. * Gets the class name of the current intput.
  8553. * @returns the class name
  8554. */
  8555. getClassName(): string;
  8556. /**
  8557. * Get the friendly name associated with the input class.
  8558. * @returns the input friendly name
  8559. */
  8560. getSimpleName(): string;
  8561. /**
  8562. * Attach the input controls to a specific dom element to get the input from.
  8563. * @param element Defines the element the controls should be listened from
  8564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8565. */
  8566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8567. /**
  8568. * Detach the current controls from the specified dom element.
  8569. * @param element Defines the element to stop listening the inputs from
  8570. */
  8571. detachControl(element: Nullable<HTMLElement>): void;
  8572. /**
  8573. * Update the current camera state depending on the inputs that have been used this frame.
  8574. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8575. */
  8576. checkInputs?: () => void;
  8577. }
  8578. /**
  8579. * Represents a map of input types to input instance or input index to input instance.
  8580. */
  8581. export interface CameraInputsMap<TCamera extends Camera> {
  8582. /**
  8583. * Accessor to the input by input type.
  8584. */
  8585. [name: string]: ICameraInput<TCamera>;
  8586. /**
  8587. * Accessor to the input by input index.
  8588. */
  8589. [idx: number]: ICameraInput<TCamera>;
  8590. }
  8591. /**
  8592. * This represents the input manager used within a camera.
  8593. * It helps dealing with all the different kind of input attached to a camera.
  8594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8595. */
  8596. export class CameraInputsManager<TCamera extends Camera> {
  8597. /**
  8598. * Defines the list of inputs attahed to the camera.
  8599. */
  8600. attached: CameraInputsMap<TCamera>;
  8601. /**
  8602. * Defines the dom element the camera is collecting inputs from.
  8603. * This is null if the controls have not been attached.
  8604. */
  8605. attachedElement: Nullable<HTMLElement>;
  8606. /**
  8607. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8608. */
  8609. noPreventDefault: boolean;
  8610. /**
  8611. * Defined the camera the input manager belongs to.
  8612. */
  8613. camera: TCamera;
  8614. /**
  8615. * Update the current camera state depending on the inputs that have been used this frame.
  8616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8617. */
  8618. checkInputs: () => void;
  8619. /**
  8620. * Instantiate a new Camera Input Manager.
  8621. * @param camera Defines the camera the input manager blongs to
  8622. */
  8623. constructor(camera: TCamera);
  8624. /**
  8625. * Add an input method to a camera
  8626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8627. * @param input camera input method
  8628. */
  8629. add(input: ICameraInput<TCamera>): void;
  8630. /**
  8631. * Remove a specific input method from a camera
  8632. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8633. * @param inputToRemove camera input method
  8634. */
  8635. remove(inputToRemove: ICameraInput<TCamera>): void;
  8636. /**
  8637. * Remove a specific input type from a camera
  8638. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8639. * @param inputType the type of the input to remove
  8640. */
  8641. removeByType(inputType: string): void;
  8642. private _addCheckInputs;
  8643. /**
  8644. * Attach the input controls to the currently attached dom element to listen the events from.
  8645. * @param input Defines the input to attach
  8646. */
  8647. attachInput(input: ICameraInput<TCamera>): void;
  8648. /**
  8649. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8650. * @param element Defines the dom element to collect the events from
  8651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8652. */
  8653. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8654. /**
  8655. * Detach the current manager inputs controls from a specific dom element.
  8656. * @param element Defines the dom element to collect the events from
  8657. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8658. */
  8659. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8660. /**
  8661. * Rebuild the dynamic inputCheck function from the current list of
  8662. * defined inputs in the manager.
  8663. */
  8664. rebuildInputCheck(): void;
  8665. /**
  8666. * Remove all attached input methods from a camera
  8667. */
  8668. clear(): void;
  8669. /**
  8670. * Serialize the current input manager attached to a camera.
  8671. * This ensures than once parsed,
  8672. * the input associated to the camera will be identical to the current ones
  8673. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8674. */
  8675. serialize(serializedCamera: any): void;
  8676. /**
  8677. * Parses an input manager serialized JSON to restore the previous list of inputs
  8678. * and states associated to a camera.
  8679. * @param parsedCamera Defines the JSON to parse
  8680. */
  8681. parse(parsedCamera: any): void;
  8682. }
  8683. }
  8684. declare module "babylonjs/Events/keyboardEvents" {
  8685. /**
  8686. * Gather the list of keyboard event types as constants.
  8687. */
  8688. export class KeyboardEventTypes {
  8689. /**
  8690. * The keydown event is fired when a key becomes active (pressed).
  8691. */
  8692. static readonly KEYDOWN: number;
  8693. /**
  8694. * The keyup event is fired when a key has been released.
  8695. */
  8696. static readonly KEYUP: number;
  8697. }
  8698. /**
  8699. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8700. */
  8701. export class KeyboardInfo {
  8702. /**
  8703. * Defines the type of event (KeyboardEventTypes)
  8704. */
  8705. type: number;
  8706. /**
  8707. * Defines the related dom event
  8708. */
  8709. event: KeyboardEvent;
  8710. /**
  8711. * Instantiates a new keyboard info.
  8712. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8713. * @param type Defines the type of event (KeyboardEventTypes)
  8714. * @param event Defines the related dom event
  8715. */
  8716. constructor(
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number,
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent);
  8725. }
  8726. /**
  8727. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8728. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8729. */
  8730. export class KeyboardInfoPre extends KeyboardInfo {
  8731. /**
  8732. * Defines the type of event (KeyboardEventTypes)
  8733. */
  8734. type: number;
  8735. /**
  8736. * Defines the related dom event
  8737. */
  8738. event: KeyboardEvent;
  8739. /**
  8740. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8741. */
  8742. skipOnPointerObservable: boolean;
  8743. /**
  8744. * Instantiates a new keyboard pre info.
  8745. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8746. * @param type Defines the type of event (KeyboardEventTypes)
  8747. * @param event Defines the related dom event
  8748. */
  8749. constructor(
  8750. /**
  8751. * Defines the type of event (KeyboardEventTypes)
  8752. */
  8753. type: number,
  8754. /**
  8755. * Defines the related dom event
  8756. */
  8757. event: KeyboardEvent);
  8758. }
  8759. }
  8760. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8761. import { Nullable } from "babylonjs/types";
  8762. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8763. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8764. /**
  8765. * Manage the keyboard inputs to control the movement of a free camera.
  8766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8767. */
  8768. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8769. /**
  8770. * Defines the camera the input is attached to.
  8771. */
  8772. camera: FreeCamera;
  8773. /**
  8774. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8775. */
  8776. keysUp: number[];
  8777. /**
  8778. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8779. */
  8780. keysDown: number[];
  8781. /**
  8782. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8783. */
  8784. keysLeft: number[];
  8785. /**
  8786. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8787. */
  8788. keysRight: number[];
  8789. private _keys;
  8790. private _onCanvasBlurObserver;
  8791. private _onKeyboardObserver;
  8792. private _engine;
  8793. private _scene;
  8794. /**
  8795. * Attach the input controls to a specific dom element to get the input from.
  8796. * @param element Defines the element the controls should be listened from
  8797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8798. */
  8799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8800. /**
  8801. * Detach the current controls from the specified dom element.
  8802. * @param element Defines the element to stop listening the inputs from
  8803. */
  8804. detachControl(element: Nullable<HTMLElement>): void;
  8805. /**
  8806. * Update the current camera state depending on the inputs that have been used this frame.
  8807. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8808. */
  8809. checkInputs(): void;
  8810. /**
  8811. * Gets the class name of the current intput.
  8812. * @returns the class name
  8813. */
  8814. getClassName(): string;
  8815. /** @hidden */
  8816. _onLostFocus(): void;
  8817. /**
  8818. * Get the friendly name associated with the input class.
  8819. * @returns the input friendly name
  8820. */
  8821. getSimpleName(): string;
  8822. }
  8823. }
  8824. declare module "babylonjs/Lights/shadowLight" {
  8825. import { Camera } from "babylonjs/Cameras/camera";
  8826. import { Scene } from "babylonjs/scene";
  8827. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8829. import { Light } from "babylonjs/Lights/light";
  8830. /**
  8831. * Interface describing all the common properties and methods a shadow light needs to implement.
  8832. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8833. * as well as binding the different shadow properties to the effects.
  8834. */
  8835. export interface IShadowLight extends Light {
  8836. /**
  8837. * The light id in the scene (used in scene.findLighById for instance)
  8838. */
  8839. id: string;
  8840. /**
  8841. * The position the shdow will be casted from.
  8842. */
  8843. position: Vector3;
  8844. /**
  8845. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8846. */
  8847. direction: Vector3;
  8848. /**
  8849. * The transformed position. Position of the light in world space taking parenting in account.
  8850. */
  8851. transformedPosition: Vector3;
  8852. /**
  8853. * The transformed direction. Direction of the light in world space taking parenting in account.
  8854. */
  8855. transformedDirection: Vector3;
  8856. /**
  8857. * The friendly name of the light in the scene.
  8858. */
  8859. name: string;
  8860. /**
  8861. * Defines the shadow projection clipping minimum z value.
  8862. */
  8863. shadowMinZ: number;
  8864. /**
  8865. * Defines the shadow projection clipping maximum z value.
  8866. */
  8867. shadowMaxZ: number;
  8868. /**
  8869. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8870. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8871. */
  8872. computeTransformedInformation(): boolean;
  8873. /**
  8874. * Gets the scene the light belongs to.
  8875. * @returns The scene
  8876. */
  8877. getScene(): Scene;
  8878. /**
  8879. * Callback defining a custom Projection Matrix Builder.
  8880. * This can be used to override the default projection matrix computation.
  8881. */
  8882. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8883. /**
  8884. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8885. * @param matrix The materix to updated with the projection information
  8886. * @param viewMatrix The transform matrix of the light
  8887. * @param renderList The list of mesh to render in the map
  8888. * @returns The current light
  8889. */
  8890. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8891. /**
  8892. * Gets the current depth scale used in ESM.
  8893. * @returns The scale
  8894. */
  8895. getDepthScale(): number;
  8896. /**
  8897. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8898. * @returns true if a cube texture needs to be use
  8899. */
  8900. needCube(): boolean;
  8901. /**
  8902. * Detects if the projection matrix requires to be recomputed this frame.
  8903. * @returns true if it requires to be recomputed otherwise, false.
  8904. */
  8905. needProjectionMatrixCompute(): boolean;
  8906. /**
  8907. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8908. */
  8909. forceProjectionMatrixCompute(): void;
  8910. /**
  8911. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8912. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8913. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8914. */
  8915. getShadowDirection(faceIndex?: number): Vector3;
  8916. /**
  8917. * Gets the minZ used for shadow according to both the scene and the light.
  8918. * @param activeCamera The camera we are returning the min for
  8919. * @returns the depth min z
  8920. */
  8921. getDepthMinZ(activeCamera: Camera): number;
  8922. /**
  8923. * Gets the maxZ used for shadow according to both the scene and the light.
  8924. * @param activeCamera The camera we are returning the max for
  8925. * @returns the depth max z
  8926. */
  8927. getDepthMaxZ(activeCamera: Camera): number;
  8928. }
  8929. /**
  8930. * Base implementation IShadowLight
  8931. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8932. */
  8933. export abstract class ShadowLight extends Light implements IShadowLight {
  8934. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8935. protected _position: Vector3;
  8936. protected _setPosition(value: Vector3): void;
  8937. /**
  8938. * Sets the position the shadow will be casted from. Also use as the light position for both
  8939. * point and spot lights.
  8940. */
  8941. /**
  8942. * Sets the position the shadow will be casted from. Also use as the light position for both
  8943. * point and spot lights.
  8944. */
  8945. position: Vector3;
  8946. protected _direction: Vector3;
  8947. protected _setDirection(value: Vector3): void;
  8948. /**
  8949. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8950. * Also use as the light direction on spot and directional lights.
  8951. */
  8952. /**
  8953. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8954. * Also use as the light direction on spot and directional lights.
  8955. */
  8956. direction: Vector3;
  8957. private _shadowMinZ;
  8958. /**
  8959. * Gets the shadow projection clipping minimum z value.
  8960. */
  8961. /**
  8962. * Sets the shadow projection clipping minimum z value.
  8963. */
  8964. shadowMinZ: number;
  8965. private _shadowMaxZ;
  8966. /**
  8967. * Sets the shadow projection clipping maximum z value.
  8968. */
  8969. /**
  8970. * Gets the shadow projection clipping maximum z value.
  8971. */
  8972. shadowMaxZ: number;
  8973. /**
  8974. * Callback defining a custom Projection Matrix Builder.
  8975. * This can be used to override the default projection matrix computation.
  8976. */
  8977. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8978. /**
  8979. * The transformed position. Position of the light in world space taking parenting in account.
  8980. */
  8981. transformedPosition: Vector3;
  8982. /**
  8983. * The transformed direction. Direction of the light in world space taking parenting in account.
  8984. */
  8985. transformedDirection: Vector3;
  8986. private _needProjectionMatrixCompute;
  8987. /**
  8988. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8989. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8990. */
  8991. computeTransformedInformation(): boolean;
  8992. /**
  8993. * Return the depth scale used for the shadow map.
  8994. * @returns the depth scale.
  8995. */
  8996. getDepthScale(): number;
  8997. /**
  8998. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8999. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9000. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9001. */
  9002. getShadowDirection(faceIndex?: number): Vector3;
  9003. /**
  9004. * Returns the ShadowLight absolute position in the World.
  9005. * @returns the position vector in world space
  9006. */
  9007. getAbsolutePosition(): Vector3;
  9008. /**
  9009. * Sets the ShadowLight direction toward the passed target.
  9010. * @param target The point to target in local space
  9011. * @returns the updated ShadowLight direction
  9012. */
  9013. setDirectionToTarget(target: Vector3): Vector3;
  9014. /**
  9015. * Returns the light rotation in euler definition.
  9016. * @returns the x y z rotation in local space.
  9017. */
  9018. getRotation(): Vector3;
  9019. /**
  9020. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9021. * @returns true if a cube texture needs to be use
  9022. */
  9023. needCube(): boolean;
  9024. /**
  9025. * Detects if the projection matrix requires to be recomputed this frame.
  9026. * @returns true if it requires to be recomputed otherwise, false.
  9027. */
  9028. needProjectionMatrixCompute(): boolean;
  9029. /**
  9030. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9031. */
  9032. forceProjectionMatrixCompute(): void;
  9033. /** @hidden */
  9034. _initCache(): void;
  9035. /** @hidden */
  9036. _isSynchronized(): boolean;
  9037. /**
  9038. * Computes the world matrix of the node
  9039. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9040. * @returns the world matrix
  9041. */
  9042. computeWorldMatrix(force?: boolean): Matrix;
  9043. /**
  9044. * Gets the minZ used for shadow according to both the scene and the light.
  9045. * @param activeCamera The camera we are returning the min for
  9046. * @returns the depth min z
  9047. */
  9048. getDepthMinZ(activeCamera: Camera): number;
  9049. /**
  9050. * Gets the maxZ used for shadow according to both the scene and the light.
  9051. * @param activeCamera The camera we are returning the max for
  9052. * @returns the depth max z
  9053. */
  9054. getDepthMaxZ(activeCamera: Camera): number;
  9055. /**
  9056. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9057. * @param matrix The materix to updated with the projection information
  9058. * @param viewMatrix The transform matrix of the light
  9059. * @param renderList The list of mesh to render in the map
  9060. * @returns The current light
  9061. */
  9062. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9063. }
  9064. }
  9065. declare module "babylonjs/Materials/materialHelper" {
  9066. import { Nullable } from "babylonjs/types";
  9067. import { Scene } from "babylonjs/scene";
  9068. import { Engine } from "babylonjs/Engines/engine";
  9069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9070. import { Light } from "babylonjs/Lights/light";
  9071. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9072. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9073. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9074. /**
  9075. * "Static Class" containing the most commonly used helper while dealing with material for
  9076. * rendering purpose.
  9077. *
  9078. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9079. *
  9080. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9081. */
  9082. export class MaterialHelper {
  9083. /**
  9084. * Bind the current view position to an effect.
  9085. * @param effect The effect to be bound
  9086. * @param scene The scene the eyes position is used from
  9087. */
  9088. static BindEyePosition(effect: Effect, scene: Scene): void;
  9089. /**
  9090. * Helps preparing the defines values about the UVs in used in the effect.
  9091. * UVs are shared as much as we can accross channels in the shaders.
  9092. * @param texture The texture we are preparing the UVs for
  9093. * @param defines The defines to update
  9094. * @param key The channel key "diffuse", "specular"... used in the shader
  9095. */
  9096. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9097. /**
  9098. * Binds a texture matrix value to its corrsponding uniform
  9099. * @param texture The texture to bind the matrix for
  9100. * @param uniformBuffer The uniform buffer receivin the data
  9101. * @param key The channel key "diffuse", "specular"... used in the shader
  9102. */
  9103. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9104. /**
  9105. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9106. * @param mesh defines the current mesh
  9107. * @param scene defines the current scene
  9108. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9109. * @param pointsCloud defines if point cloud rendering has to be turned on
  9110. * @param fogEnabled defines if fog has to be turned on
  9111. * @param alphaTest defines if alpha testing has to be turned on
  9112. * @param defines defines the current list of defines
  9113. */
  9114. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9115. /**
  9116. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9117. * @param scene defines the current scene
  9118. * @param engine defines the current engine
  9119. * @param defines specifies the list of active defines
  9120. * @param useInstances defines if instances have to be turned on
  9121. * @param useClipPlane defines if clip plane have to be turned on
  9122. */
  9123. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9124. /**
  9125. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9126. * @param mesh The mesh containing the geometry data we will draw
  9127. * @param defines The defines to update
  9128. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9129. * @param useBones Precise whether bones should be used or not (override mesh info)
  9130. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9131. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9132. * @returns false if defines are considered not dirty and have not been checked
  9133. */
  9134. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9135. /**
  9136. * Prepares the defines related to the light information passed in parameter
  9137. * @param scene The scene we are intending to draw
  9138. * @param mesh The mesh the effect is compiling for
  9139. * @param defines The defines to update
  9140. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9141. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9142. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9143. * @returns true if normals will be required for the rest of the effect
  9144. */
  9145. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9146. /**
  9147. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9148. * that won t be acctive due to defines being turned off.
  9149. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9150. * @param samplersList The samplers list
  9151. * @param defines The defines helping in the list generation
  9152. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9153. */
  9154. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9155. /**
  9156. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9157. * @param defines The defines to update while falling back
  9158. * @param fallbacks The authorized effect fallbacks
  9159. * @param maxSimultaneousLights The maximum number of lights allowed
  9160. * @param rank the current rank of the Effect
  9161. * @returns The newly affected rank
  9162. */
  9163. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9164. /**
  9165. * Prepares the list of attributes required for morph targets according to the effect defines.
  9166. * @param attribs The current list of supported attribs
  9167. * @param mesh The mesh to prepare the morph targets attributes for
  9168. * @param defines The current Defines of the effect
  9169. */
  9170. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9171. /**
  9172. * Prepares the list of attributes required for bones according to the effect defines.
  9173. * @param attribs The current list of supported attribs
  9174. * @param mesh The mesh to prepare the bones attributes for
  9175. * @param defines The current Defines of the effect
  9176. * @param fallbacks The current efffect fallback strategy
  9177. */
  9178. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9179. /**
  9180. * Prepares the list of attributes required for instances according to the effect defines.
  9181. * @param attribs The current list of supported attribs
  9182. * @param defines The current Defines of the effect
  9183. */
  9184. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9185. /**
  9186. * Binds the light shadow information to the effect for the given mesh.
  9187. * @param light The light containing the generator
  9188. * @param scene The scene the lights belongs to
  9189. * @param mesh The mesh we are binding the information to render
  9190. * @param lightIndex The light index in the effect used to render the mesh
  9191. * @param effect The effect we are binding the data to
  9192. */
  9193. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9194. /**
  9195. * Binds the light information to the effect.
  9196. * @param light The light containing the generator
  9197. * @param effect The effect we are binding the data to
  9198. * @param lightIndex The light index in the effect used to render
  9199. */
  9200. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9201. /**
  9202. * Binds the lights information from the scene to the effect for the given mesh.
  9203. * @param scene The scene the lights belongs to
  9204. * @param mesh The mesh we are binding the information to render
  9205. * @param effect The effect we are binding the data to
  9206. * @param defines The generated defines for the effect
  9207. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9208. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9209. */
  9210. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9211. private static _tempFogColor;
  9212. /**
  9213. * Binds the fog information from the scene to the effect for the given mesh.
  9214. * @param scene The scene the lights belongs to
  9215. * @param mesh The mesh we are binding the information to render
  9216. * @param effect The effect we are binding the data to
  9217. * @param linearSpace Defines if the fog effect is applied in linear space
  9218. */
  9219. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9220. /**
  9221. * Binds the bones information from the mesh to the effect.
  9222. * @param mesh The mesh we are binding the information to render
  9223. * @param effect The effect we are binding the data to
  9224. */
  9225. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9226. /**
  9227. * Binds the morph targets information from the mesh to the effect.
  9228. * @param abstractMesh The mesh we are binding the information to render
  9229. * @param effect The effect we are binding the data to
  9230. */
  9231. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9232. /**
  9233. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9234. * @param defines The generated defines used in the effect
  9235. * @param effect The effect we are binding the data to
  9236. * @param scene The scene we are willing to render with logarithmic scale for
  9237. */
  9238. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9239. /**
  9240. * Binds the clip plane information from the scene to the effect.
  9241. * @param scene The scene the clip plane information are extracted from
  9242. * @param effect The effect we are binding the data to
  9243. */
  9244. static BindClipPlane(effect: Effect, scene: Scene): void;
  9245. }
  9246. }
  9247. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9248. /** @hidden */
  9249. export var kernelBlurVaryingDeclaration: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9255. /** @hidden */
  9256. export var kernelBlurFragment: {
  9257. name: string;
  9258. shader: string;
  9259. };
  9260. }
  9261. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9262. /** @hidden */
  9263. export var kernelBlurFragment2: {
  9264. name: string;
  9265. shader: string;
  9266. };
  9267. }
  9268. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9269. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9270. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9271. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9272. /** @hidden */
  9273. export var kernelBlurPixelShader: {
  9274. name: string;
  9275. shader: string;
  9276. };
  9277. }
  9278. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9279. /** @hidden */
  9280. export var kernelBlurVertex: {
  9281. name: string;
  9282. shader: string;
  9283. };
  9284. }
  9285. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9286. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9287. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9288. /** @hidden */
  9289. export var kernelBlurVertexShader: {
  9290. name: string;
  9291. shader: string;
  9292. };
  9293. }
  9294. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9295. import { Vector2 } from "babylonjs/Maths/math";
  9296. import { Nullable } from "babylonjs/types";
  9297. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9298. import { Camera } from "babylonjs/Cameras/camera";
  9299. import { Effect } from "babylonjs/Materials/effect";
  9300. import { Engine } from "babylonjs/Engines/engine";
  9301. import "babylonjs/Shaders/kernelBlur.fragment";
  9302. import "babylonjs/Shaders/kernelBlur.vertex";
  9303. /**
  9304. * The Blur Post Process which blurs an image based on a kernel and direction.
  9305. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9306. */
  9307. export class BlurPostProcess extends PostProcess {
  9308. /** The direction in which to blur the image. */
  9309. direction: Vector2;
  9310. private blockCompilation;
  9311. protected _kernel: number;
  9312. protected _idealKernel: number;
  9313. protected _packedFloat: boolean;
  9314. private _staticDefines;
  9315. /**
  9316. * Sets the length in pixels of the blur sample region
  9317. */
  9318. /**
  9319. * Gets the length in pixels of the blur sample region
  9320. */
  9321. kernel: number;
  9322. /**
  9323. * Sets wether or not the blur needs to unpack/repack floats
  9324. */
  9325. /**
  9326. * Gets wether or not the blur is unpacking/repacking floats
  9327. */
  9328. packedFloat: boolean;
  9329. /**
  9330. * Creates a new instance BlurPostProcess
  9331. * @param name The name of the effect.
  9332. * @param direction The direction in which to blur the image.
  9333. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  9334. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9335. * @param camera The camera to apply the render pass to.
  9336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9337. * @param engine The engine which the post process will be applied. (default: current engine)
  9338. * @param reusable If the post process can be reused on the same frame. (default: false)
  9339. * @param textureType Type of textures used when performing the post process. (default: 0)
  9340. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  9341. */
  9342. constructor(name: string,
  9343. /** The direction in which to blur the image. */
  9344. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9345. /**
  9346. * Updates the effect with the current post process compile time values and recompiles the shader.
  9347. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9348. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9349. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9350. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  9351. * @param onCompiled Called when the shader has been compiled.
  9352. * @param onError Called if there is an error when compiling a shader.
  9353. */
  9354. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9355. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9356. /**
  9357. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9358. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9359. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9360. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9361. * The gaps between physical kernels are compensated for in the weighting of the samples
  9362. * @param idealKernel Ideal blur kernel.
  9363. * @return Nearest best kernel.
  9364. */
  9365. protected _nearestBestKernel(idealKernel: number): number;
  9366. /**
  9367. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9368. * @param x The point on the Gaussian distribution to sample.
  9369. * @return the value of the Gaussian function at x.
  9370. */
  9371. protected _gaussianWeight(x: number): number;
  9372. /**
  9373. * Generates a string that can be used as a floating point number in GLSL.
  9374. * @param x Value to print.
  9375. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9376. * @return GLSL float string.
  9377. */
  9378. protected _glslFloat(x: number, decimalFigures?: number): string;
  9379. }
  9380. }
  9381. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9382. /** @hidden */
  9383. export var shadowMapPixelShader: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9389. /** @hidden */
  9390. export var bonesDeclaration: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9396. /** @hidden */
  9397. export var morphTargetsVertexGlobalDeclaration: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9403. /** @hidden */
  9404. export var morphTargetsVertexDeclaration: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9410. /** @hidden */
  9411. export var instancesDeclaration: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9417. /** @hidden */
  9418. export var helperFunctions: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9424. /** @hidden */
  9425. export var morphTargetsVertex: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9431. /** @hidden */
  9432. export var instancesVertex: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9438. /** @hidden */
  9439. export var bonesVertex: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9445. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9446. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9447. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9448. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9449. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9450. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9451. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9452. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9453. /** @hidden */
  9454. export var shadowMapVertexShader: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9460. /** @hidden */
  9461. export var depthBoxBlurPixelShader: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9467. import { Nullable } from "babylonjs/types";
  9468. import { Scene } from "babylonjs/scene";
  9469. import { Matrix } from "babylonjs/Maths/math";
  9470. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9472. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9473. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9474. import { Effect } from "babylonjs/Materials/effect";
  9475. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9476. import "babylonjs/Shaders/shadowMap.fragment";
  9477. import "babylonjs/Shaders/shadowMap.vertex";
  9478. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9479. import { Observable } from "babylonjs/Misc/observable";
  9480. /**
  9481. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9482. */
  9483. export interface ICustomShaderOptions {
  9484. /**
  9485. * Gets or sets the custom shader name to use
  9486. */
  9487. shaderName: string;
  9488. /**
  9489. * The list of attribute names used in the shader
  9490. */
  9491. attributes?: string[];
  9492. /**
  9493. * The list of unifrom names used in the shader
  9494. */
  9495. uniforms?: string[];
  9496. /**
  9497. * The list of sampler names used in the shader
  9498. */
  9499. samplers?: string[];
  9500. /**
  9501. * The list of defines used in the shader
  9502. */
  9503. defines?: string[];
  9504. }
  9505. /**
  9506. * Interface to implement to create a shadow generator compatible with BJS.
  9507. */
  9508. export interface IShadowGenerator {
  9509. /**
  9510. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9511. * @returns The render target texture if present otherwise, null
  9512. */
  9513. getShadowMap(): Nullable<RenderTargetTexture>;
  9514. /**
  9515. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9516. * @returns The render target texture if the shadow map is present otherwise, null
  9517. */
  9518. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9519. /**
  9520. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9521. * @param subMesh The submesh we want to render in the shadow map
  9522. * @param useInstances Defines wether will draw in the map using instances
  9523. * @returns true if ready otherwise, false
  9524. */
  9525. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9526. /**
  9527. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9528. * @param defines Defines of the material we want to update
  9529. * @param lightIndex Index of the light in the enabled light list of the material
  9530. */
  9531. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9532. /**
  9533. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9534. * defined in the generator but impacting the effect).
  9535. * It implies the unifroms available on the materials are the standard BJS ones.
  9536. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9537. * @param effect The effect we are binfing the information for
  9538. */
  9539. bindShadowLight(lightIndex: string, effect: Effect): void;
  9540. /**
  9541. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9542. * (eq to shadow prjection matrix * light transform matrix)
  9543. * @returns The transform matrix used to create the shadow map
  9544. */
  9545. getTransformMatrix(): Matrix;
  9546. /**
  9547. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9548. * Cube and 2D textures for instance.
  9549. */
  9550. recreateShadowMap(): void;
  9551. /**
  9552. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9553. * @param onCompiled Callback triggered at the and of the effects compilation
  9554. * @param options Sets of optional options forcing the compilation with different modes
  9555. */
  9556. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9557. useInstances: boolean;
  9558. }>): void;
  9559. /**
  9560. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9561. * @param options Sets of optional options forcing the compilation with different modes
  9562. * @returns A promise that resolves when the compilation completes
  9563. */
  9564. forceCompilationAsync(options?: Partial<{
  9565. useInstances: boolean;
  9566. }>): Promise<void>;
  9567. /**
  9568. * Serializes the shadow generator setup to a json object.
  9569. * @returns The serialized JSON object
  9570. */
  9571. serialize(): any;
  9572. /**
  9573. * Disposes the Shadow map and related Textures and effects.
  9574. */
  9575. dispose(): void;
  9576. }
  9577. /**
  9578. * Default implementation IShadowGenerator.
  9579. * This is the main object responsible of generating shadows in the framework.
  9580. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9581. */
  9582. export class ShadowGenerator implements IShadowGenerator {
  9583. /**
  9584. * Shadow generator mode None: no filtering applied.
  9585. */
  9586. static readonly FILTER_NONE: number;
  9587. /**
  9588. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9589. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9590. */
  9591. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9592. /**
  9593. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9594. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9595. */
  9596. static readonly FILTER_POISSONSAMPLING: number;
  9597. /**
  9598. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9599. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9600. */
  9601. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9602. /**
  9603. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9604. * edge artifacts on steep falloff.
  9605. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9606. */
  9607. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9608. /**
  9609. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9610. * edge artifacts on steep falloff.
  9611. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9612. */
  9613. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9614. /**
  9615. * Shadow generator mode PCF: Percentage Closer Filtering
  9616. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9617. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9618. */
  9619. static readonly FILTER_PCF: number;
  9620. /**
  9621. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9622. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9623. * Contact Hardening
  9624. */
  9625. static readonly FILTER_PCSS: number;
  9626. /**
  9627. * Reserved for PCF and PCSS
  9628. * Highest Quality.
  9629. *
  9630. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9631. *
  9632. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9633. */
  9634. static readonly QUALITY_HIGH: number;
  9635. /**
  9636. * Reserved for PCF and PCSS
  9637. * Good tradeoff for quality/perf cross devices
  9638. *
  9639. * Execute PCF on a 3*3 kernel.
  9640. *
  9641. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9642. */
  9643. static readonly QUALITY_MEDIUM: number;
  9644. /**
  9645. * Reserved for PCF and PCSS
  9646. * The lowest quality but the fastest.
  9647. *
  9648. * Execute PCF on a 1*1 kernel.
  9649. *
  9650. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9651. */
  9652. static readonly QUALITY_LOW: number;
  9653. /** Gets or sets the custom shader name to use */
  9654. customShaderOptions: ICustomShaderOptions;
  9655. /**
  9656. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9657. */
  9658. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9659. private _bias;
  9660. /**
  9661. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9662. */
  9663. /**
  9664. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9665. */
  9666. bias: number;
  9667. private _normalBias;
  9668. /**
  9669. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9670. */
  9671. /**
  9672. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9673. */
  9674. normalBias: number;
  9675. private _blurBoxOffset;
  9676. /**
  9677. * Gets the blur box offset: offset applied during the blur pass.
  9678. * Only useful if useKernelBlur = false
  9679. */
  9680. /**
  9681. * Sets the blur box offset: offset applied during the blur pass.
  9682. * Only useful if useKernelBlur = false
  9683. */
  9684. blurBoxOffset: number;
  9685. private _blurScale;
  9686. /**
  9687. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9688. * 2 means half of the size.
  9689. */
  9690. /**
  9691. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9692. * 2 means half of the size.
  9693. */
  9694. blurScale: number;
  9695. private _blurKernel;
  9696. /**
  9697. * Gets the blur kernel: kernel size of the blur pass.
  9698. * Only useful if useKernelBlur = true
  9699. */
  9700. /**
  9701. * Sets the blur kernel: kernel size of the blur pass.
  9702. * Only useful if useKernelBlur = true
  9703. */
  9704. blurKernel: number;
  9705. private _useKernelBlur;
  9706. /**
  9707. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9708. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9709. */
  9710. /**
  9711. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9712. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9713. */
  9714. useKernelBlur: boolean;
  9715. private _depthScale;
  9716. /**
  9717. * Gets the depth scale used in ESM mode.
  9718. */
  9719. /**
  9720. * Sets the depth scale used in ESM mode.
  9721. * This can override the scale stored on the light.
  9722. */
  9723. depthScale: number;
  9724. private _filter;
  9725. /**
  9726. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9727. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9728. */
  9729. /**
  9730. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9731. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9732. */
  9733. filter: number;
  9734. /**
  9735. * Gets if the current filter is set to Poisson Sampling.
  9736. */
  9737. /**
  9738. * Sets the current filter to Poisson Sampling.
  9739. */
  9740. usePoissonSampling: boolean;
  9741. /**
  9742. * Gets if the current filter is set to ESM.
  9743. */
  9744. /**
  9745. * Sets the current filter is to ESM.
  9746. */
  9747. useExponentialShadowMap: boolean;
  9748. /**
  9749. * Gets if the current filter is set to filtered ESM.
  9750. */
  9751. /**
  9752. * Gets if the current filter is set to filtered ESM.
  9753. */
  9754. useBlurExponentialShadowMap: boolean;
  9755. /**
  9756. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9757. * exponential to prevent steep falloff artifacts).
  9758. */
  9759. /**
  9760. * Sets the current filter to "close ESM" (using the inverse of the
  9761. * exponential to prevent steep falloff artifacts).
  9762. */
  9763. useCloseExponentialShadowMap: boolean;
  9764. /**
  9765. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9766. * exponential to prevent steep falloff artifacts).
  9767. */
  9768. /**
  9769. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9770. * exponential to prevent steep falloff artifacts).
  9771. */
  9772. useBlurCloseExponentialShadowMap: boolean;
  9773. /**
  9774. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9775. */
  9776. /**
  9777. * Sets the current filter to "PCF" (percentage closer filtering).
  9778. */
  9779. usePercentageCloserFiltering: boolean;
  9780. private _filteringQuality;
  9781. /**
  9782. * Gets the PCF or PCSS Quality.
  9783. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9784. */
  9785. /**
  9786. * Sets the PCF or PCSS Quality.
  9787. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9788. */
  9789. filteringQuality: number;
  9790. /**
  9791. * Gets if the current filter is set to "PCSS" (contact hardening).
  9792. */
  9793. /**
  9794. * Sets the current filter to "PCSS" (contact hardening).
  9795. */
  9796. useContactHardeningShadow: boolean;
  9797. private _contactHardeningLightSizeUVRatio;
  9798. /**
  9799. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9800. * Using a ratio helps keeping shape stability independently of the map size.
  9801. *
  9802. * It does not account for the light projection as it was having too much
  9803. * instability during the light setup or during light position changes.
  9804. *
  9805. * Only valid if useContactHardeningShadow is true.
  9806. */
  9807. /**
  9808. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9809. * Using a ratio helps keeping shape stability independently of the map size.
  9810. *
  9811. * It does not account for the light projection as it was having too much
  9812. * instability during the light setup or during light position changes.
  9813. *
  9814. * Only valid if useContactHardeningShadow is true.
  9815. */
  9816. contactHardeningLightSizeUVRatio: number;
  9817. private _darkness;
  9818. /**
  9819. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9820. * 0 means strongest and 1 would means no shadow.
  9821. * @returns the darkness.
  9822. */
  9823. getDarkness(): number;
  9824. /**
  9825. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9826. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9827. * @returns the shadow generator allowing fluent coding.
  9828. */
  9829. setDarkness(darkness: number): ShadowGenerator;
  9830. private _transparencyShadow;
  9831. /**
  9832. * Sets the ability to have transparent shadow (boolean).
  9833. * @param transparent True if transparent else False
  9834. * @returns the shadow generator allowing fluent coding
  9835. */
  9836. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9837. private _shadowMap;
  9838. private _shadowMap2;
  9839. /**
  9840. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9841. * @returns The render target texture if present otherwise, null
  9842. */
  9843. getShadowMap(): Nullable<RenderTargetTexture>;
  9844. /**
  9845. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9846. * @returns The render target texture if the shadow map is present otherwise, null
  9847. */
  9848. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9849. /**
  9850. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9851. * @param mesh Mesh to add
  9852. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9853. * @returns the Shadow Generator itself
  9854. */
  9855. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9856. /**
  9857. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9858. * @param mesh Mesh to remove
  9859. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9860. * @returns the Shadow Generator itself
  9861. */
  9862. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9863. /**
  9864. * Controls the extent to which the shadows fade out at the edge of the frustum
  9865. * Used only by directionals and spots
  9866. */
  9867. frustumEdgeFalloff: number;
  9868. private _light;
  9869. /**
  9870. * Returns the associated light object.
  9871. * @returns the light generating the shadow
  9872. */
  9873. getLight(): IShadowLight;
  9874. /**
  9875. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9876. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9877. * It might on the other hand introduce peter panning.
  9878. */
  9879. forceBackFacesOnly: boolean;
  9880. private _scene;
  9881. private _lightDirection;
  9882. private _effect;
  9883. private _viewMatrix;
  9884. private _projectionMatrix;
  9885. private _transformMatrix;
  9886. private _cachedPosition;
  9887. private _cachedDirection;
  9888. private _cachedDefines;
  9889. private _currentRenderID;
  9890. private _boxBlurPostprocess;
  9891. private _kernelBlurXPostprocess;
  9892. private _kernelBlurYPostprocess;
  9893. private _blurPostProcesses;
  9894. private _mapSize;
  9895. private _currentFaceIndex;
  9896. private _currentFaceIndexCache;
  9897. private _textureType;
  9898. private _defaultTextureMatrix;
  9899. /** @hidden */
  9900. static _SceneComponentInitialization: (scene: Scene) => void;
  9901. /**
  9902. * Creates a ShadowGenerator object.
  9903. * A ShadowGenerator is the required tool to use the shadows.
  9904. * Each light casting shadows needs to use its own ShadowGenerator.
  9905. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9906. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9907. * @param light The light object generating the shadows.
  9908. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9909. */
  9910. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9911. private _initializeGenerator;
  9912. private _initializeShadowMap;
  9913. private _initializeBlurRTTAndPostProcesses;
  9914. private _renderForShadowMap;
  9915. private _renderSubMeshForShadowMap;
  9916. private _applyFilterValues;
  9917. /**
  9918. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9919. * @param onCompiled Callback triggered at the and of the effects compilation
  9920. * @param options Sets of optional options forcing the compilation with different modes
  9921. */
  9922. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9923. useInstances: boolean;
  9924. }>): void;
  9925. /**
  9926. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9927. * @param options Sets of optional options forcing the compilation with different modes
  9928. * @returns A promise that resolves when the compilation completes
  9929. */
  9930. forceCompilationAsync(options?: Partial<{
  9931. useInstances: boolean;
  9932. }>): Promise<void>;
  9933. /**
  9934. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9935. * @param subMesh The submesh we want to render in the shadow map
  9936. * @param useInstances Defines wether will draw in the map using instances
  9937. * @returns true if ready otherwise, false
  9938. */
  9939. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9940. /**
  9941. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9942. * @param defines Defines of the material we want to update
  9943. * @param lightIndex Index of the light in the enabled light list of the material
  9944. */
  9945. prepareDefines(defines: any, lightIndex: number): void;
  9946. /**
  9947. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9948. * defined in the generator but impacting the effect).
  9949. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9950. * @param effect The effect we are binfing the information for
  9951. */
  9952. bindShadowLight(lightIndex: string, effect: Effect): void;
  9953. /**
  9954. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9955. * (eq to shadow prjection matrix * light transform matrix)
  9956. * @returns The transform matrix used to create the shadow map
  9957. */
  9958. getTransformMatrix(): Matrix;
  9959. /**
  9960. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9961. * Cube and 2D textures for instance.
  9962. */
  9963. recreateShadowMap(): void;
  9964. private _disposeBlurPostProcesses;
  9965. private _disposeRTTandPostProcesses;
  9966. /**
  9967. * Disposes the ShadowGenerator.
  9968. * Returns nothing.
  9969. */
  9970. dispose(): void;
  9971. /**
  9972. * Serializes the shadow generator setup to a json object.
  9973. * @returns The serialized JSON object
  9974. */
  9975. serialize(): any;
  9976. /**
  9977. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9978. * @param parsedShadowGenerator The JSON object to parse
  9979. * @param scene The scene to create the shadow map for
  9980. * @returns The parsed shadow generator
  9981. */
  9982. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9983. }
  9984. }
  9985. declare module "babylonjs/Lights/light" {
  9986. import { Nullable } from "babylonjs/types";
  9987. import { Scene } from "babylonjs/scene";
  9988. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9989. import { Node } from "babylonjs/node";
  9990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9991. import { Effect } from "babylonjs/Materials/effect";
  9992. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9993. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9994. /**
  9995. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9996. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9997. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9998. */
  9999. export abstract class Light extends Node {
  10000. /**
  10001. * Falloff Default: light is falling off following the material specification:
  10002. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10003. */
  10004. static readonly FALLOFF_DEFAULT: number;
  10005. /**
  10006. * Falloff Physical: light is falling off following the inverse squared distance law.
  10007. */
  10008. static readonly FALLOFF_PHYSICAL: number;
  10009. /**
  10010. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10011. * to enhance interoperability with other engines.
  10012. */
  10013. static readonly FALLOFF_GLTF: number;
  10014. /**
  10015. * Falloff Standard: light is falling off like in the standard material
  10016. * to enhance interoperability with other materials.
  10017. */
  10018. static readonly FALLOFF_STANDARD: number;
  10019. /**
  10020. * If every light affecting the material is in this lightmapMode,
  10021. * material.lightmapTexture adds or multiplies
  10022. * (depends on material.useLightmapAsShadowmap)
  10023. * after every other light calculations.
  10024. */
  10025. static readonly LIGHTMAP_DEFAULT: number;
  10026. /**
  10027. * material.lightmapTexture as only diffuse lighting from this light
  10028. * adds only specular lighting from this light
  10029. * adds dynamic shadows
  10030. */
  10031. static readonly LIGHTMAP_SPECULAR: number;
  10032. /**
  10033. * material.lightmapTexture as only lighting
  10034. * no light calculation from this light
  10035. * only adds dynamic shadows from this light
  10036. */
  10037. static readonly LIGHTMAP_SHADOWSONLY: number;
  10038. /**
  10039. * Each light type uses the default quantity according to its type:
  10040. * point/spot lights use luminous intensity
  10041. * directional lights use illuminance
  10042. */
  10043. static readonly INTENSITYMODE_AUTOMATIC: number;
  10044. /**
  10045. * lumen (lm)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10048. /**
  10049. * candela (lm/sr)
  10050. */
  10051. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10052. /**
  10053. * lux (lm/m^2)
  10054. */
  10055. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10056. /**
  10057. * nit (cd/m^2)
  10058. */
  10059. static readonly INTENSITYMODE_LUMINANCE: number;
  10060. /**
  10061. * Light type const id of the point light.
  10062. */
  10063. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10064. /**
  10065. * Light type const id of the directional light.
  10066. */
  10067. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10068. /**
  10069. * Light type const id of the spot light.
  10070. */
  10071. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10072. /**
  10073. * Light type const id of the hemispheric light.
  10074. */
  10075. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10076. /**
  10077. * Diffuse gives the basic color to an object.
  10078. */
  10079. diffuse: Color3;
  10080. /**
  10081. * Specular produces a highlight color on an object.
  10082. * Note: This is note affecting PBR materials.
  10083. */
  10084. specular: Color3;
  10085. /**
  10086. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10087. * falling off base on range or angle.
  10088. * This can be set to any values in Light.FALLOFF_x.
  10089. *
  10090. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10091. * other types of materials.
  10092. */
  10093. falloffType: number;
  10094. /**
  10095. * Strength of the light.
  10096. * Note: By default it is define in the framework own unit.
  10097. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10098. */
  10099. intensity: number;
  10100. private _range;
  10101. protected _inverseSquaredRange: number;
  10102. /**
  10103. * Defines how far from the source the light is impacting in scene units.
  10104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10105. */
  10106. /**
  10107. * Defines how far from the source the light is impacting in scene units.
  10108. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10109. */
  10110. range: number;
  10111. /**
  10112. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10113. * of light.
  10114. */
  10115. private _photometricScale;
  10116. private _intensityMode;
  10117. /**
  10118. * Gets the photometric scale used to interpret the intensity.
  10119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10120. */
  10121. /**
  10122. * Sets the photometric scale used to interpret the intensity.
  10123. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10124. */
  10125. intensityMode: number;
  10126. private _radius;
  10127. /**
  10128. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10129. */
  10130. /**
  10131. * sets the light radius used by PBR Materials to simulate soft area lights.
  10132. */
  10133. radius: number;
  10134. private _renderPriority;
  10135. /**
  10136. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10137. * exceeding the number allowed of the materials.
  10138. */
  10139. renderPriority: number;
  10140. private _shadowEnabled;
  10141. /**
  10142. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10143. * the current shadow generator.
  10144. */
  10145. /**
  10146. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10147. * the current shadow generator.
  10148. */
  10149. shadowEnabled: boolean;
  10150. private _includedOnlyMeshes;
  10151. /**
  10152. * Gets the only meshes impacted by this light.
  10153. */
  10154. /**
  10155. * Sets the only meshes impacted by this light.
  10156. */
  10157. includedOnlyMeshes: AbstractMesh[];
  10158. private _excludedMeshes;
  10159. /**
  10160. * Gets the meshes not impacted by this light.
  10161. */
  10162. /**
  10163. * Sets the meshes not impacted by this light.
  10164. */
  10165. excludedMeshes: AbstractMesh[];
  10166. private _excludeWithLayerMask;
  10167. /**
  10168. * Gets the layer id use to find what meshes are not impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. /**
  10172. * Sets the layer id use to find what meshes are not impacted by the light.
  10173. * Inactive if 0
  10174. */
  10175. excludeWithLayerMask: number;
  10176. private _includeOnlyWithLayerMask;
  10177. /**
  10178. * Gets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. /**
  10182. * Sets the layer id use to find what meshes are impacted by the light.
  10183. * Inactive if 0
  10184. */
  10185. includeOnlyWithLayerMask: number;
  10186. private _lightmapMode;
  10187. /**
  10188. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10189. */
  10190. /**
  10191. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10192. */
  10193. lightmapMode: number;
  10194. /**
  10195. * Shadow generator associted to the light.
  10196. * @hidden Internal use only.
  10197. */
  10198. _shadowGenerator: Nullable<IShadowGenerator>;
  10199. /**
  10200. * @hidden Internal use only.
  10201. */
  10202. _excludedMeshesIds: string[];
  10203. /**
  10204. * @hidden Internal use only.
  10205. */
  10206. _includedOnlyMeshesIds: string[];
  10207. /**
  10208. * The current light unifom buffer.
  10209. * @hidden Internal use only.
  10210. */
  10211. _uniformBuffer: UniformBuffer;
  10212. /**
  10213. * Creates a Light object in the scene.
  10214. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10215. * @param name The firendly name of the light
  10216. * @param scene The scene the light belongs too
  10217. */
  10218. constructor(name: string, scene: Scene);
  10219. protected abstract _buildUniformLayout(): void;
  10220. /**
  10221. * Sets the passed Effect "effect" with the Light information.
  10222. * @param effect The effect to update
  10223. * @param lightIndex The index of the light in the effect to update
  10224. * @returns The light
  10225. */
  10226. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10227. /**
  10228. * Returns the string "Light".
  10229. * @returns the class name
  10230. */
  10231. getClassName(): string;
  10232. /** @hidden */
  10233. readonly _isLight: boolean;
  10234. /**
  10235. * Converts the light information to a readable string for debug purpose.
  10236. * @param fullDetails Supports for multiple levels of logging within scene loading
  10237. * @returns the human readable light info
  10238. */
  10239. toString(fullDetails?: boolean): string;
  10240. /** @hidden */
  10241. protected _syncParentEnabledState(): void;
  10242. /**
  10243. * Set the enabled state of this node.
  10244. * @param value - the new enabled state
  10245. */
  10246. setEnabled(value: boolean): void;
  10247. /**
  10248. * Returns the Light associated shadow generator if any.
  10249. * @return the associated shadow generator.
  10250. */
  10251. getShadowGenerator(): Nullable<IShadowGenerator>;
  10252. /**
  10253. * Returns a Vector3, the absolute light position in the World.
  10254. * @returns the world space position of the light
  10255. */
  10256. getAbsolutePosition(): Vector3;
  10257. /**
  10258. * Specifies if the light will affect the passed mesh.
  10259. * @param mesh The mesh to test against the light
  10260. * @return true the mesh is affected otherwise, false.
  10261. */
  10262. canAffectMesh(mesh: AbstractMesh): boolean;
  10263. /**
  10264. * Sort function to order lights for rendering.
  10265. * @param a First Light object to compare to second.
  10266. * @param b Second Light object to compare first.
  10267. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10268. */
  10269. static CompareLightsPriority(a: Light, b: Light): number;
  10270. /**
  10271. * Releases resources associated with this node.
  10272. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10273. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10274. */
  10275. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10276. /**
  10277. * Returns the light type ID (integer).
  10278. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10279. */
  10280. getTypeID(): number;
  10281. /**
  10282. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10283. * @returns the scaled intensity in intensity mode unit
  10284. */
  10285. getScaledIntensity(): number;
  10286. /**
  10287. * Returns a new Light object, named "name", from the current one.
  10288. * @param name The name of the cloned light
  10289. * @returns the new created light
  10290. */
  10291. clone(name: string): Nullable<Light>;
  10292. /**
  10293. * Serializes the current light into a Serialization object.
  10294. * @returns the serialized object.
  10295. */
  10296. serialize(): any;
  10297. /**
  10298. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10299. * This new light is named "name" and added to the passed scene.
  10300. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10301. * @param name The friendly name of the light
  10302. * @param scene The scene the new light will belong to
  10303. * @returns the constructor function
  10304. */
  10305. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10306. /**
  10307. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10308. * @param parsedLight The JSON representation of the light
  10309. * @param scene The scene to create the parsed light in
  10310. * @returns the created light after parsing
  10311. */
  10312. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10313. private _hookArrayForExcluded;
  10314. private _hookArrayForIncludedOnly;
  10315. private _resyncMeshes;
  10316. /**
  10317. * Forces the meshes to update their light related information in their rendering used effects
  10318. * @hidden Internal Use Only
  10319. */
  10320. _markMeshesAsLightDirty(): void;
  10321. /**
  10322. * Recomputes the cached photometric scale if needed.
  10323. */
  10324. private _computePhotometricScale;
  10325. /**
  10326. * Returns the Photometric Scale according to the light type and intensity mode.
  10327. */
  10328. private _getPhotometricScale;
  10329. /**
  10330. * Reorder the light in the scene according to their defined priority.
  10331. * @hidden Internal Use Only
  10332. */
  10333. _reorderLightsInScene(): void;
  10334. /**
  10335. * Prepares the list of defines specific to the light type.
  10336. * @param defines the list of defines
  10337. * @param lightIndex defines the index of the light for the effect
  10338. */
  10339. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10340. }
  10341. }
  10342. declare module "babylonjs/Actions/action" {
  10343. import { Observable } from "babylonjs/Misc/observable";
  10344. import { Condition } from "babylonjs/Actions/condition";
  10345. import { ActionManager } from "babylonjs/Actions/actionManager";
  10346. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10347. /**
  10348. * Interface used to define Action
  10349. */
  10350. export interface IAction {
  10351. /**
  10352. * Trigger for the action
  10353. */
  10354. trigger: number;
  10355. /** Options of the trigger */
  10356. triggerOptions: any;
  10357. /**
  10358. * Gets the trigger parameters
  10359. * @returns the trigger parameters
  10360. */
  10361. getTriggerParameter(): any;
  10362. /**
  10363. * Internal only - executes current action event
  10364. * @hidden
  10365. */
  10366. _executeCurrent(evt?: ActionEvent): void;
  10367. /**
  10368. * Serialize placeholder for child classes
  10369. * @param parent of child
  10370. * @returns the serialized object
  10371. */
  10372. serialize(parent: any): any;
  10373. }
  10374. /**
  10375. * The action to be carried out following a trigger
  10376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10377. */
  10378. export class Action implements IAction {
  10379. /** the trigger, with or without parameters, for the action */
  10380. triggerOptions: any;
  10381. /**
  10382. * Trigger for the action
  10383. */
  10384. trigger: number;
  10385. /**
  10386. * Internal only - manager for action
  10387. * @hidden
  10388. */
  10389. _actionManager: ActionManager;
  10390. private _nextActiveAction;
  10391. private _child;
  10392. private _condition?;
  10393. private _triggerParameter;
  10394. /**
  10395. * An event triggered prior to action being executed.
  10396. */
  10397. onBeforeExecuteObservable: Observable<Action>;
  10398. /**
  10399. * Creates a new Action
  10400. * @param triggerOptions the trigger, with or without parameters, for the action
  10401. * @param condition an optional determinant of action
  10402. */
  10403. constructor(
  10404. /** the trigger, with or without parameters, for the action */
  10405. triggerOptions: any, condition?: Condition);
  10406. /**
  10407. * Internal only
  10408. * @hidden
  10409. */
  10410. _prepare(): void;
  10411. /**
  10412. * Gets the trigger parameters
  10413. * @returns the trigger parameters
  10414. */
  10415. getTriggerParameter(): any;
  10416. /**
  10417. * Internal only - executes current action event
  10418. * @hidden
  10419. */
  10420. _executeCurrent(evt?: ActionEvent): void;
  10421. /**
  10422. * Execute placeholder for child classes
  10423. * @param evt optional action event
  10424. */
  10425. execute(evt?: ActionEvent): void;
  10426. /**
  10427. * Skips to next active action
  10428. */
  10429. skipToNextActiveAction(): void;
  10430. /**
  10431. * Adds action to chain of actions, may be a DoNothingAction
  10432. * @param action defines the next action to execute
  10433. * @returns The action passed in
  10434. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10435. */
  10436. then(action: Action): Action;
  10437. /**
  10438. * Internal only
  10439. * @hidden
  10440. */
  10441. _getProperty(propertyPath: string): string;
  10442. /**
  10443. * Internal only
  10444. * @hidden
  10445. */
  10446. _getEffectiveTarget(target: any, propertyPath: string): any;
  10447. /**
  10448. * Serialize placeholder for child classes
  10449. * @param parent of child
  10450. * @returns the serialized object
  10451. */
  10452. serialize(parent: any): any;
  10453. /**
  10454. * Internal only called by serialize
  10455. * @hidden
  10456. */
  10457. protected _serialize(serializedAction: any, parent?: any): any;
  10458. /**
  10459. * Internal only
  10460. * @hidden
  10461. */
  10462. static _SerializeValueAsString: (value: any) => string;
  10463. /**
  10464. * Internal only
  10465. * @hidden
  10466. */
  10467. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10468. name: string;
  10469. targetType: string;
  10470. value: string;
  10471. };
  10472. }
  10473. }
  10474. declare module "babylonjs/Actions/condition" {
  10475. import { ActionManager } from "babylonjs/Actions/actionManager";
  10476. /**
  10477. * A Condition applied to an Action
  10478. */
  10479. export class Condition {
  10480. /**
  10481. * Internal only - manager for action
  10482. * @hidden
  10483. */
  10484. _actionManager: ActionManager;
  10485. /**
  10486. * Internal only
  10487. * @hidden
  10488. */
  10489. _evaluationId: number;
  10490. /**
  10491. * Internal only
  10492. * @hidden
  10493. */
  10494. _currentResult: boolean;
  10495. /**
  10496. * Creates a new Condition
  10497. * @param actionManager the manager of the action the condition is applied to
  10498. */
  10499. constructor(actionManager: ActionManager);
  10500. /**
  10501. * Check if the current condition is valid
  10502. * @returns a boolean
  10503. */
  10504. isValid(): boolean;
  10505. /**
  10506. * Internal only
  10507. * @hidden
  10508. */
  10509. _getProperty(propertyPath: string): string;
  10510. /**
  10511. * Internal only
  10512. * @hidden
  10513. */
  10514. _getEffectiveTarget(target: any, propertyPath: string): any;
  10515. /**
  10516. * Serialize placeholder for child classes
  10517. * @returns the serialized object
  10518. */
  10519. serialize(): any;
  10520. /**
  10521. * Internal only
  10522. * @hidden
  10523. */
  10524. protected _serialize(serializedCondition: any): any;
  10525. }
  10526. /**
  10527. * Defines specific conditional operators as extensions of Condition
  10528. */
  10529. export class ValueCondition extends Condition {
  10530. /** path to specify the property of the target the conditional operator uses */
  10531. propertyPath: string;
  10532. /** the value compared by the conditional operator against the current value of the property */
  10533. value: any;
  10534. /** the conditional operator, default ValueCondition.IsEqual */
  10535. operator: number;
  10536. /**
  10537. * Internal only
  10538. * @hidden
  10539. */
  10540. private static _IsEqual;
  10541. /**
  10542. * Internal only
  10543. * @hidden
  10544. */
  10545. private static _IsDifferent;
  10546. /**
  10547. * Internal only
  10548. * @hidden
  10549. */
  10550. private static _IsGreater;
  10551. /**
  10552. * Internal only
  10553. * @hidden
  10554. */
  10555. private static _IsLesser;
  10556. /**
  10557. * returns the number for IsEqual
  10558. */
  10559. static readonly IsEqual: number;
  10560. /**
  10561. * Returns the number for IsDifferent
  10562. */
  10563. static readonly IsDifferent: number;
  10564. /**
  10565. * Returns the number for IsGreater
  10566. */
  10567. static readonly IsGreater: number;
  10568. /**
  10569. * Returns the number for IsLesser
  10570. */
  10571. static readonly IsLesser: number;
  10572. /**
  10573. * Internal only The action manager for the condition
  10574. * @hidden
  10575. */
  10576. _actionManager: ActionManager;
  10577. /**
  10578. * Internal only
  10579. * @hidden
  10580. */
  10581. private _target;
  10582. /**
  10583. * Internal only
  10584. * @hidden
  10585. */
  10586. private _effectiveTarget;
  10587. /**
  10588. * Internal only
  10589. * @hidden
  10590. */
  10591. private _property;
  10592. /**
  10593. * Creates a new ValueCondition
  10594. * @param actionManager manager for the action the condition applies to
  10595. * @param target for the action
  10596. * @param propertyPath path to specify the property of the target the conditional operator uses
  10597. * @param value the value compared by the conditional operator against the current value of the property
  10598. * @param operator the conditional operator, default ValueCondition.IsEqual
  10599. */
  10600. constructor(actionManager: ActionManager, target: any,
  10601. /** path to specify the property of the target the conditional operator uses */
  10602. propertyPath: string,
  10603. /** the value compared by the conditional operator against the current value of the property */
  10604. value: any,
  10605. /** the conditional operator, default ValueCondition.IsEqual */
  10606. operator?: number);
  10607. /**
  10608. * Compares the given value with the property value for the specified conditional operator
  10609. * @returns the result of the comparison
  10610. */
  10611. isValid(): boolean;
  10612. /**
  10613. * Serialize the ValueCondition into a JSON compatible object
  10614. * @returns serialization object
  10615. */
  10616. serialize(): any;
  10617. /**
  10618. * Gets the name of the conditional operator for the ValueCondition
  10619. * @param operator the conditional operator
  10620. * @returns the name
  10621. */
  10622. static GetOperatorName(operator: number): string;
  10623. }
  10624. /**
  10625. * Defines a predicate condition as an extension of Condition
  10626. */
  10627. export class PredicateCondition extends Condition {
  10628. /** defines the predicate function used to validate the condition */
  10629. predicate: () => boolean;
  10630. /**
  10631. * Internal only - manager for action
  10632. * @hidden
  10633. */
  10634. _actionManager: ActionManager;
  10635. /**
  10636. * Creates a new PredicateCondition
  10637. * @param actionManager manager for the action the condition applies to
  10638. * @param predicate defines the predicate function used to validate the condition
  10639. */
  10640. constructor(actionManager: ActionManager,
  10641. /** defines the predicate function used to validate the condition */
  10642. predicate: () => boolean);
  10643. /**
  10644. * @returns the validity of the predicate condition
  10645. */
  10646. isValid(): boolean;
  10647. }
  10648. /**
  10649. * Defines a state condition as an extension of Condition
  10650. */
  10651. export class StateCondition extends Condition {
  10652. /** Value to compare with target state */
  10653. value: string;
  10654. /**
  10655. * Internal only - manager for action
  10656. * @hidden
  10657. */
  10658. _actionManager: ActionManager;
  10659. /**
  10660. * Internal only
  10661. * @hidden
  10662. */
  10663. private _target;
  10664. /**
  10665. * Creates a new StateCondition
  10666. * @param actionManager manager for the action the condition applies to
  10667. * @param target of the condition
  10668. * @param value to compare with target state
  10669. */
  10670. constructor(actionManager: ActionManager, target: any,
  10671. /** Value to compare with target state */
  10672. value: string);
  10673. /**
  10674. * Gets a boolean indicating if the current condition is met
  10675. * @returns the validity of the state
  10676. */
  10677. isValid(): boolean;
  10678. /**
  10679. * Serialize the StateCondition into a JSON compatible object
  10680. * @returns serialization object
  10681. */
  10682. serialize(): any;
  10683. }
  10684. }
  10685. declare module "babylonjs/Actions/directActions" {
  10686. import { Action } from "babylonjs/Actions/action";
  10687. import { Condition } from "babylonjs/Actions/condition";
  10688. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10689. /**
  10690. * This defines an action responsible to toggle a boolean once triggered.
  10691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10692. */
  10693. export class SwitchBooleanAction extends Action {
  10694. /**
  10695. * The path to the boolean property in the target object
  10696. */
  10697. propertyPath: string;
  10698. private _target;
  10699. private _effectiveTarget;
  10700. private _property;
  10701. /**
  10702. * Instantiate the action
  10703. * @param triggerOptions defines the trigger options
  10704. * @param target defines the object containing the boolean
  10705. * @param propertyPath defines the path to the boolean property in the target object
  10706. * @param condition defines the trigger related conditions
  10707. */
  10708. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10709. /** @hidden */
  10710. _prepare(): void;
  10711. /**
  10712. * Execute the action toggle the boolean value.
  10713. */
  10714. execute(): void;
  10715. /**
  10716. * Serializes the actions and its related information.
  10717. * @param parent defines the object to serialize in
  10718. * @returns the serialized object
  10719. */
  10720. serialize(parent: any): any;
  10721. }
  10722. /**
  10723. * This defines an action responsible to set a the state field of the target
  10724. * to a desired value once triggered.
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10726. */
  10727. export class SetStateAction extends Action {
  10728. /**
  10729. * The value to store in the state field.
  10730. */
  10731. value: string;
  10732. private _target;
  10733. /**
  10734. * Instantiate the action
  10735. * @param triggerOptions defines the trigger options
  10736. * @param target defines the object containing the state property
  10737. * @param value defines the value to store in the state field
  10738. * @param condition defines the trigger related conditions
  10739. */
  10740. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10741. /**
  10742. * Execute the action and store the value on the target state property.
  10743. */
  10744. execute(): void;
  10745. /**
  10746. * Serializes the actions and its related information.
  10747. * @param parent defines the object to serialize in
  10748. * @returns the serialized object
  10749. */
  10750. serialize(parent: any): any;
  10751. }
  10752. /**
  10753. * This defines an action responsible to set a property of the target
  10754. * to a desired value once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class SetValueAction extends Action {
  10758. /**
  10759. * The path of the property to set in the target.
  10760. */
  10761. propertyPath: string;
  10762. /**
  10763. * The value to set in the property
  10764. */
  10765. value: any;
  10766. private _target;
  10767. private _effectiveTarget;
  10768. private _property;
  10769. /**
  10770. * Instantiate the action
  10771. * @param triggerOptions defines the trigger options
  10772. * @param target defines the object containing the property
  10773. * @param propertyPath defines the path of the property to set in the target
  10774. * @param value defines the value to set in the property
  10775. * @param condition defines the trigger related conditions
  10776. */
  10777. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10778. /** @hidden */
  10779. _prepare(): void;
  10780. /**
  10781. * Execute the action and set the targetted property to the desired value.
  10782. */
  10783. execute(): void;
  10784. /**
  10785. * Serializes the actions and its related information.
  10786. * @param parent defines the object to serialize in
  10787. * @returns the serialized object
  10788. */
  10789. serialize(parent: any): any;
  10790. }
  10791. /**
  10792. * This defines an action responsible to increment the target value
  10793. * to a desired value once triggered.
  10794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10795. */
  10796. export class IncrementValueAction extends Action {
  10797. /**
  10798. * The path of the property to increment in the target.
  10799. */
  10800. propertyPath: string;
  10801. /**
  10802. * The value we should increment the property by.
  10803. */
  10804. value: any;
  10805. private _target;
  10806. private _effectiveTarget;
  10807. private _property;
  10808. /**
  10809. * Instantiate the action
  10810. * @param triggerOptions defines the trigger options
  10811. * @param target defines the object containing the property
  10812. * @param propertyPath defines the path of the property to increment in the target
  10813. * @param value defines the value value we should increment the property by
  10814. * @param condition defines the trigger related conditions
  10815. */
  10816. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10817. /** @hidden */
  10818. _prepare(): void;
  10819. /**
  10820. * Execute the action and increment the target of the value amount.
  10821. */
  10822. execute(): void;
  10823. /**
  10824. * Serializes the actions and its related information.
  10825. * @param parent defines the object to serialize in
  10826. * @returns the serialized object
  10827. */
  10828. serialize(parent: any): any;
  10829. }
  10830. /**
  10831. * This defines an action responsible to start an animation once triggered.
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10833. */
  10834. export class PlayAnimationAction extends Action {
  10835. /**
  10836. * Where the animation should start (animation frame)
  10837. */
  10838. from: number;
  10839. /**
  10840. * Where the animation should stop (animation frame)
  10841. */
  10842. to: number;
  10843. /**
  10844. * Define if the animation should loop or stop after the first play.
  10845. */
  10846. loop?: boolean;
  10847. private _target;
  10848. /**
  10849. * Instantiate the action
  10850. * @param triggerOptions defines the trigger options
  10851. * @param target defines the target animation or animation name
  10852. * @param from defines from where the animation should start (animation frame)
  10853. * @param end defines where the animation should stop (animation frame)
  10854. * @param loop defines if the animation should loop or stop after the first play
  10855. * @param condition defines the trigger related conditions
  10856. */
  10857. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10858. /** @hidden */
  10859. _prepare(): void;
  10860. /**
  10861. * Execute the action and play the animation.
  10862. */
  10863. execute(): void;
  10864. /**
  10865. * Serializes the actions and its related information.
  10866. * @param parent defines the object to serialize in
  10867. * @returns the serialized object
  10868. */
  10869. serialize(parent: any): any;
  10870. }
  10871. /**
  10872. * This defines an action responsible to stop an animation once triggered.
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10874. */
  10875. export class StopAnimationAction extends Action {
  10876. private _target;
  10877. /**
  10878. * Instantiate the action
  10879. * @param triggerOptions defines the trigger options
  10880. * @param target defines the target animation or animation name
  10881. * @param condition defines the trigger related conditions
  10882. */
  10883. constructor(triggerOptions: any, target: any, condition?: Condition);
  10884. /** @hidden */
  10885. _prepare(): void;
  10886. /**
  10887. * Execute the action and stop the animation.
  10888. */
  10889. execute(): void;
  10890. /**
  10891. * Serializes the actions and its related information.
  10892. * @param parent defines the object to serialize in
  10893. * @returns the serialized object
  10894. */
  10895. serialize(parent: any): any;
  10896. }
  10897. /**
  10898. * This defines an action responsible that does nothing once triggered.
  10899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10900. */
  10901. export class DoNothingAction extends Action {
  10902. /**
  10903. * Instantiate the action
  10904. * @param triggerOptions defines the trigger options
  10905. * @param condition defines the trigger related conditions
  10906. */
  10907. constructor(triggerOptions?: any, condition?: Condition);
  10908. /**
  10909. * Execute the action and do nothing.
  10910. */
  10911. execute(): void;
  10912. /**
  10913. * Serializes the actions and its related information.
  10914. * @param parent defines the object to serialize in
  10915. * @returns the serialized object
  10916. */
  10917. serialize(parent: any): any;
  10918. }
  10919. /**
  10920. * This defines an action responsible to trigger several actions once triggered.
  10921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10922. */
  10923. export class CombineAction extends Action {
  10924. /**
  10925. * The list of aggregated animations to run.
  10926. */
  10927. children: Action[];
  10928. /**
  10929. * Instantiate the action
  10930. * @param triggerOptions defines the trigger options
  10931. * @param children defines the list of aggregated animations to run
  10932. * @param condition defines the trigger related conditions
  10933. */
  10934. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10935. /** @hidden */
  10936. _prepare(): void;
  10937. /**
  10938. * Execute the action and executes all the aggregated actions.
  10939. */
  10940. execute(evt: ActionEvent): void;
  10941. /**
  10942. * Serializes the actions and its related information.
  10943. * @param parent defines the object to serialize in
  10944. * @returns the serialized object
  10945. */
  10946. serialize(parent: any): any;
  10947. }
  10948. /**
  10949. * This defines an action responsible to run code (external event) once triggered.
  10950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10951. */
  10952. export class ExecuteCodeAction extends Action {
  10953. /**
  10954. * The callback function to run.
  10955. */
  10956. func: (evt: ActionEvent) => void;
  10957. /**
  10958. * Instantiate the action
  10959. * @param triggerOptions defines the trigger options
  10960. * @param func defines the callback function to run
  10961. * @param condition defines the trigger related conditions
  10962. */
  10963. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10964. /**
  10965. * Execute the action and run the attached code.
  10966. */
  10967. execute(evt: ActionEvent): void;
  10968. }
  10969. /**
  10970. * This defines an action responsible to set the parent property of the target once triggered.
  10971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10972. */
  10973. export class SetParentAction extends Action {
  10974. private _parent;
  10975. private _target;
  10976. /**
  10977. * Instantiate the action
  10978. * @param triggerOptions defines the trigger options
  10979. * @param target defines the target containing the parent property
  10980. * @param parent defines from where the animation should start (animation frame)
  10981. * @param condition defines the trigger related conditions
  10982. */
  10983. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10984. /** @hidden */
  10985. _prepare(): void;
  10986. /**
  10987. * Execute the action and set the parent property.
  10988. */
  10989. execute(): void;
  10990. /**
  10991. * Serializes the actions and its related information.
  10992. * @param parent defines the object to serialize in
  10993. * @returns the serialized object
  10994. */
  10995. serialize(parent: any): any;
  10996. }
  10997. }
  10998. declare module "babylonjs/Actions/actionManager" {
  10999. import { Nullable } from "babylonjs/types";
  11000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11001. import { Scene } from "babylonjs/scene";
  11002. import { Action } from "babylonjs/Actions/action";
  11003. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11004. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11005. /**
  11006. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11007. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11009. */
  11010. export class ActionManager extends AbstractActionManager {
  11011. /**
  11012. * Nothing
  11013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11014. */
  11015. static readonly NothingTrigger: number;
  11016. /**
  11017. * On pick
  11018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11019. */
  11020. static readonly OnPickTrigger: number;
  11021. /**
  11022. * On left pick
  11023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11024. */
  11025. static readonly OnLeftPickTrigger: number;
  11026. /**
  11027. * On right pick
  11028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11029. */
  11030. static readonly OnRightPickTrigger: number;
  11031. /**
  11032. * On center pick
  11033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11034. */
  11035. static readonly OnCenterPickTrigger: number;
  11036. /**
  11037. * On pick down
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11039. */
  11040. static readonly OnPickDownTrigger: number;
  11041. /**
  11042. * On double pick
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11044. */
  11045. static readonly OnDoublePickTrigger: number;
  11046. /**
  11047. * On pick up
  11048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11049. */
  11050. static readonly OnPickUpTrigger: number;
  11051. /**
  11052. * On pick out.
  11053. * This trigger will only be raised if you also declared a OnPickDown
  11054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11055. */
  11056. static readonly OnPickOutTrigger: number;
  11057. /**
  11058. * On long press
  11059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11060. */
  11061. static readonly OnLongPressTrigger: number;
  11062. /**
  11063. * On pointer over
  11064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11065. */
  11066. static readonly OnPointerOverTrigger: number;
  11067. /**
  11068. * On pointer out
  11069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11070. */
  11071. static readonly OnPointerOutTrigger: number;
  11072. /**
  11073. * On every frame
  11074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11075. */
  11076. static readonly OnEveryFrameTrigger: number;
  11077. /**
  11078. * On intersection enter
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11080. */
  11081. static readonly OnIntersectionEnterTrigger: number;
  11082. /**
  11083. * On intersection exit
  11084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11085. */
  11086. static readonly OnIntersectionExitTrigger: number;
  11087. /**
  11088. * On key down
  11089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11090. */
  11091. static readonly OnKeyDownTrigger: number;
  11092. /**
  11093. * On key up
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11095. */
  11096. static readonly OnKeyUpTrigger: number;
  11097. private _scene;
  11098. /**
  11099. * Creates a new action manager
  11100. * @param scene defines the hosting scene
  11101. */
  11102. constructor(scene: Scene);
  11103. /**
  11104. * Releases all associated resources
  11105. */
  11106. dispose(): void;
  11107. /**
  11108. * Gets hosting scene
  11109. * @returns the hosting scene
  11110. */
  11111. getScene(): Scene;
  11112. /**
  11113. * Does this action manager handles actions of any of the given triggers
  11114. * @param triggers defines the triggers to be tested
  11115. * @return a boolean indicating whether one (or more) of the triggers is handled
  11116. */
  11117. hasSpecificTriggers(triggers: number[]): boolean;
  11118. /**
  11119. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11120. * speed.
  11121. * @param triggerA defines the trigger to be tested
  11122. * @param triggerB defines the trigger to be tested
  11123. * @return a boolean indicating whether one (or more) of the triggers is handled
  11124. */
  11125. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11126. /**
  11127. * Does this action manager handles actions of a given trigger
  11128. * @param trigger defines the trigger to be tested
  11129. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11130. * @return whether the trigger is handled
  11131. */
  11132. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11133. /**
  11134. * Does this action manager has pointer triggers
  11135. */
  11136. readonly hasPointerTriggers: boolean;
  11137. /**
  11138. * Does this action manager has pick triggers
  11139. */
  11140. readonly hasPickTriggers: boolean;
  11141. /**
  11142. * Registers an action to this action manager
  11143. * @param action defines the action to be registered
  11144. * @return the action amended (prepared) after registration
  11145. */
  11146. registerAction(action: Action): Nullable<Action>;
  11147. /**
  11148. * Unregisters an action to this action manager
  11149. * @param action defines the action to be unregistered
  11150. * @return a boolean indicating whether the action has been unregistered
  11151. */
  11152. unregisterAction(action: Action): Boolean;
  11153. /**
  11154. * Process a specific trigger
  11155. * @param trigger defines the trigger to process
  11156. * @param evt defines the event details to be processed
  11157. */
  11158. processTrigger(trigger: number, evt?: IActionEvent): void;
  11159. /** @hidden */
  11160. _getEffectiveTarget(target: any, propertyPath: string): any;
  11161. /** @hidden */
  11162. _getProperty(propertyPath: string): string;
  11163. /**
  11164. * Serialize this manager to a JSON object
  11165. * @param name defines the property name to store this manager
  11166. * @returns a JSON representation of this manager
  11167. */
  11168. serialize(name: string): any;
  11169. /**
  11170. * Creates a new ActionManager from a JSON data
  11171. * @param parsedActions defines the JSON data to read from
  11172. * @param object defines the hosting mesh
  11173. * @param scene defines the hosting scene
  11174. */
  11175. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11176. /**
  11177. * Get a trigger name by index
  11178. * @param trigger defines the trigger index
  11179. * @returns a trigger name
  11180. */
  11181. static GetTriggerName(trigger: number): string;
  11182. }
  11183. }
  11184. declare module "babylonjs/Culling/ray" {
  11185. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11186. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11188. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11189. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11190. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11191. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11192. /**
  11193. * Class representing a ray with position and direction
  11194. */
  11195. export class Ray {
  11196. /** origin point */
  11197. origin: Vector3;
  11198. /** direction */
  11199. direction: Vector3;
  11200. /** length of the ray */
  11201. length: number;
  11202. private static readonly TmpVector3;
  11203. private _tmpRay;
  11204. /**
  11205. * Creates a new ray
  11206. * @param origin origin point
  11207. * @param direction direction
  11208. * @param length length of the ray
  11209. */
  11210. constructor(
  11211. /** origin point */
  11212. origin: Vector3,
  11213. /** direction */
  11214. direction: Vector3,
  11215. /** length of the ray */
  11216. length?: number);
  11217. /**
  11218. * Checks if the ray intersects a box
  11219. * @param minimum bound of the box
  11220. * @param maximum bound of the box
  11221. * @param intersectionTreshold extra extend to be added to the box in all direction
  11222. * @returns if the box was hit
  11223. */
  11224. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11225. /**
  11226. * Checks if the ray intersects a box
  11227. * @param box the bounding box to check
  11228. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11229. * @returns if the box was hit
  11230. */
  11231. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11232. /**
  11233. * If the ray hits a sphere
  11234. * @param sphere the bounding sphere to check
  11235. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11236. * @returns true if it hits the sphere
  11237. */
  11238. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11239. /**
  11240. * If the ray hits a triange
  11241. * @param vertex0 triangle vertex
  11242. * @param vertex1 triangle vertex
  11243. * @param vertex2 triangle vertex
  11244. * @returns intersection information if hit
  11245. */
  11246. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11247. /**
  11248. * Checks if ray intersects a plane
  11249. * @param plane the plane to check
  11250. * @returns the distance away it was hit
  11251. */
  11252. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11253. /**
  11254. * Checks if ray intersects a mesh
  11255. * @param mesh the mesh to check
  11256. * @param fastCheck if only the bounding box should checked
  11257. * @returns picking info of the intersecton
  11258. */
  11259. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11260. /**
  11261. * Checks if ray intersects a mesh
  11262. * @param meshes the meshes to check
  11263. * @param fastCheck if only the bounding box should checked
  11264. * @param results array to store result in
  11265. * @returns Array of picking infos
  11266. */
  11267. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11268. private _comparePickingInfo;
  11269. private static smallnum;
  11270. private static rayl;
  11271. /**
  11272. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11273. * @param sega the first point of the segment to test the intersection against
  11274. * @param segb the second point of the segment to test the intersection against
  11275. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11276. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11277. */
  11278. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11279. /**
  11280. * Update the ray from viewport position
  11281. * @param x position
  11282. * @param y y position
  11283. * @param viewportWidth viewport width
  11284. * @param viewportHeight viewport height
  11285. * @param world world matrix
  11286. * @param view view matrix
  11287. * @param projection projection matrix
  11288. * @returns this ray updated
  11289. */
  11290. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11291. /**
  11292. * Creates a ray with origin and direction of 0,0,0
  11293. * @returns the new ray
  11294. */
  11295. static Zero(): Ray;
  11296. /**
  11297. * Creates a new ray from screen space and viewport
  11298. * @param x position
  11299. * @param y y position
  11300. * @param viewportWidth viewport width
  11301. * @param viewportHeight viewport height
  11302. * @param world world matrix
  11303. * @param view view matrix
  11304. * @param projection projection matrix
  11305. * @returns new ray
  11306. */
  11307. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11308. /**
  11309. * 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
  11310. * transformed to the given world matrix.
  11311. * @param origin The origin point
  11312. * @param end The end point
  11313. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11314. * @returns the new ray
  11315. */
  11316. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11317. /**
  11318. * Transforms a ray by a matrix
  11319. * @param ray ray to transform
  11320. * @param matrix matrix to apply
  11321. * @returns the resulting new ray
  11322. */
  11323. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11324. /**
  11325. * Transforms a ray by a matrix
  11326. * @param ray ray to transform
  11327. * @param matrix matrix to apply
  11328. * @param result ray to store result in
  11329. */
  11330. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11331. /**
  11332. * Unproject a ray from screen space to object space
  11333. * @param sourceX defines the screen space x coordinate to use
  11334. * @param sourceY defines the screen space y coordinate to use
  11335. * @param viewportWidth defines the current width of the viewport
  11336. * @param viewportHeight defines the current height of the viewport
  11337. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11338. * @param view defines the view matrix to use
  11339. * @param projection defines the projection matrix to use
  11340. */
  11341. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11342. }
  11343. /**
  11344. * Type used to define predicate used to select faces when a mesh intersection is detected
  11345. */
  11346. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11347. module "babylonjs/scene" {
  11348. interface Scene {
  11349. /** @hidden */
  11350. _tempPickingRay: Nullable<Ray>;
  11351. /** @hidden */
  11352. _cachedRayForTransform: Ray;
  11353. /** @hidden */
  11354. _pickWithRayInverseMatrix: Matrix;
  11355. /** @hidden */
  11356. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11357. /** @hidden */
  11358. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11359. }
  11360. }
  11361. }
  11362. declare module "babylonjs/sceneComponent" {
  11363. import { Scene } from "babylonjs/scene";
  11364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11365. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11366. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11367. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11368. import { Nullable } from "babylonjs/types";
  11369. import { Camera } from "babylonjs/Cameras/camera";
  11370. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11371. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11372. import { AbstractScene } from "babylonjs/abstractScene";
  11373. /**
  11374. * Groups all the scene component constants in one place to ease maintenance.
  11375. * @hidden
  11376. */
  11377. export class SceneComponentConstants {
  11378. static readonly NAME_EFFECTLAYER: string;
  11379. static readonly NAME_LAYER: string;
  11380. static readonly NAME_LENSFLARESYSTEM: string;
  11381. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11382. static readonly NAME_PARTICLESYSTEM: string;
  11383. static readonly NAME_GAMEPAD: string;
  11384. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11385. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11386. static readonly NAME_DEPTHRENDERER: string;
  11387. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11388. static readonly NAME_SPRITE: string;
  11389. static readonly NAME_OUTLINERENDERER: string;
  11390. static readonly NAME_PROCEDURALTEXTURE: string;
  11391. static readonly NAME_SHADOWGENERATOR: string;
  11392. static readonly NAME_OCTREE: string;
  11393. static readonly NAME_PHYSICSENGINE: string;
  11394. static readonly NAME_AUDIO: string;
  11395. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11396. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11397. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11398. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11399. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11400. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11401. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11402. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11403. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11404. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11405. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11406. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11407. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11408. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11409. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11410. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11411. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11412. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11413. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11414. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11415. static readonly STEP_AFTERRENDER_AUDIO: number;
  11416. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11417. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11418. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11419. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11420. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11421. static readonly STEP_POINTERMOVE_SPRITE: number;
  11422. static readonly STEP_POINTERDOWN_SPRITE: number;
  11423. static readonly STEP_POINTERUP_SPRITE: number;
  11424. }
  11425. /**
  11426. * This represents a scene component.
  11427. *
  11428. * This is used to decouple the dependency the scene is having on the different workloads like
  11429. * layers, post processes...
  11430. */
  11431. export interface ISceneComponent {
  11432. /**
  11433. * The name of the component. Each component must have a unique name.
  11434. */
  11435. name: string;
  11436. /**
  11437. * The scene the component belongs to.
  11438. */
  11439. scene: Scene;
  11440. /**
  11441. * Register the component to one instance of a scene.
  11442. */
  11443. register(): void;
  11444. /**
  11445. * Rebuilds the elements related to this component in case of
  11446. * context lost for instance.
  11447. */
  11448. rebuild(): void;
  11449. /**
  11450. * Disposes the component and the associated ressources.
  11451. */
  11452. dispose(): void;
  11453. }
  11454. /**
  11455. * This represents a SERIALIZABLE scene component.
  11456. *
  11457. * This extends Scene Component to add Serialization methods on top.
  11458. */
  11459. export interface ISceneSerializableComponent extends ISceneComponent {
  11460. /**
  11461. * Adds all the element from the container to the scene
  11462. * @param container the container holding the elements
  11463. */
  11464. addFromContainer(container: AbstractScene): void;
  11465. /**
  11466. * Removes all the elements in the container from the scene
  11467. * @param container contains the elements to remove
  11468. */
  11469. removeFromContainer(container: AbstractScene): void;
  11470. /**
  11471. * Serializes the component data to the specified json object
  11472. * @param serializationObject The object to serialize to
  11473. */
  11474. serialize(serializationObject: any): void;
  11475. }
  11476. /**
  11477. * Strong typing of a Mesh related stage step action
  11478. */
  11479. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11480. /**
  11481. * Strong typing of a Evaluate Sub Mesh related stage step action
  11482. */
  11483. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11484. /**
  11485. * Strong typing of a Active Mesh related stage step action
  11486. */
  11487. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11488. /**
  11489. * Strong typing of a Camera related stage step action
  11490. */
  11491. export type CameraStageAction = (camera: Camera) => void;
  11492. /**
  11493. * Strong typing of a Render Target related stage step action
  11494. */
  11495. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11496. /**
  11497. * Strong typing of a RenderingGroup related stage step action
  11498. */
  11499. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11500. /**
  11501. * Strong typing of a Mesh Render related stage step action
  11502. */
  11503. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11504. /**
  11505. * Strong typing of a simple stage step action
  11506. */
  11507. export type SimpleStageAction = () => void;
  11508. /**
  11509. * Strong typing of a render target action.
  11510. */
  11511. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11512. /**
  11513. * Strong typing of a pointer move action.
  11514. */
  11515. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11516. /**
  11517. * Strong typing of a pointer up/down action.
  11518. */
  11519. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11520. /**
  11521. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11522. * @hidden
  11523. */
  11524. export class Stage<T extends Function> extends Array<{
  11525. index: number;
  11526. component: ISceneComponent;
  11527. action: T;
  11528. }> {
  11529. /**
  11530. * Hide ctor from the rest of the world.
  11531. * @param items The items to add.
  11532. */
  11533. private constructor();
  11534. /**
  11535. * Creates a new Stage.
  11536. * @returns A new instance of a Stage
  11537. */
  11538. static Create<T extends Function>(): Stage<T>;
  11539. /**
  11540. * Registers a step in an ordered way in the targeted stage.
  11541. * @param index Defines the position to register the step in
  11542. * @param component Defines the component attached to the step
  11543. * @param action Defines the action to launch during the step
  11544. */
  11545. registerStep(index: number, component: ISceneComponent, action: T): void;
  11546. /**
  11547. * Clears all the steps from the stage.
  11548. */
  11549. clear(): void;
  11550. }
  11551. }
  11552. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11553. import { Nullable } from "babylonjs/types";
  11554. import { Observable } from "babylonjs/Misc/observable";
  11555. import { Scene } from "babylonjs/scene";
  11556. import { Sprite } from "babylonjs/Sprites/sprite";
  11557. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11558. import { Ray } from "babylonjs/Culling/ray";
  11559. import { Camera } from "babylonjs/Cameras/camera";
  11560. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11561. import { ISceneComponent } from "babylonjs/sceneComponent";
  11562. module "babylonjs/scene" {
  11563. interface Scene {
  11564. /** @hidden */
  11565. _pointerOverSprite: Nullable<Sprite>;
  11566. /** @hidden */
  11567. _pickedDownSprite: Nullable<Sprite>;
  11568. /** @hidden */
  11569. _tempSpritePickingRay: Nullable<Ray>;
  11570. /**
  11571. * All of the sprite managers added to this scene
  11572. * @see http://doc.babylonjs.com/babylon101/sprites
  11573. */
  11574. spriteManagers: Array<ISpriteManager>;
  11575. /**
  11576. * An event triggered when sprites rendering is about to start
  11577. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11578. */
  11579. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11580. /**
  11581. * An event triggered when sprites rendering is done
  11582. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11583. */
  11584. onAfterSpritesRenderingObservable: Observable<Scene>;
  11585. /** @hidden */
  11586. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11587. /** Launch a ray to try to pick a sprite in the scene
  11588. * @param x position on screen
  11589. * @param y position on screen
  11590. * @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
  11591. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11592. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11593. * @returns a PickingInfo
  11594. */
  11595. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11596. /** Use the given ray to pick a sprite in the scene
  11597. * @param ray The ray (in world space) to use to pick meshes
  11598. * @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
  11599. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11600. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11601. * @returns a PickingInfo
  11602. */
  11603. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11604. /**
  11605. * Force the sprite under the pointer
  11606. * @param sprite defines the sprite to use
  11607. */
  11608. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11609. /**
  11610. * Gets the sprite under the pointer
  11611. * @returns a Sprite or null if no sprite is under the pointer
  11612. */
  11613. getPointerOverSprite(): Nullable<Sprite>;
  11614. }
  11615. }
  11616. /**
  11617. * Defines the sprite scene component responsible to manage sprites
  11618. * in a given scene.
  11619. */
  11620. export class SpriteSceneComponent implements ISceneComponent {
  11621. /**
  11622. * The component name helpfull to identify the component in the list of scene components.
  11623. */
  11624. readonly name: string;
  11625. /**
  11626. * The scene the component belongs to.
  11627. */
  11628. scene: Scene;
  11629. /** @hidden */
  11630. private _spritePredicate;
  11631. /**
  11632. * Creates a new instance of the component for the given scene
  11633. * @param scene Defines the scene to register the component in
  11634. */
  11635. constructor(scene: Scene);
  11636. /**
  11637. * Registers the component in a given scene
  11638. */
  11639. register(): void;
  11640. /**
  11641. * Rebuilds the elements related to this component in case of
  11642. * context lost for instance.
  11643. */
  11644. rebuild(): void;
  11645. /**
  11646. * Disposes the component and the associated ressources.
  11647. */
  11648. dispose(): void;
  11649. private _pickSpriteButKeepRay;
  11650. private _pointerMove;
  11651. private _pointerDown;
  11652. private _pointerUp;
  11653. }
  11654. }
  11655. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11656. /** @hidden */
  11657. export var fogFragmentDeclaration: {
  11658. name: string;
  11659. shader: string;
  11660. };
  11661. }
  11662. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11663. /** @hidden */
  11664. export var fogFragment: {
  11665. name: string;
  11666. shader: string;
  11667. };
  11668. }
  11669. declare module "babylonjs/Shaders/sprites.fragment" {
  11670. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11671. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11672. /** @hidden */
  11673. export var spritesPixelShader: {
  11674. name: string;
  11675. shader: string;
  11676. };
  11677. }
  11678. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11679. /** @hidden */
  11680. export var fogVertexDeclaration: {
  11681. name: string;
  11682. shader: string;
  11683. };
  11684. }
  11685. declare module "babylonjs/Shaders/sprites.vertex" {
  11686. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11687. /** @hidden */
  11688. export var spritesVertexShader: {
  11689. name: string;
  11690. shader: string;
  11691. };
  11692. }
  11693. declare module "babylonjs/Sprites/spriteManager" {
  11694. import { IDisposable, Scene } from "babylonjs/scene";
  11695. import { Nullable } from "babylonjs/types";
  11696. import { Observable } from "babylonjs/Misc/observable";
  11697. import { Sprite } from "babylonjs/Sprites/sprite";
  11698. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11699. import { Camera } from "babylonjs/Cameras/camera";
  11700. import { Texture } from "babylonjs/Materials/Textures/texture";
  11701. import "babylonjs/Shaders/sprites.fragment";
  11702. import "babylonjs/Shaders/sprites.vertex";
  11703. import { Ray } from "babylonjs/Culling/ray";
  11704. /**
  11705. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11706. */
  11707. export interface ISpriteManager extends IDisposable {
  11708. /**
  11709. * Restricts the camera to viewing objects with the same layerMask.
  11710. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11711. */
  11712. layerMask: number;
  11713. /**
  11714. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11715. */
  11716. isPickable: boolean;
  11717. /**
  11718. * Specifies the rendering group id for this mesh (0 by default)
  11719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11720. */
  11721. renderingGroupId: number;
  11722. /**
  11723. * Defines the list of sprites managed by the manager.
  11724. */
  11725. sprites: Array<Sprite>;
  11726. /**
  11727. * Tests the intersection of a sprite with a specific ray.
  11728. * @param ray The ray we are sending to test the collision
  11729. * @param camera The camera space we are sending rays in
  11730. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11731. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11732. * @returns picking info or null.
  11733. */
  11734. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11735. /**
  11736. * Renders the list of sprites on screen.
  11737. */
  11738. render(): void;
  11739. }
  11740. /**
  11741. * Class used to manage multiple sprites on the same spritesheet
  11742. * @see http://doc.babylonjs.com/babylon101/sprites
  11743. */
  11744. export class SpriteManager implements ISpriteManager {
  11745. /** defines the manager's name */
  11746. name: string;
  11747. /** Gets the list of sprites */
  11748. sprites: Sprite[];
  11749. /** Gets or sets the rendering group id (0 by default) */
  11750. renderingGroupId: number;
  11751. /** Gets or sets camera layer mask */
  11752. layerMask: number;
  11753. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11754. fogEnabled: boolean;
  11755. /** Gets or sets a boolean indicating if the sprites are pickable */
  11756. isPickable: boolean;
  11757. /** Defines the default width of a cell in the spritesheet */
  11758. cellWidth: number;
  11759. /** Defines the default height of a cell in the spritesheet */
  11760. cellHeight: number;
  11761. /**
  11762. * An event triggered when the manager is disposed.
  11763. */
  11764. onDisposeObservable: Observable<SpriteManager>;
  11765. private _onDisposeObserver;
  11766. /**
  11767. * Callback called when the manager is disposed
  11768. */
  11769. onDispose: () => void;
  11770. private _capacity;
  11771. private _spriteTexture;
  11772. private _epsilon;
  11773. private _scene;
  11774. private _vertexData;
  11775. private _buffer;
  11776. private _vertexBuffers;
  11777. private _indexBuffer;
  11778. private _effectBase;
  11779. private _effectFog;
  11780. /**
  11781. * Gets or sets the spritesheet texture
  11782. */
  11783. texture: Texture;
  11784. /**
  11785. * Creates a new sprite manager
  11786. * @param name defines the manager's name
  11787. * @param imgUrl defines the sprite sheet url
  11788. * @param capacity defines the maximum allowed number of sprites
  11789. * @param cellSize defines the size of a sprite cell
  11790. * @param scene defines the hosting scene
  11791. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11792. * @param samplingMode defines the smapling mode to use with spritesheet
  11793. */
  11794. constructor(
  11795. /** defines the manager's name */
  11796. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11797. private _appendSpriteVertex;
  11798. /**
  11799. * Intersects the sprites with a ray
  11800. * @param ray defines the ray to intersect with
  11801. * @param camera defines the current active camera
  11802. * @param predicate defines a predicate used to select candidate sprites
  11803. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11804. * @returns null if no hit or a PickingInfo
  11805. */
  11806. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11807. /**
  11808. * Render all child sprites
  11809. */
  11810. render(): void;
  11811. /**
  11812. * Release associated resources
  11813. */
  11814. dispose(): void;
  11815. }
  11816. }
  11817. declare module "babylonjs/Sprites/sprite" {
  11818. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11819. import { Nullable } from "babylonjs/types";
  11820. import { ActionManager } from "babylonjs/Actions/actionManager";
  11821. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11822. /**
  11823. * Class used to represent a sprite
  11824. * @see http://doc.babylonjs.com/babylon101/sprites
  11825. */
  11826. export class Sprite {
  11827. /** defines the name */
  11828. name: string;
  11829. /** Gets or sets the current world position */
  11830. position: Vector3;
  11831. /** Gets or sets the main color */
  11832. color: Color4;
  11833. /** Gets or sets the width */
  11834. width: number;
  11835. /** Gets or sets the height */
  11836. height: number;
  11837. /** Gets or sets rotation angle */
  11838. angle: number;
  11839. /** Gets or sets the cell index in the sprite sheet */
  11840. cellIndex: number;
  11841. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11842. invertU: number;
  11843. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11844. invertV: number;
  11845. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11846. disposeWhenFinishedAnimating: boolean;
  11847. /** Gets the list of attached animations */
  11848. animations: Animation[];
  11849. /** Gets or sets a boolean indicating if the sprite can be picked */
  11850. isPickable: boolean;
  11851. /**
  11852. * Gets or sets the associated action manager
  11853. */
  11854. actionManager: Nullable<ActionManager>;
  11855. private _animationStarted;
  11856. private _loopAnimation;
  11857. private _fromIndex;
  11858. private _toIndex;
  11859. private _delay;
  11860. private _direction;
  11861. private _manager;
  11862. private _time;
  11863. private _onAnimationEnd;
  11864. /**
  11865. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11866. */
  11867. isVisible: boolean;
  11868. /**
  11869. * Gets or sets the sprite size
  11870. */
  11871. size: number;
  11872. /**
  11873. * Creates a new Sprite
  11874. * @param name defines the name
  11875. * @param manager defines the manager
  11876. */
  11877. constructor(
  11878. /** defines the name */
  11879. name: string, manager: ISpriteManager);
  11880. /**
  11881. * Starts an animation
  11882. * @param from defines the initial key
  11883. * @param to defines the end key
  11884. * @param loop defines if the animation must loop
  11885. * @param delay defines the start delay (in ms)
  11886. * @param onAnimationEnd defines a callback to call when animation ends
  11887. */
  11888. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11889. /** Stops current animation (if any) */
  11890. stopAnimation(): void;
  11891. /** @hidden */
  11892. _animate(deltaTime: number): void;
  11893. /** Release associated resources */
  11894. dispose(): void;
  11895. }
  11896. }
  11897. declare module "babylonjs/Collisions/pickingInfo" {
  11898. import { Nullable } from "babylonjs/types";
  11899. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11901. import { Sprite } from "babylonjs/Sprites/sprite";
  11902. import { Ray } from "babylonjs/Culling/ray";
  11903. /**
  11904. * Information about the result of picking within a scene
  11905. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11906. */
  11907. export class PickingInfo {
  11908. /** @hidden */
  11909. _pickingUnavailable: boolean;
  11910. /**
  11911. * If the pick collided with an object
  11912. */
  11913. hit: boolean;
  11914. /**
  11915. * Distance away where the pick collided
  11916. */
  11917. distance: number;
  11918. /**
  11919. * The location of pick collision
  11920. */
  11921. pickedPoint: Nullable<Vector3>;
  11922. /**
  11923. * The mesh corresponding the the pick collision
  11924. */
  11925. pickedMesh: Nullable<AbstractMesh>;
  11926. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11927. bu: number;
  11928. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11929. bv: number;
  11930. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11931. faceId: number;
  11932. /** Id of the the submesh that was picked */
  11933. subMeshId: number;
  11934. /** If a sprite was picked, this will be the sprite the pick collided with */
  11935. pickedSprite: Nullable<Sprite>;
  11936. /**
  11937. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11938. */
  11939. originMesh: Nullable<AbstractMesh>;
  11940. /**
  11941. * The ray that was used to perform the picking.
  11942. */
  11943. ray: Nullable<Ray>;
  11944. /**
  11945. * Gets the normal correspodning to the face the pick collided with
  11946. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11947. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11948. * @returns The normal correspodning to the face the pick collided with
  11949. */
  11950. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11951. /**
  11952. * Gets the texture coordinates of where the pick occured
  11953. * @returns the vector containing the coordnates of the texture
  11954. */
  11955. getTextureCoordinates(): Nullable<Vector2>;
  11956. }
  11957. }
  11958. declare module "babylonjs/Events/pointerEvents" {
  11959. import { Nullable } from "babylonjs/types";
  11960. import { Vector2 } from "babylonjs/Maths/math";
  11961. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11962. import { Ray } from "babylonjs/Culling/ray";
  11963. /**
  11964. * Gather the list of pointer event types as constants.
  11965. */
  11966. export class PointerEventTypes {
  11967. /**
  11968. * 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.
  11969. */
  11970. static readonly POINTERDOWN: number;
  11971. /**
  11972. * The pointerup event is fired when a pointer is no longer active.
  11973. */
  11974. static readonly POINTERUP: number;
  11975. /**
  11976. * The pointermove event is fired when a pointer changes coordinates.
  11977. */
  11978. static readonly POINTERMOVE: number;
  11979. /**
  11980. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11981. */
  11982. static readonly POINTERWHEEL: number;
  11983. /**
  11984. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11985. */
  11986. static readonly POINTERPICK: number;
  11987. /**
  11988. * The pointertap event is fired when a the object has been touched and released without drag.
  11989. */
  11990. static readonly POINTERTAP: number;
  11991. /**
  11992. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11993. */
  11994. static readonly POINTERDOUBLETAP: number;
  11995. }
  11996. /**
  11997. * Base class of pointer info types.
  11998. */
  11999. export class PointerInfoBase {
  12000. /**
  12001. * Defines the type of event (PointerEventTypes)
  12002. */
  12003. type: number;
  12004. /**
  12005. * Defines the related dom event
  12006. */
  12007. event: PointerEvent | MouseWheelEvent;
  12008. /**
  12009. * Instantiates the base class of pointers info.
  12010. * @param type Defines the type of event (PointerEventTypes)
  12011. * @param event Defines the related dom event
  12012. */
  12013. constructor(
  12014. /**
  12015. * Defines the type of event (PointerEventTypes)
  12016. */
  12017. type: number,
  12018. /**
  12019. * Defines the related dom event
  12020. */
  12021. event: PointerEvent | MouseWheelEvent);
  12022. }
  12023. /**
  12024. * This class is used to store pointer related info for the onPrePointerObservable event.
  12025. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12026. */
  12027. export class PointerInfoPre extends PointerInfoBase {
  12028. /**
  12029. * Ray from a pointer if availible (eg. 6dof controller)
  12030. */
  12031. ray: Nullable<Ray>;
  12032. /**
  12033. * Defines the local position of the pointer on the canvas.
  12034. */
  12035. localPosition: Vector2;
  12036. /**
  12037. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12038. */
  12039. skipOnPointerObservable: boolean;
  12040. /**
  12041. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12042. * @param type Defines the type of event (PointerEventTypes)
  12043. * @param event Defines the related dom event
  12044. * @param localX Defines the local x coordinates of the pointer when the event occured
  12045. * @param localY Defines the local y coordinates of the pointer when the event occured
  12046. */
  12047. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12048. }
  12049. /**
  12050. * This type contains all the data related to a pointer event in Babylon.js.
  12051. * 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.
  12052. */
  12053. export class PointerInfo extends PointerInfoBase {
  12054. /**
  12055. * Defines the picking info associated to the info (if any)\
  12056. */
  12057. pickInfo: Nullable<PickingInfo>;
  12058. /**
  12059. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12060. * @param type Defines the type of event (PointerEventTypes)
  12061. * @param event Defines the related dom event
  12062. * @param pickInfo Defines the picking info associated to the info (if any)\
  12063. */
  12064. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12065. /**
  12066. * Defines the picking info associated to the info (if any)\
  12067. */
  12068. pickInfo: Nullable<PickingInfo>);
  12069. }
  12070. /**
  12071. * Data relating to a touch event on the screen.
  12072. */
  12073. export interface PointerTouch {
  12074. /**
  12075. * X coordinate of touch.
  12076. */
  12077. x: number;
  12078. /**
  12079. * Y coordinate of touch.
  12080. */
  12081. y: number;
  12082. /**
  12083. * Id of touch. Unique for each finger.
  12084. */
  12085. pointerId: number;
  12086. /**
  12087. * Event type passed from DOM.
  12088. */
  12089. type: any;
  12090. }
  12091. }
  12092. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12093. import { Nullable } from "babylonjs/types";
  12094. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12095. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12096. /**
  12097. * Manage the mouse inputs to control the movement of a free camera.
  12098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12099. */
  12100. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12101. /**
  12102. * Define if touch is enabled in the mouse input
  12103. */
  12104. touchEnabled: boolean;
  12105. /**
  12106. * Defines the camera the input is attached to.
  12107. */
  12108. camera: FreeCamera;
  12109. /**
  12110. * Defines the buttons associated with the input to handle camera move.
  12111. */
  12112. buttons: number[];
  12113. /**
  12114. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12115. */
  12116. angularSensibility: number;
  12117. private _pointerInput;
  12118. private _onMouseMove;
  12119. private _observer;
  12120. private previousPosition;
  12121. /**
  12122. * Manage the mouse inputs to control the movement of a free camera.
  12123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12124. * @param touchEnabled Defines if touch is enabled or not
  12125. */
  12126. constructor(
  12127. /**
  12128. * Define if touch is enabled in the mouse input
  12129. */
  12130. touchEnabled?: boolean);
  12131. /**
  12132. * Attach the input controls to a specific dom element to get the input from.
  12133. * @param element Defines the element the controls should be listened from
  12134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12135. */
  12136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12137. /**
  12138. * Detach the current controls from the specified dom element.
  12139. * @param element Defines the element to stop listening the inputs from
  12140. */
  12141. detachControl(element: Nullable<HTMLElement>): void;
  12142. /**
  12143. * Gets the class name of the current intput.
  12144. * @returns the class name
  12145. */
  12146. getClassName(): string;
  12147. /**
  12148. * Get the friendly name associated with the input class.
  12149. * @returns the input friendly name
  12150. */
  12151. getSimpleName(): string;
  12152. }
  12153. }
  12154. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12155. import { Nullable } from "babylonjs/types";
  12156. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12157. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12158. /**
  12159. * Manage the touch inputs to control the movement of a free camera.
  12160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12161. */
  12162. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12163. /**
  12164. * Defines the camera the input is attached to.
  12165. */
  12166. camera: FreeCamera;
  12167. /**
  12168. * Defines the touch sensibility for rotation.
  12169. * The higher the faster.
  12170. */
  12171. touchAngularSensibility: number;
  12172. /**
  12173. * Defines the touch sensibility for move.
  12174. * The higher the faster.
  12175. */
  12176. touchMoveSensibility: number;
  12177. private _offsetX;
  12178. private _offsetY;
  12179. private _pointerPressed;
  12180. private _pointerInput;
  12181. private _observer;
  12182. private _onLostFocus;
  12183. /**
  12184. * Attach the input controls to a specific dom element to get the input from.
  12185. * @param element Defines the element the controls should be listened from
  12186. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12187. */
  12188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12189. /**
  12190. * Detach the current controls from the specified dom element.
  12191. * @param element Defines the element to stop listening the inputs from
  12192. */
  12193. detachControl(element: Nullable<HTMLElement>): void;
  12194. /**
  12195. * Update the current camera state depending on the inputs that have been used this frame.
  12196. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12197. */
  12198. checkInputs(): void;
  12199. /**
  12200. * Gets the class name of the current intput.
  12201. * @returns the class name
  12202. */
  12203. getClassName(): string;
  12204. /**
  12205. * Get the friendly name associated with the input class.
  12206. * @returns the input friendly name
  12207. */
  12208. getSimpleName(): string;
  12209. }
  12210. }
  12211. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12212. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12213. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12214. /**
  12215. * Default Inputs manager for the FreeCamera.
  12216. * It groups all the default supported inputs for ease of use.
  12217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12218. */
  12219. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12220. /**
  12221. * Instantiates a new FreeCameraInputsManager.
  12222. * @param camera Defines the camera the inputs belong to
  12223. */
  12224. constructor(camera: FreeCamera);
  12225. /**
  12226. * Add keyboard input support to the input manager.
  12227. * @returns the current input manager
  12228. */
  12229. addKeyboard(): FreeCameraInputsManager;
  12230. /**
  12231. * Add mouse input support to the input manager.
  12232. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12233. * @returns the current input manager
  12234. */
  12235. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12236. /**
  12237. * Add touch input support to the input manager.
  12238. * @returns the current input manager
  12239. */
  12240. addTouch(): FreeCameraInputsManager;
  12241. }
  12242. }
  12243. declare module "babylonjs/Cameras/freeCamera" {
  12244. import { Vector3 } from "babylonjs/Maths/math";
  12245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12246. import { Scene } from "babylonjs/scene";
  12247. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12248. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12249. /**
  12250. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12251. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12253. */
  12254. export class FreeCamera extends TargetCamera {
  12255. /**
  12256. * Define the collision ellipsoid of the camera.
  12257. * This is helpful to simulate a camera body like the player body around the camera
  12258. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12259. */
  12260. ellipsoid: Vector3;
  12261. /**
  12262. * Define an offset for the position of the ellipsoid around the camera.
  12263. * This can be helpful to determine the center of the body near the gravity center of the body
  12264. * instead of its head.
  12265. */
  12266. ellipsoidOffset: Vector3;
  12267. /**
  12268. * Enable or disable collisions of the camera with the rest of the scene objects.
  12269. */
  12270. checkCollisions: boolean;
  12271. /**
  12272. * Enable or disable gravity on the camera.
  12273. */
  12274. applyGravity: boolean;
  12275. /**
  12276. * Define the input manager associated to the camera.
  12277. */
  12278. inputs: FreeCameraInputsManager;
  12279. /**
  12280. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12281. * Higher values reduce sensitivity.
  12282. */
  12283. /**
  12284. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12285. * Higher values reduce sensitivity.
  12286. */
  12287. angularSensibility: number;
  12288. /**
  12289. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12290. */
  12291. keysUp: number[];
  12292. /**
  12293. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12294. */
  12295. keysDown: number[];
  12296. /**
  12297. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12298. */
  12299. keysLeft: number[];
  12300. /**
  12301. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12302. */
  12303. keysRight: number[];
  12304. /**
  12305. * Event raised when the camera collide with a mesh in the scene.
  12306. */
  12307. onCollide: (collidedMesh: AbstractMesh) => void;
  12308. private _collider;
  12309. private _needMoveForGravity;
  12310. private _oldPosition;
  12311. private _diffPosition;
  12312. private _newPosition;
  12313. /** @hidden */
  12314. _localDirection: Vector3;
  12315. /** @hidden */
  12316. _transformedDirection: Vector3;
  12317. /**
  12318. * Instantiates a Free Camera.
  12319. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12320. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12321. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12322. * @param name Define the name of the camera in the scene
  12323. * @param position Define the start position of the camera in the scene
  12324. * @param scene Define the scene the camera belongs to
  12325. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12326. */
  12327. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12328. /**
  12329. * Attached controls to the current camera.
  12330. * @param element Defines the element the controls should be listened from
  12331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12332. */
  12333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12334. /**
  12335. * Detach the current controls from the camera.
  12336. * The camera will stop reacting to inputs.
  12337. * @param element Defines the element to stop listening the inputs from
  12338. */
  12339. detachControl(element: HTMLElement): void;
  12340. private _collisionMask;
  12341. /**
  12342. * Define a collision mask to limit the list of object the camera can collide with
  12343. */
  12344. collisionMask: number;
  12345. /** @hidden */
  12346. _collideWithWorld(displacement: Vector3): void;
  12347. private _onCollisionPositionChange;
  12348. /** @hidden */
  12349. _checkInputs(): void;
  12350. /** @hidden */
  12351. _decideIfNeedsToMove(): boolean;
  12352. /** @hidden */
  12353. _updatePosition(): void;
  12354. /**
  12355. * Destroy the camera and release the current resources hold by it.
  12356. */
  12357. dispose(): void;
  12358. /**
  12359. * Gets the current object class name.
  12360. * @return the class name
  12361. */
  12362. getClassName(): string;
  12363. }
  12364. }
  12365. declare module "babylonjs/Gamepads/gamepad" {
  12366. import { Observable } from "babylonjs/Misc/observable";
  12367. /**
  12368. * Represents a gamepad control stick position
  12369. */
  12370. export class StickValues {
  12371. /**
  12372. * The x component of the control stick
  12373. */
  12374. x: number;
  12375. /**
  12376. * The y component of the control stick
  12377. */
  12378. y: number;
  12379. /**
  12380. * Initializes the gamepad x and y control stick values
  12381. * @param x The x component of the gamepad control stick value
  12382. * @param y The y component of the gamepad control stick value
  12383. */
  12384. constructor(
  12385. /**
  12386. * The x component of the control stick
  12387. */
  12388. x: number,
  12389. /**
  12390. * The y component of the control stick
  12391. */
  12392. y: number);
  12393. }
  12394. /**
  12395. * An interface which manages callbacks for gamepad button changes
  12396. */
  12397. export interface GamepadButtonChanges {
  12398. /**
  12399. * Called when a gamepad has been changed
  12400. */
  12401. changed: boolean;
  12402. /**
  12403. * Called when a gamepad press event has been triggered
  12404. */
  12405. pressChanged: boolean;
  12406. /**
  12407. * Called when a touch event has been triggered
  12408. */
  12409. touchChanged: boolean;
  12410. /**
  12411. * Called when a value has changed
  12412. */
  12413. valueChanged: boolean;
  12414. }
  12415. /**
  12416. * Represents a gamepad
  12417. */
  12418. export class Gamepad {
  12419. /**
  12420. * The id of the gamepad
  12421. */
  12422. id: string;
  12423. /**
  12424. * The index of the gamepad
  12425. */
  12426. index: number;
  12427. /**
  12428. * The browser gamepad
  12429. */
  12430. browserGamepad: any;
  12431. /**
  12432. * Specifies what type of gamepad this represents
  12433. */
  12434. type: number;
  12435. private _leftStick;
  12436. private _rightStick;
  12437. /** @hidden */
  12438. _isConnected: boolean;
  12439. private _leftStickAxisX;
  12440. private _leftStickAxisY;
  12441. private _rightStickAxisX;
  12442. private _rightStickAxisY;
  12443. /**
  12444. * Triggered when the left control stick has been changed
  12445. */
  12446. private _onleftstickchanged;
  12447. /**
  12448. * Triggered when the right control stick has been changed
  12449. */
  12450. private _onrightstickchanged;
  12451. /**
  12452. * Represents a gamepad controller
  12453. */
  12454. static GAMEPAD: number;
  12455. /**
  12456. * Represents a generic controller
  12457. */
  12458. static GENERIC: number;
  12459. /**
  12460. * Represents an XBox controller
  12461. */
  12462. static XBOX: number;
  12463. /**
  12464. * Represents a pose-enabled controller
  12465. */
  12466. static POSE_ENABLED: number;
  12467. /**
  12468. * Specifies whether the left control stick should be Y-inverted
  12469. */
  12470. protected _invertLeftStickY: boolean;
  12471. /**
  12472. * Specifies if the gamepad has been connected
  12473. */
  12474. readonly isConnected: boolean;
  12475. /**
  12476. * Initializes the gamepad
  12477. * @param id The id of the gamepad
  12478. * @param index The index of the gamepad
  12479. * @param browserGamepad The browser gamepad
  12480. * @param leftStickX The x component of the left joystick
  12481. * @param leftStickY The y component of the left joystick
  12482. * @param rightStickX The x component of the right joystick
  12483. * @param rightStickY The y component of the right joystick
  12484. */
  12485. constructor(
  12486. /**
  12487. * The id of the gamepad
  12488. */
  12489. id: string,
  12490. /**
  12491. * The index of the gamepad
  12492. */
  12493. index: number,
  12494. /**
  12495. * The browser gamepad
  12496. */
  12497. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12498. /**
  12499. * Callback triggered when the left joystick has changed
  12500. * @param callback
  12501. */
  12502. onleftstickchanged(callback: (values: StickValues) => void): void;
  12503. /**
  12504. * Callback triggered when the right joystick has changed
  12505. * @param callback
  12506. */
  12507. onrightstickchanged(callback: (values: StickValues) => void): void;
  12508. /**
  12509. * Gets the left joystick
  12510. */
  12511. /**
  12512. * Sets the left joystick values
  12513. */
  12514. leftStick: StickValues;
  12515. /**
  12516. * Gets the right joystick
  12517. */
  12518. /**
  12519. * Sets the right joystick value
  12520. */
  12521. rightStick: StickValues;
  12522. /**
  12523. * Updates the gamepad joystick positions
  12524. */
  12525. update(): void;
  12526. /**
  12527. * Disposes the gamepad
  12528. */
  12529. dispose(): void;
  12530. }
  12531. /**
  12532. * Represents a generic gamepad
  12533. */
  12534. export class GenericPad extends Gamepad {
  12535. private _buttons;
  12536. private _onbuttondown;
  12537. private _onbuttonup;
  12538. /**
  12539. * Observable triggered when a button has been pressed
  12540. */
  12541. onButtonDownObservable: Observable<number>;
  12542. /**
  12543. * Observable triggered when a button has been released
  12544. */
  12545. onButtonUpObservable: Observable<number>;
  12546. /**
  12547. * Callback triggered when a button has been pressed
  12548. * @param callback Called when a button has been pressed
  12549. */
  12550. onbuttondown(callback: (buttonPressed: number) => void): void;
  12551. /**
  12552. * Callback triggered when a button has been released
  12553. * @param callback Called when a button has been released
  12554. */
  12555. onbuttonup(callback: (buttonReleased: number) => void): void;
  12556. /**
  12557. * Initializes the generic gamepad
  12558. * @param id The id of the generic gamepad
  12559. * @param index The index of the generic gamepad
  12560. * @param browserGamepad The browser gamepad
  12561. */
  12562. constructor(id: string, index: number, browserGamepad: any);
  12563. private _setButtonValue;
  12564. /**
  12565. * Updates the generic gamepad
  12566. */
  12567. update(): void;
  12568. /**
  12569. * Disposes the generic gamepad
  12570. */
  12571. dispose(): void;
  12572. }
  12573. }
  12574. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12575. import { Observable } from "babylonjs/Misc/observable";
  12576. import { Nullable } from "babylonjs/types";
  12577. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12578. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12580. import { Ray } from "babylonjs/Culling/ray";
  12581. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12582. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12583. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12584. /**
  12585. * Defines the types of pose enabled controllers that are supported
  12586. */
  12587. export enum PoseEnabledControllerType {
  12588. /**
  12589. * HTC Vive
  12590. */
  12591. VIVE = 0,
  12592. /**
  12593. * Oculus Rift
  12594. */
  12595. OCULUS = 1,
  12596. /**
  12597. * Windows mixed reality
  12598. */
  12599. WINDOWS = 2,
  12600. /**
  12601. * Samsung gear VR
  12602. */
  12603. GEAR_VR = 3,
  12604. /**
  12605. * Google Daydream
  12606. */
  12607. DAYDREAM = 4,
  12608. /**
  12609. * Generic
  12610. */
  12611. GENERIC = 5
  12612. }
  12613. /**
  12614. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12615. */
  12616. export interface MutableGamepadButton {
  12617. /**
  12618. * Value of the button/trigger
  12619. */
  12620. value: number;
  12621. /**
  12622. * If the button/trigger is currently touched
  12623. */
  12624. touched: boolean;
  12625. /**
  12626. * If the button/trigger is currently pressed
  12627. */
  12628. pressed: boolean;
  12629. }
  12630. /**
  12631. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12632. * @hidden
  12633. */
  12634. export interface ExtendedGamepadButton extends GamepadButton {
  12635. /**
  12636. * If the button/trigger is currently pressed
  12637. */
  12638. readonly pressed: boolean;
  12639. /**
  12640. * If the button/trigger is currently touched
  12641. */
  12642. readonly touched: boolean;
  12643. /**
  12644. * Value of the button/trigger
  12645. */
  12646. readonly value: number;
  12647. }
  12648. /** @hidden */
  12649. export interface _GamePadFactory {
  12650. /**
  12651. * Returns wether or not the current gamepad can be created for this type of controller.
  12652. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12653. * @returns true if it can be created, otherwise false
  12654. */
  12655. canCreate(gamepadInfo: any): boolean;
  12656. /**
  12657. * Creates a new instance of the Gamepad.
  12658. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12659. * @returns the new gamepad instance
  12660. */
  12661. create(gamepadInfo: any): Gamepad;
  12662. }
  12663. /**
  12664. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12665. */
  12666. export class PoseEnabledControllerHelper {
  12667. /** @hidden */
  12668. static _ControllerFactories: _GamePadFactory[];
  12669. /** @hidden */
  12670. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12671. /**
  12672. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12673. * @param vrGamepad the gamepad to initialized
  12674. * @returns a vr controller of the type the gamepad identified as
  12675. */
  12676. static InitiateController(vrGamepad: any): Gamepad;
  12677. }
  12678. /**
  12679. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12680. */
  12681. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12682. private _deviceRoomPosition;
  12683. private _deviceRoomRotationQuaternion;
  12684. /**
  12685. * The device position in babylon space
  12686. */
  12687. devicePosition: Vector3;
  12688. /**
  12689. * The device rotation in babylon space
  12690. */
  12691. deviceRotationQuaternion: Quaternion;
  12692. /**
  12693. * The scale factor of the device in babylon space
  12694. */
  12695. deviceScaleFactor: number;
  12696. /**
  12697. * (Likely devicePosition should be used instead) The device position in its room space
  12698. */
  12699. position: Vector3;
  12700. /**
  12701. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12702. */
  12703. rotationQuaternion: Quaternion;
  12704. /**
  12705. * The type of controller (Eg. Windows mixed reality)
  12706. */
  12707. controllerType: PoseEnabledControllerType;
  12708. protected _calculatedPosition: Vector3;
  12709. private _calculatedRotation;
  12710. /**
  12711. * The raw pose from the device
  12712. */
  12713. rawPose: DevicePose;
  12714. private _trackPosition;
  12715. private _maxRotationDistFromHeadset;
  12716. private _draggedRoomRotation;
  12717. /**
  12718. * @hidden
  12719. */
  12720. _disableTrackPosition(fixedPosition: Vector3): void;
  12721. /**
  12722. * Internal, the mesh attached to the controller
  12723. * @hidden
  12724. */
  12725. _mesh: Nullable<AbstractMesh>;
  12726. private _poseControlledCamera;
  12727. private _leftHandSystemQuaternion;
  12728. /**
  12729. * Internal, matrix used to convert room space to babylon space
  12730. * @hidden
  12731. */
  12732. _deviceToWorld: Matrix;
  12733. /**
  12734. * Node to be used when casting a ray from the controller
  12735. * @hidden
  12736. */
  12737. _pointingPoseNode: Nullable<TransformNode>;
  12738. /**
  12739. * Name of the child mesh that can be used to cast a ray from the controller
  12740. */
  12741. static readonly POINTING_POSE: string;
  12742. /**
  12743. * Creates a new PoseEnabledController from a gamepad
  12744. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12745. */
  12746. constructor(browserGamepad: any);
  12747. private _workingMatrix;
  12748. /**
  12749. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12750. */
  12751. update(): void;
  12752. /**
  12753. * Updates only the pose device and mesh without doing any button event checking
  12754. */
  12755. protected _updatePoseAndMesh(): void;
  12756. /**
  12757. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12758. * @param poseData raw pose fromthe device
  12759. */
  12760. updateFromDevice(poseData: DevicePose): void;
  12761. /**
  12762. * @hidden
  12763. */
  12764. _meshAttachedObservable: Observable<AbstractMesh>;
  12765. /**
  12766. * Attaches a mesh to the controller
  12767. * @param mesh the mesh to be attached
  12768. */
  12769. attachToMesh(mesh: AbstractMesh): void;
  12770. /**
  12771. * Attaches the controllers mesh to a camera
  12772. * @param camera the camera the mesh should be attached to
  12773. */
  12774. attachToPoseControlledCamera(camera: TargetCamera): void;
  12775. /**
  12776. * Disposes of the controller
  12777. */
  12778. dispose(): void;
  12779. /**
  12780. * The mesh that is attached to the controller
  12781. */
  12782. readonly mesh: Nullable<AbstractMesh>;
  12783. /**
  12784. * Gets the ray of the controller in the direction the controller is pointing
  12785. * @param length the length the resulting ray should be
  12786. * @returns a ray in the direction the controller is pointing
  12787. */
  12788. getForwardRay(length?: number): Ray;
  12789. }
  12790. }
  12791. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12792. import { Observable } from "babylonjs/Misc/observable";
  12793. import { Scene } from "babylonjs/scene";
  12794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12795. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12796. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12797. /**
  12798. * Defines the WebVRController object that represents controllers tracked in 3D space
  12799. */
  12800. export abstract class WebVRController extends PoseEnabledController {
  12801. /**
  12802. * Internal, the default controller model for the controller
  12803. */
  12804. protected _defaultModel: AbstractMesh;
  12805. /**
  12806. * Fired when the trigger state has changed
  12807. */
  12808. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12809. /**
  12810. * Fired when the main button state has changed
  12811. */
  12812. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12813. /**
  12814. * Fired when the secondary button state has changed
  12815. */
  12816. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12817. /**
  12818. * Fired when the pad state has changed
  12819. */
  12820. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12821. /**
  12822. * Fired when controllers stick values have changed
  12823. */
  12824. onPadValuesChangedObservable: Observable<StickValues>;
  12825. /**
  12826. * Array of button availible on the controller
  12827. */
  12828. protected _buttons: Array<MutableGamepadButton>;
  12829. private _onButtonStateChange;
  12830. /**
  12831. * Fired when a controller button's state has changed
  12832. * @param callback the callback containing the button that was modified
  12833. */
  12834. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12835. /**
  12836. * X and Y axis corrisponding to the controllers joystick
  12837. */
  12838. pad: StickValues;
  12839. /**
  12840. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12841. */
  12842. hand: string;
  12843. /**
  12844. * The default controller model for the controller
  12845. */
  12846. readonly defaultModel: AbstractMesh;
  12847. /**
  12848. * Creates a new WebVRController from a gamepad
  12849. * @param vrGamepad the gamepad that the WebVRController should be created from
  12850. */
  12851. constructor(vrGamepad: any);
  12852. /**
  12853. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12854. */
  12855. update(): void;
  12856. /**
  12857. * Function to be called when a button is modified
  12858. */
  12859. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12860. /**
  12861. * Loads a mesh and attaches it to the controller
  12862. * @param scene the scene the mesh should be added to
  12863. * @param meshLoaded callback for when the mesh has been loaded
  12864. */
  12865. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12866. private _setButtonValue;
  12867. private _changes;
  12868. private _checkChanges;
  12869. /**
  12870. * Disposes of th webVRCOntroller
  12871. */
  12872. dispose(): void;
  12873. }
  12874. }
  12875. declare module "babylonjs/Lights/hemisphericLight" {
  12876. import { Nullable } from "babylonjs/types";
  12877. import { Scene } from "babylonjs/scene";
  12878. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12879. import { Effect } from "babylonjs/Materials/effect";
  12880. import { Light } from "babylonjs/Lights/light";
  12881. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12882. /**
  12883. * The HemisphericLight simulates the ambient environment light,
  12884. * so the passed direction is the light reflection direction, not the incoming direction.
  12885. */
  12886. export class HemisphericLight extends Light {
  12887. /**
  12888. * The groundColor is the light in the opposite direction to the one specified during creation.
  12889. * 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.
  12890. */
  12891. groundColor: Color3;
  12892. /**
  12893. * The light reflection direction, not the incoming direction.
  12894. */
  12895. direction: Vector3;
  12896. /**
  12897. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12898. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12899. * The HemisphericLight can't cast shadows.
  12900. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12901. * @param name The friendly name of the light
  12902. * @param direction The direction of the light reflection
  12903. * @param scene The scene the light belongs to
  12904. */
  12905. constructor(name: string, direction: Vector3, scene: Scene);
  12906. protected _buildUniformLayout(): void;
  12907. /**
  12908. * Returns the string "HemisphericLight".
  12909. * @return The class name
  12910. */
  12911. getClassName(): string;
  12912. /**
  12913. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12914. * Returns the updated direction.
  12915. * @param target The target the direction should point to
  12916. * @return The computed direction
  12917. */
  12918. setDirectionToTarget(target: Vector3): Vector3;
  12919. /**
  12920. * Returns the shadow generator associated to the light.
  12921. * @returns Always null for hemispheric lights because it does not support shadows.
  12922. */
  12923. getShadowGenerator(): Nullable<IShadowGenerator>;
  12924. /**
  12925. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12926. * @param effect The effect to update
  12927. * @param lightIndex The index of the light in the effect to update
  12928. * @returns The hemispheric light
  12929. */
  12930. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12931. /**
  12932. * Computes the world matrix of the node
  12933. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12934. * @param useWasUpdatedFlag defines a reserved property
  12935. * @returns the world matrix
  12936. */
  12937. computeWorldMatrix(): Matrix;
  12938. /**
  12939. * Returns the integer 3.
  12940. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12941. */
  12942. getTypeID(): number;
  12943. /**
  12944. * Prepares the list of defines specific to the light type.
  12945. * @param defines the list of defines
  12946. * @param lightIndex defines the index of the light for the effect
  12947. */
  12948. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12949. }
  12950. }
  12951. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12952. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12953. import { Nullable } from "babylonjs/types";
  12954. import { Observable } from "babylonjs/Misc/observable";
  12955. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12956. import { Scene } from "babylonjs/scene";
  12957. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12958. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12959. import { Node } from "babylonjs/node";
  12960. import { Ray } from "babylonjs/Culling/ray";
  12961. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12962. /**
  12963. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12964. * IMPORTANT!! The data is right-hand data.
  12965. * @export
  12966. * @interface DevicePose
  12967. */
  12968. export interface DevicePose {
  12969. /**
  12970. * The position of the device, values in array are [x,y,z].
  12971. */
  12972. readonly position: Nullable<Float32Array>;
  12973. /**
  12974. * The linearVelocity of the device, values in array are [x,y,z].
  12975. */
  12976. readonly linearVelocity: Nullable<Float32Array>;
  12977. /**
  12978. * The linearAcceleration of the device, values in array are [x,y,z].
  12979. */
  12980. readonly linearAcceleration: Nullable<Float32Array>;
  12981. /**
  12982. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12983. */
  12984. readonly orientation: Nullable<Float32Array>;
  12985. /**
  12986. * The angularVelocity of the device, values in array are [x,y,z].
  12987. */
  12988. readonly angularVelocity: Nullable<Float32Array>;
  12989. /**
  12990. * The angularAcceleration of the device, values in array are [x,y,z].
  12991. */
  12992. readonly angularAcceleration: Nullable<Float32Array>;
  12993. }
  12994. /**
  12995. * Interface representing a pose controlled object in Babylon.
  12996. * A pose controlled object has both regular pose values as well as pose values
  12997. * from an external device such as a VR head mounted display
  12998. */
  12999. export interface PoseControlled {
  13000. /**
  13001. * The position of the object in babylon space.
  13002. */
  13003. position: Vector3;
  13004. /**
  13005. * The rotation quaternion of the object in babylon space.
  13006. */
  13007. rotationQuaternion: Quaternion;
  13008. /**
  13009. * The position of the device in babylon space.
  13010. */
  13011. devicePosition?: Vector3;
  13012. /**
  13013. * The rotation quaternion of the device in babylon space.
  13014. */
  13015. deviceRotationQuaternion: Quaternion;
  13016. /**
  13017. * The raw pose coming from the device.
  13018. */
  13019. rawPose: Nullable<DevicePose>;
  13020. /**
  13021. * The scale of the device to be used when translating from device space to babylon space.
  13022. */
  13023. deviceScaleFactor: number;
  13024. /**
  13025. * Updates the poseControlled values based on the input device pose.
  13026. * @param poseData the pose data to update the object with
  13027. */
  13028. updateFromDevice(poseData: DevicePose): void;
  13029. }
  13030. /**
  13031. * Set of options to customize the webVRCamera
  13032. */
  13033. export interface WebVROptions {
  13034. /**
  13035. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13036. */
  13037. trackPosition?: boolean;
  13038. /**
  13039. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13040. */
  13041. positionScale?: number;
  13042. /**
  13043. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13044. */
  13045. displayName?: string;
  13046. /**
  13047. * Should the native controller meshes be initialized. (default: true)
  13048. */
  13049. controllerMeshes?: boolean;
  13050. /**
  13051. * Creating a default HemiLight only on controllers. (default: true)
  13052. */
  13053. defaultLightingOnControllers?: boolean;
  13054. /**
  13055. * If you don't want to use the default VR button of the helper. (default: false)
  13056. */
  13057. useCustomVRButton?: boolean;
  13058. /**
  13059. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13060. */
  13061. customVRButton?: HTMLButtonElement;
  13062. /**
  13063. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13064. */
  13065. rayLength?: number;
  13066. /**
  13067. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13068. */
  13069. defaultHeight?: number;
  13070. }
  13071. /**
  13072. * This represents a WebVR camera.
  13073. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13074. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13075. */
  13076. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13077. private webVROptions;
  13078. /**
  13079. * @hidden
  13080. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13081. */
  13082. _vrDevice: any;
  13083. /**
  13084. * The rawPose of the vrDevice.
  13085. */
  13086. rawPose: Nullable<DevicePose>;
  13087. private _onVREnabled;
  13088. private _specsVersion;
  13089. private _attached;
  13090. private _frameData;
  13091. protected _descendants: Array<Node>;
  13092. private _deviceRoomPosition;
  13093. /** @hidden */
  13094. _deviceRoomRotationQuaternion: Quaternion;
  13095. private _standingMatrix;
  13096. /**
  13097. * Represents device position in babylon space.
  13098. */
  13099. devicePosition: Vector3;
  13100. /**
  13101. * Represents device rotation in babylon space.
  13102. */
  13103. deviceRotationQuaternion: Quaternion;
  13104. /**
  13105. * The scale of the device to be used when translating from device space to babylon space.
  13106. */
  13107. deviceScaleFactor: number;
  13108. private _deviceToWorld;
  13109. private _worldToDevice;
  13110. /**
  13111. * References to the webVR controllers for the vrDevice.
  13112. */
  13113. controllers: Array<WebVRController>;
  13114. /**
  13115. * Emits an event when a controller is attached.
  13116. */
  13117. onControllersAttachedObservable: Observable<WebVRController[]>;
  13118. /**
  13119. * Emits an event when a controller's mesh has been loaded;
  13120. */
  13121. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13122. /**
  13123. * Emits an event when the HMD's pose has been updated.
  13124. */
  13125. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13126. private _poseSet;
  13127. /**
  13128. * If the rig cameras be used as parent instead of this camera.
  13129. */
  13130. rigParenting: boolean;
  13131. private _lightOnControllers;
  13132. private _defaultHeight?;
  13133. /**
  13134. * Instantiates a WebVRFreeCamera.
  13135. * @param name The name of the WebVRFreeCamera
  13136. * @param position The starting anchor position for the camera
  13137. * @param scene The scene the camera belongs to
  13138. * @param webVROptions a set of customizable options for the webVRCamera
  13139. */
  13140. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13141. /**
  13142. * Gets the device distance from the ground in meters.
  13143. * @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.
  13144. */
  13145. deviceDistanceToRoomGround(): number;
  13146. /**
  13147. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13148. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13149. */
  13150. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13151. /**
  13152. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13153. * @returns A promise with a boolean set to if the standing matrix is supported.
  13154. */
  13155. useStandingMatrixAsync(): Promise<boolean>;
  13156. /**
  13157. * Disposes the camera
  13158. */
  13159. dispose(): void;
  13160. /**
  13161. * Gets a vrController by name.
  13162. * @param name The name of the controller to retreive
  13163. * @returns the controller matching the name specified or null if not found
  13164. */
  13165. getControllerByName(name: string): Nullable<WebVRController>;
  13166. private _leftController;
  13167. /**
  13168. * The controller corrisponding to the users left hand.
  13169. */
  13170. readonly leftController: Nullable<WebVRController>;
  13171. private _rightController;
  13172. /**
  13173. * The controller corrisponding to the users right hand.
  13174. */
  13175. readonly rightController: Nullable<WebVRController>;
  13176. /**
  13177. * Casts a ray forward from the vrCamera's gaze.
  13178. * @param length Length of the ray (default: 100)
  13179. * @returns the ray corrisponding to the gaze
  13180. */
  13181. getForwardRay(length?: number): Ray;
  13182. /**
  13183. * @hidden
  13184. * Updates the camera based on device's frame data
  13185. */
  13186. _checkInputs(): void;
  13187. /**
  13188. * Updates the poseControlled values based on the input device pose.
  13189. * @param poseData Pose coming from the device
  13190. */
  13191. updateFromDevice(poseData: DevicePose): void;
  13192. private _htmlElementAttached;
  13193. private _detachIfAttached;
  13194. /**
  13195. * WebVR's attach control will start broadcasting frames to the device.
  13196. * Note that in certain browsers (chrome for example) this function must be called
  13197. * within a user-interaction callback. Example:
  13198. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13199. *
  13200. * @param element html element to attach the vrDevice to
  13201. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13202. */
  13203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13204. /**
  13205. * Detaches the camera from the html element and disables VR
  13206. *
  13207. * @param element html element to detach from
  13208. */
  13209. detachControl(element: HTMLElement): void;
  13210. /**
  13211. * @returns the name of this class
  13212. */
  13213. getClassName(): string;
  13214. /**
  13215. * Calls resetPose on the vrDisplay
  13216. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13217. */
  13218. resetToCurrentRotation(): void;
  13219. /**
  13220. * @hidden
  13221. * Updates the rig cameras (left and right eye)
  13222. */
  13223. _updateRigCameras(): void;
  13224. private _workingVector;
  13225. private _oneVector;
  13226. private _workingMatrix;
  13227. private updateCacheCalled;
  13228. private _correctPositionIfNotTrackPosition;
  13229. /**
  13230. * @hidden
  13231. * Updates the cached values of the camera
  13232. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13233. */
  13234. _updateCache(ignoreParentClass?: boolean): void;
  13235. /**
  13236. * @hidden
  13237. * Get current device position in babylon world
  13238. */
  13239. _computeDevicePosition(): void;
  13240. /**
  13241. * Updates the current device position and rotation in the babylon world
  13242. */
  13243. update(): void;
  13244. /**
  13245. * @hidden
  13246. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13247. * @returns an identity matrix
  13248. */
  13249. _getViewMatrix(): Matrix;
  13250. private _tmpMatrix;
  13251. /**
  13252. * This function is called by the two RIG cameras.
  13253. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13254. * @hidden
  13255. */
  13256. _getWebVRViewMatrix(): Matrix;
  13257. /** @hidden */
  13258. _getWebVRProjectionMatrix(): Matrix;
  13259. private _onGamepadConnectedObserver;
  13260. private _onGamepadDisconnectedObserver;
  13261. private _updateCacheWhenTrackingDisabledObserver;
  13262. /**
  13263. * Initializes the controllers and their meshes
  13264. */
  13265. initControllers(): void;
  13266. }
  13267. }
  13268. declare module "babylonjs/PostProcesses/postProcess" {
  13269. import { Nullable } from "babylonjs/types";
  13270. import { SmartArray } from "babylonjs/Misc/smartArray";
  13271. import { Observable } from "babylonjs/Misc/observable";
  13272. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13273. import { Camera } from "babylonjs/Cameras/camera";
  13274. import { Effect } from "babylonjs/Materials/effect";
  13275. import "babylonjs/Shaders/postprocess.vertex";
  13276. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13277. import { Engine } from "babylonjs/Engines/engine";
  13278. /**
  13279. * Size options for a post process
  13280. */
  13281. export type PostProcessOptions = {
  13282. width: number;
  13283. height: number;
  13284. };
  13285. /**
  13286. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13287. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13288. */
  13289. export class PostProcess {
  13290. /** Name of the PostProcess. */
  13291. name: string;
  13292. /**
  13293. * Gets or sets the unique id of the post process
  13294. */
  13295. uniqueId: number;
  13296. /**
  13297. * Width of the texture to apply the post process on
  13298. */
  13299. width: number;
  13300. /**
  13301. * Height of the texture to apply the post process on
  13302. */
  13303. height: number;
  13304. /**
  13305. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13306. * @hidden
  13307. */
  13308. _outputTexture: Nullable<InternalTexture>;
  13309. /**
  13310. * Sampling mode used by the shader
  13311. * See https://doc.babylonjs.com/classes/3.1/texture
  13312. */
  13313. renderTargetSamplingMode: number;
  13314. /**
  13315. * Clear color to use when screen clearing
  13316. */
  13317. clearColor: Color4;
  13318. /**
  13319. * If the buffer needs to be cleared before applying the post process. (default: true)
  13320. * Should be set to false if shader will overwrite all previous pixels.
  13321. */
  13322. autoClear: boolean;
  13323. /**
  13324. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13325. */
  13326. alphaMode: number;
  13327. /**
  13328. * Sets the setAlphaBlendConstants of the babylon engine
  13329. */
  13330. alphaConstants: Color4;
  13331. /**
  13332. * Animations to be used for the post processing
  13333. */
  13334. animations: import("babylonjs/Animations/animation").Animation[];
  13335. /**
  13336. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13337. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13338. */
  13339. enablePixelPerfectMode: boolean;
  13340. /**
  13341. * Force the postprocess to be applied without taking in account viewport
  13342. */
  13343. forceFullscreenViewport: boolean;
  13344. /**
  13345. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13346. *
  13347. * | Value | Type | Description |
  13348. * | ----- | ----------------------------------- | ----------- |
  13349. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13350. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13351. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13352. *
  13353. */
  13354. scaleMode: number;
  13355. /**
  13356. * Force textures to be a power of two (default: false)
  13357. */
  13358. alwaysForcePOT: boolean;
  13359. private _samples;
  13360. /**
  13361. * Number of sample textures (default: 1)
  13362. */
  13363. samples: number;
  13364. /**
  13365. * Modify the scale of the post process to be the same as the viewport (default: false)
  13366. */
  13367. adaptScaleToCurrentViewport: boolean;
  13368. private _camera;
  13369. private _scene;
  13370. private _engine;
  13371. private _options;
  13372. private _reusable;
  13373. private _textureType;
  13374. /**
  13375. * Smart array of input and output textures for the post process.
  13376. * @hidden
  13377. */
  13378. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13379. /**
  13380. * The index in _textures that corresponds to the output texture.
  13381. * @hidden
  13382. */
  13383. _currentRenderTextureInd: number;
  13384. private _effect;
  13385. private _samplers;
  13386. private _fragmentUrl;
  13387. private _vertexUrl;
  13388. private _parameters;
  13389. private _scaleRatio;
  13390. protected _indexParameters: any;
  13391. private _shareOutputWithPostProcess;
  13392. private _texelSize;
  13393. private _forcedOutputTexture;
  13394. /**
  13395. * Returns the fragment url or shader name used in the post process.
  13396. * @returns the fragment url or name in the shader store.
  13397. */
  13398. getEffectName(): string;
  13399. /**
  13400. * An event triggered when the postprocess is activated.
  13401. */
  13402. onActivateObservable: Observable<Camera>;
  13403. private _onActivateObserver;
  13404. /**
  13405. * A function that is added to the onActivateObservable
  13406. */
  13407. onActivate: Nullable<(camera: Camera) => void>;
  13408. /**
  13409. * An event triggered when the postprocess changes its size.
  13410. */
  13411. onSizeChangedObservable: Observable<PostProcess>;
  13412. private _onSizeChangedObserver;
  13413. /**
  13414. * A function that is added to the onSizeChangedObservable
  13415. */
  13416. onSizeChanged: (postProcess: PostProcess) => void;
  13417. /**
  13418. * An event triggered when the postprocess applies its effect.
  13419. */
  13420. onApplyObservable: Observable<Effect>;
  13421. private _onApplyObserver;
  13422. /**
  13423. * A function that is added to the onApplyObservable
  13424. */
  13425. onApply: (effect: Effect) => void;
  13426. /**
  13427. * An event triggered before rendering the postprocess
  13428. */
  13429. onBeforeRenderObservable: Observable<Effect>;
  13430. private _onBeforeRenderObserver;
  13431. /**
  13432. * A function that is added to the onBeforeRenderObservable
  13433. */
  13434. onBeforeRender: (effect: Effect) => void;
  13435. /**
  13436. * An event triggered after rendering the postprocess
  13437. */
  13438. onAfterRenderObservable: Observable<Effect>;
  13439. private _onAfterRenderObserver;
  13440. /**
  13441. * A function that is added to the onAfterRenderObservable
  13442. */
  13443. onAfterRender: (efect: Effect) => void;
  13444. /**
  13445. * 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
  13446. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13447. */
  13448. inputTexture: InternalTexture;
  13449. /**
  13450. * Gets the camera which post process is applied to.
  13451. * @returns The camera the post process is applied to.
  13452. */
  13453. getCamera(): Camera;
  13454. /**
  13455. * Gets the texel size of the postprocess.
  13456. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13457. */
  13458. readonly texelSize: Vector2;
  13459. /**
  13460. * Creates a new instance PostProcess
  13461. * @param name The name of the PostProcess.
  13462. * @param fragmentUrl The url of the fragment shader to be used.
  13463. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13464. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13465. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13466. * @param camera The camera to apply the render pass to.
  13467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13468. * @param engine The engine which the post process will be applied. (default: current engine)
  13469. * @param reusable If the post process can be reused on the same frame. (default: false)
  13470. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13471. * @param textureType Type of textures used when performing the post process. (default: 0)
  13472. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13473. * @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
  13474. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13475. */
  13476. constructor(
  13477. /** Name of the PostProcess. */
  13478. 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);
  13479. /**
  13480. * Gets a string idenfifying the name of the class
  13481. * @returns "PostProcess" string
  13482. */
  13483. getClassName(): string;
  13484. /**
  13485. * Gets the engine which this post process belongs to.
  13486. * @returns The engine the post process was enabled with.
  13487. */
  13488. getEngine(): Engine;
  13489. /**
  13490. * The effect that is created when initializing the post process.
  13491. * @returns The created effect corrisponding the the postprocess.
  13492. */
  13493. getEffect(): Effect;
  13494. /**
  13495. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13496. * @param postProcess The post process to share the output with.
  13497. * @returns This post process.
  13498. */
  13499. shareOutputWith(postProcess: PostProcess): PostProcess;
  13500. /**
  13501. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13502. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13503. */
  13504. useOwnOutput(): void;
  13505. /**
  13506. * Updates the effect with the current post process compile time values and recompiles the shader.
  13507. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13508. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13509. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13510. * @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
  13511. * @param onCompiled Called when the shader has been compiled.
  13512. * @param onError Called if there is an error when compiling a shader.
  13513. */
  13514. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13515. /**
  13516. * The post process is reusable if it can be used multiple times within one frame.
  13517. * @returns If the post process is reusable
  13518. */
  13519. isReusable(): boolean;
  13520. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13521. markTextureDirty(): void;
  13522. /**
  13523. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13524. * 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.
  13525. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13526. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13527. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13528. * @returns The target texture that was bound to be written to.
  13529. */
  13530. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13531. /**
  13532. * If the post process is supported.
  13533. */
  13534. readonly isSupported: boolean;
  13535. /**
  13536. * The aspect ratio of the output texture.
  13537. */
  13538. readonly aspectRatio: number;
  13539. /**
  13540. * Get a value indicating if the post-process is ready to be used
  13541. * @returns true if the post-process is ready (shader is compiled)
  13542. */
  13543. isReady(): boolean;
  13544. /**
  13545. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13546. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13547. */
  13548. apply(): Nullable<Effect>;
  13549. private _disposeTextures;
  13550. /**
  13551. * Disposes the post process.
  13552. * @param camera The camera to dispose the post process on.
  13553. */
  13554. dispose(camera?: Camera): void;
  13555. }
  13556. }
  13557. declare module "babylonjs/PostProcesses/postProcessManager" {
  13558. import { Nullable } from "babylonjs/types";
  13559. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13560. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13561. import { Scene } from "babylonjs/scene";
  13562. /**
  13563. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13564. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13565. */
  13566. export class PostProcessManager {
  13567. private _scene;
  13568. private _indexBuffer;
  13569. private _vertexBuffers;
  13570. /**
  13571. * Creates a new instance PostProcess
  13572. * @param scene The scene that the post process is associated with.
  13573. */
  13574. constructor(scene: Scene);
  13575. private _prepareBuffers;
  13576. private _buildIndexBuffer;
  13577. /**
  13578. * Rebuilds the vertex buffers of the manager.
  13579. * @hidden
  13580. */
  13581. _rebuild(): void;
  13582. /**
  13583. * Prepares a frame to be run through a post process.
  13584. * @param sourceTexture The input texture to the post procesess. (default: null)
  13585. * @param postProcesses An array of post processes to be run. (default: null)
  13586. * @returns True if the post processes were able to be run.
  13587. * @hidden
  13588. */
  13589. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13590. /**
  13591. * Manually render a set of post processes to a texture.
  13592. * @param postProcesses An array of post processes to be run.
  13593. * @param targetTexture The target texture to render to.
  13594. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13595. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13596. * @param lodLevel defines which lod of the texture to render to
  13597. */
  13598. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13599. /**
  13600. * Finalize the result of the output of the postprocesses.
  13601. * @param doNotPresent If true the result will not be displayed to the screen.
  13602. * @param targetTexture The target texture to render to.
  13603. * @param faceIndex The index of the face to bind the target texture to.
  13604. * @param postProcesses The array of post processes to render.
  13605. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13606. * @hidden
  13607. */
  13608. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13609. /**
  13610. * Disposes of the post process manager.
  13611. */
  13612. dispose(): void;
  13613. }
  13614. }
  13615. declare module "babylonjs/Layers/layerSceneComponent" {
  13616. import { Scene } from "babylonjs/scene";
  13617. import { ISceneComponent } from "babylonjs/sceneComponent";
  13618. import { Layer } from "babylonjs/Layers/layer";
  13619. module "babylonjs/abstractScene" {
  13620. interface AbstractScene {
  13621. /**
  13622. * The list of layers (background and foreground) of the scene
  13623. */
  13624. layers: Array<Layer>;
  13625. }
  13626. }
  13627. /**
  13628. * Defines the layer scene component responsible to manage any layers
  13629. * in a given scene.
  13630. */
  13631. export class LayerSceneComponent implements ISceneComponent {
  13632. /**
  13633. * The component name helpfull to identify the component in the list of scene components.
  13634. */
  13635. readonly name: string;
  13636. /**
  13637. * The scene the component belongs to.
  13638. */
  13639. scene: Scene;
  13640. private _engine;
  13641. /**
  13642. * Creates a new instance of the component for the given scene
  13643. * @param scene Defines the scene to register the component in
  13644. */
  13645. constructor(scene: Scene);
  13646. /**
  13647. * Registers the component in a given scene
  13648. */
  13649. register(): void;
  13650. /**
  13651. * Rebuilds the elements related to this component in case of
  13652. * context lost for instance.
  13653. */
  13654. rebuild(): void;
  13655. /**
  13656. * Disposes the component and the associated ressources.
  13657. */
  13658. dispose(): void;
  13659. private _draw;
  13660. private _drawCameraPredicate;
  13661. private _drawCameraBackground;
  13662. private _drawCameraForeground;
  13663. private _drawRenderTargetPredicate;
  13664. private _drawRenderTargetBackground;
  13665. private _drawRenderTargetForeground;
  13666. }
  13667. }
  13668. declare module "babylonjs/Shaders/layer.fragment" {
  13669. /** @hidden */
  13670. export var layerPixelShader: {
  13671. name: string;
  13672. shader: string;
  13673. };
  13674. }
  13675. declare module "babylonjs/Shaders/layer.vertex" {
  13676. /** @hidden */
  13677. export var layerVertexShader: {
  13678. name: string;
  13679. shader: string;
  13680. };
  13681. }
  13682. declare module "babylonjs/Layers/layer" {
  13683. import { Observable } from "babylonjs/Misc/observable";
  13684. import { Nullable } from "babylonjs/types";
  13685. import { Scene } from "babylonjs/scene";
  13686. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13687. import { Texture } from "babylonjs/Materials/Textures/texture";
  13688. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13689. import "babylonjs/Shaders/layer.fragment";
  13690. import "babylonjs/Shaders/layer.vertex";
  13691. /**
  13692. * This represents a full screen 2d layer.
  13693. * This can be useful to display a picture in the background of your scene for instance.
  13694. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13695. */
  13696. export class Layer {
  13697. /**
  13698. * Define the name of the layer.
  13699. */
  13700. name: string;
  13701. /**
  13702. * Define the texture the layer should display.
  13703. */
  13704. texture: Nullable<Texture>;
  13705. /**
  13706. * Is the layer in background or foreground.
  13707. */
  13708. isBackground: boolean;
  13709. /**
  13710. * Define the color of the layer (instead of texture).
  13711. */
  13712. color: Color4;
  13713. /**
  13714. * Define the scale of the layer in order to zoom in out of the texture.
  13715. */
  13716. scale: Vector2;
  13717. /**
  13718. * Define an offset for the layer in order to shift the texture.
  13719. */
  13720. offset: Vector2;
  13721. /**
  13722. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13723. */
  13724. alphaBlendingMode: number;
  13725. /**
  13726. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13727. * Alpha test will not mix with the background color in case of transparency.
  13728. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13729. */
  13730. alphaTest: boolean;
  13731. /**
  13732. * Define a mask to restrict the layer to only some of the scene cameras.
  13733. */
  13734. layerMask: number;
  13735. /**
  13736. * Define the list of render target the layer is visible into.
  13737. */
  13738. renderTargetTextures: RenderTargetTexture[];
  13739. /**
  13740. * Define if the layer is only used in renderTarget or if it also
  13741. * renders in the main frame buffer of the canvas.
  13742. */
  13743. renderOnlyInRenderTargetTextures: boolean;
  13744. private _scene;
  13745. private _vertexBuffers;
  13746. private _indexBuffer;
  13747. private _effect;
  13748. private _alphaTestEffect;
  13749. /**
  13750. * An event triggered when the layer is disposed.
  13751. */
  13752. onDisposeObservable: Observable<Layer>;
  13753. private _onDisposeObserver;
  13754. /**
  13755. * Back compatibility with callback before the onDisposeObservable existed.
  13756. * The set callback will be triggered when the layer has been disposed.
  13757. */
  13758. onDispose: () => void;
  13759. /**
  13760. * An event triggered before rendering the scene
  13761. */
  13762. onBeforeRenderObservable: Observable<Layer>;
  13763. private _onBeforeRenderObserver;
  13764. /**
  13765. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13766. * The set callback will be triggered just before rendering the layer.
  13767. */
  13768. onBeforeRender: () => void;
  13769. /**
  13770. * An event triggered after rendering the scene
  13771. */
  13772. onAfterRenderObservable: Observable<Layer>;
  13773. private _onAfterRenderObserver;
  13774. /**
  13775. * Back compatibility with callback before the onAfterRenderObservable existed.
  13776. * The set callback will be triggered just after rendering the layer.
  13777. */
  13778. onAfterRender: () => void;
  13779. /**
  13780. * Instantiates a new layer.
  13781. * This represents a full screen 2d layer.
  13782. * This can be useful to display a picture in the background of your scene for instance.
  13783. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13784. * @param name Define the name of the layer in the scene
  13785. * @param imgUrl Define the url of the texture to display in the layer
  13786. * @param scene Define the scene the layer belongs to
  13787. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13788. * @param color Defines a color for the layer
  13789. */
  13790. constructor(
  13791. /**
  13792. * Define the name of the layer.
  13793. */
  13794. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13795. private _createIndexBuffer;
  13796. /** @hidden */
  13797. _rebuild(): void;
  13798. /**
  13799. * Renders the layer in the scene.
  13800. */
  13801. render(): void;
  13802. /**
  13803. * Disposes and releases the associated ressources.
  13804. */
  13805. dispose(): void;
  13806. }
  13807. }
  13808. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13809. import { Scene } from "babylonjs/scene";
  13810. import { ISceneComponent } from "babylonjs/sceneComponent";
  13811. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13812. module "babylonjs/abstractScene" {
  13813. interface AbstractScene {
  13814. /**
  13815. * The list of procedural textures added to the scene
  13816. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13817. */
  13818. proceduralTextures: Array<ProceduralTexture>;
  13819. }
  13820. }
  13821. /**
  13822. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13823. * in a given scene.
  13824. */
  13825. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13826. /**
  13827. * The component name helpfull to identify the component in the list of scene components.
  13828. */
  13829. readonly name: string;
  13830. /**
  13831. * The scene the component belongs to.
  13832. */
  13833. scene: Scene;
  13834. /**
  13835. * Creates a new instance of the component for the given scene
  13836. * @param scene Defines the scene to register the component in
  13837. */
  13838. constructor(scene: Scene);
  13839. /**
  13840. * Registers the component in a given scene
  13841. */
  13842. register(): void;
  13843. /**
  13844. * Rebuilds the elements related to this component in case of
  13845. * context lost for instance.
  13846. */
  13847. rebuild(): void;
  13848. /**
  13849. * Disposes the component and the associated ressources.
  13850. */
  13851. dispose(): void;
  13852. private _beforeClear;
  13853. }
  13854. }
  13855. declare module "babylonjs/Shaders/procedural.vertex" {
  13856. /** @hidden */
  13857. export var proceduralVertexShader: {
  13858. name: string;
  13859. shader: string;
  13860. };
  13861. }
  13862. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13863. import { Observable } from "babylonjs/Misc/observable";
  13864. import { Nullable } from "babylonjs/types";
  13865. import { Scene } from "babylonjs/scene";
  13866. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13867. import { Effect } from "babylonjs/Materials/effect";
  13868. import { Texture } from "babylonjs/Materials/Textures/texture";
  13869. import "babylonjs/Shaders/procedural.vertex";
  13870. /**
  13871. * 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.
  13872. * This is the base class of any Procedural texture and contains most of the shareable code.
  13873. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13874. */
  13875. export class ProceduralTexture extends Texture {
  13876. isCube: boolean;
  13877. /**
  13878. * Define if the texture is enabled or not (disabled texture will not render)
  13879. */
  13880. isEnabled: boolean;
  13881. /**
  13882. * Define if the texture must be cleared before rendering (default is true)
  13883. */
  13884. autoClear: boolean;
  13885. /**
  13886. * Callback called when the texture is generated
  13887. */
  13888. onGenerated: () => void;
  13889. /**
  13890. * Event raised when the texture is generated
  13891. */
  13892. onGeneratedObservable: Observable<ProceduralTexture>;
  13893. /** @hidden */
  13894. _generateMipMaps: boolean;
  13895. /** @hidden **/
  13896. _effect: Effect;
  13897. /** @hidden */
  13898. _textures: {
  13899. [key: string]: Texture;
  13900. };
  13901. private _size;
  13902. private _currentRefreshId;
  13903. private _refreshRate;
  13904. private _vertexBuffers;
  13905. private _indexBuffer;
  13906. private _uniforms;
  13907. private _samplers;
  13908. private _fragment;
  13909. private _floats;
  13910. private _ints;
  13911. private _floatsArrays;
  13912. private _colors3;
  13913. private _colors4;
  13914. private _vectors2;
  13915. private _vectors3;
  13916. private _matrices;
  13917. private _fallbackTexture;
  13918. private _fallbackTextureUsed;
  13919. private _engine;
  13920. private _cachedDefines;
  13921. private _contentUpdateId;
  13922. private _contentData;
  13923. /**
  13924. * Instantiates a new procedural texture.
  13925. * 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.
  13926. * This is the base class of any Procedural texture and contains most of the shareable code.
  13927. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13928. * @param name Define the name of the texture
  13929. * @param size Define the size of the texture to create
  13930. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13931. * @param scene Define the scene the texture belongs to
  13932. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13933. * @param generateMipMaps Define if the texture should creates mip maps or not
  13934. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13935. */
  13936. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13937. /**
  13938. * The effect that is created when initializing the post process.
  13939. * @returns The created effect corrisponding the the postprocess.
  13940. */
  13941. getEffect(): Effect;
  13942. /**
  13943. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13944. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13945. */
  13946. getContent(): Nullable<ArrayBufferView>;
  13947. private _createIndexBuffer;
  13948. /** @hidden */
  13949. _rebuild(): void;
  13950. /**
  13951. * Resets the texture in order to recreate its associated resources.
  13952. * This can be called in case of context loss
  13953. */
  13954. reset(): void;
  13955. protected _getDefines(): string;
  13956. /**
  13957. * Is the texture ready to be used ? (rendered at least once)
  13958. * @returns true if ready, otherwise, false.
  13959. */
  13960. isReady(): boolean;
  13961. /**
  13962. * Resets the refresh counter of the texture and start bak from scratch.
  13963. * Could be useful to regenerate the texture if it is setup to render only once.
  13964. */
  13965. resetRefreshCounter(): void;
  13966. /**
  13967. * Set the fragment shader to use in order to render the texture.
  13968. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13969. */
  13970. setFragment(fragment: any): void;
  13971. /**
  13972. * Define the refresh rate of the texture or the rendering frequency.
  13973. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13974. */
  13975. refreshRate: number;
  13976. /** @hidden */
  13977. _shouldRender(): boolean;
  13978. /**
  13979. * Get the size the texture is rendering at.
  13980. * @returns the size (texture is always squared)
  13981. */
  13982. getRenderSize(): number;
  13983. /**
  13984. * Resize the texture to new value.
  13985. * @param size Define the new size the texture should have
  13986. * @param generateMipMaps Define whether the new texture should create mip maps
  13987. */
  13988. resize(size: number, generateMipMaps: boolean): void;
  13989. private _checkUniform;
  13990. /**
  13991. * Set a texture in the shader program used to render.
  13992. * @param name Define the name of the uniform samplers as defined in the shader
  13993. * @param texture Define the texture to bind to this sampler
  13994. * @return the texture itself allowing "fluent" like uniform updates
  13995. */
  13996. setTexture(name: string, texture: Texture): ProceduralTexture;
  13997. /**
  13998. * Set a float in the shader.
  13999. * @param name Define the name of the uniform as defined in the shader
  14000. * @param value Define the value to give to the uniform
  14001. * @return the texture itself allowing "fluent" like uniform updates
  14002. */
  14003. setFloat(name: string, value: number): ProceduralTexture;
  14004. /**
  14005. * Set a int in the shader.
  14006. * @param name Define the name of the uniform as defined in the shader
  14007. * @param value Define the value to give to the uniform
  14008. * @return the texture itself allowing "fluent" like uniform updates
  14009. */
  14010. setInt(name: string, value: number): ProceduralTexture;
  14011. /**
  14012. * Set an array of floats in the shader.
  14013. * @param name Define the name of the uniform as defined in the shader
  14014. * @param value Define the value to give to the uniform
  14015. * @return the texture itself allowing "fluent" like uniform updates
  14016. */
  14017. setFloats(name: string, value: number[]): ProceduralTexture;
  14018. /**
  14019. * Set a vec3 in the shader from a Color3.
  14020. * @param name Define the name of the uniform as defined in the shader
  14021. * @param value Define the value to give to the uniform
  14022. * @return the texture itself allowing "fluent" like uniform updates
  14023. */
  14024. setColor3(name: string, value: Color3): ProceduralTexture;
  14025. /**
  14026. * Set a vec4 in the shader from a Color4.
  14027. * @param name Define the name of the uniform as defined in the shader
  14028. * @param value Define the value to give to the uniform
  14029. * @return the texture itself allowing "fluent" like uniform updates
  14030. */
  14031. setColor4(name: string, value: Color4): ProceduralTexture;
  14032. /**
  14033. * Set a vec2 in the shader from a Vector2.
  14034. * @param name Define the name of the uniform as defined in the shader
  14035. * @param value Define the value to give to the uniform
  14036. * @return the texture itself allowing "fluent" like uniform updates
  14037. */
  14038. setVector2(name: string, value: Vector2): ProceduralTexture;
  14039. /**
  14040. * Set a vec3 in the shader from a Vector3.
  14041. * @param name Define the name of the uniform as defined in the shader
  14042. * @param value Define the value to give to the uniform
  14043. * @return the texture itself allowing "fluent" like uniform updates
  14044. */
  14045. setVector3(name: string, value: Vector3): ProceduralTexture;
  14046. /**
  14047. * Set a mat4 in the shader from a MAtrix.
  14048. * @param name Define the name of the uniform as defined in the shader
  14049. * @param value Define the value to give to the uniform
  14050. * @return the texture itself allowing "fluent" like uniform updates
  14051. */
  14052. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14053. /**
  14054. * Render the texture to its associated render target.
  14055. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14056. */
  14057. render(useCameraPostProcess?: boolean): void;
  14058. /**
  14059. * Clone the texture.
  14060. * @returns the cloned texture
  14061. */
  14062. clone(): ProceduralTexture;
  14063. /**
  14064. * Dispose the texture and release its asoociated resources.
  14065. */
  14066. dispose(): void;
  14067. }
  14068. }
  14069. declare module "babylonjs/Particles/baseParticleSystem" {
  14070. import { Nullable } from "babylonjs/types";
  14071. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14073. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14074. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14075. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14076. import { Scene } from "babylonjs/scene";
  14077. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14078. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14079. import { Texture } from "babylonjs/Materials/Textures/texture";
  14080. import { Animation } from "babylonjs/Animations/animation";
  14081. /**
  14082. * This represents the base class for particle system in Babylon.
  14083. * 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.
  14084. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14085. * @example https://doc.babylonjs.com/babylon101/particles
  14086. */
  14087. export class BaseParticleSystem {
  14088. /**
  14089. * Source color is added to the destination color without alpha affecting the result
  14090. */
  14091. static BLENDMODE_ONEONE: number;
  14092. /**
  14093. * Blend current color and particle color using particle’s alpha
  14094. */
  14095. static BLENDMODE_STANDARD: number;
  14096. /**
  14097. * Add current color and particle color multiplied by particle’s alpha
  14098. */
  14099. static BLENDMODE_ADD: number;
  14100. /**
  14101. * Multiply current color with particle color
  14102. */
  14103. static BLENDMODE_MULTIPLY: number;
  14104. /**
  14105. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14106. */
  14107. static BLENDMODE_MULTIPLYADD: number;
  14108. /**
  14109. * List of animations used by the particle system.
  14110. */
  14111. animations: Animation[];
  14112. /**
  14113. * The id of the Particle system.
  14114. */
  14115. id: string;
  14116. /**
  14117. * The friendly name of the Particle system.
  14118. */
  14119. name: string;
  14120. /**
  14121. * The rendering group used by the Particle system to chose when to render.
  14122. */
  14123. renderingGroupId: number;
  14124. /**
  14125. * The emitter represents the Mesh or position we are attaching the particle system to.
  14126. */
  14127. emitter: Nullable<AbstractMesh | Vector3>;
  14128. /**
  14129. * The maximum number of particles to emit per frame
  14130. */
  14131. emitRate: number;
  14132. /**
  14133. * If you want to launch only a few particles at once, that can be done, as well.
  14134. */
  14135. manualEmitCount: number;
  14136. /**
  14137. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14138. */
  14139. updateSpeed: number;
  14140. /**
  14141. * The amount of time the particle system is running (depends of the overall update speed).
  14142. */
  14143. targetStopDuration: number;
  14144. /**
  14145. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14146. */
  14147. disposeOnStop: boolean;
  14148. /**
  14149. * Minimum power of emitting particles.
  14150. */
  14151. minEmitPower: number;
  14152. /**
  14153. * Maximum power of emitting particles.
  14154. */
  14155. maxEmitPower: number;
  14156. /**
  14157. * Minimum life time of emitting particles.
  14158. */
  14159. minLifeTime: number;
  14160. /**
  14161. * Maximum life time of emitting particles.
  14162. */
  14163. maxLifeTime: number;
  14164. /**
  14165. * Minimum Size of emitting particles.
  14166. */
  14167. minSize: number;
  14168. /**
  14169. * Maximum Size of emitting particles.
  14170. */
  14171. maxSize: number;
  14172. /**
  14173. * Minimum scale of emitting particles on X axis.
  14174. */
  14175. minScaleX: number;
  14176. /**
  14177. * Maximum scale of emitting particles on X axis.
  14178. */
  14179. maxScaleX: number;
  14180. /**
  14181. * Minimum scale of emitting particles on Y axis.
  14182. */
  14183. minScaleY: number;
  14184. /**
  14185. * Maximum scale of emitting particles on Y axis.
  14186. */
  14187. maxScaleY: number;
  14188. /**
  14189. * Gets or sets the minimal initial rotation in radians.
  14190. */
  14191. minInitialRotation: number;
  14192. /**
  14193. * Gets or sets the maximal initial rotation in radians.
  14194. */
  14195. maxInitialRotation: number;
  14196. /**
  14197. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14198. */
  14199. minAngularSpeed: number;
  14200. /**
  14201. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14202. */
  14203. maxAngularSpeed: number;
  14204. /**
  14205. * The texture used to render each particle. (this can be a spritesheet)
  14206. */
  14207. particleTexture: Nullable<Texture>;
  14208. /**
  14209. * The layer mask we are rendering the particles through.
  14210. */
  14211. layerMask: number;
  14212. /**
  14213. * This can help using your own shader to render the particle system.
  14214. * The according effect will be created
  14215. */
  14216. customShader: any;
  14217. /**
  14218. * By default particle system starts as soon as they are created. This prevents the
  14219. * automatic start to happen and let you decide when to start emitting particles.
  14220. */
  14221. preventAutoStart: boolean;
  14222. private _noiseTexture;
  14223. /**
  14224. * Gets or sets a texture used to add random noise to particle positions
  14225. */
  14226. noiseTexture: Nullable<ProceduralTexture>;
  14227. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14228. noiseStrength: Vector3;
  14229. /**
  14230. * Callback triggered when the particle animation is ending.
  14231. */
  14232. onAnimationEnd: Nullable<() => void>;
  14233. /**
  14234. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14235. */
  14236. blendMode: number;
  14237. /**
  14238. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14239. * to override the particles.
  14240. */
  14241. forceDepthWrite: boolean;
  14242. /** 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 */
  14243. preWarmCycles: number;
  14244. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14245. preWarmStepOffset: number;
  14246. /**
  14247. * 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)
  14248. */
  14249. spriteCellChangeSpeed: number;
  14250. /**
  14251. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14252. */
  14253. startSpriteCellID: number;
  14254. /**
  14255. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14256. */
  14257. endSpriteCellID: number;
  14258. /**
  14259. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14260. */
  14261. spriteCellWidth: number;
  14262. /**
  14263. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14264. */
  14265. spriteCellHeight: number;
  14266. /**
  14267. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14268. */
  14269. spriteRandomStartCell: boolean;
  14270. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14271. translationPivot: Vector2;
  14272. /** @hidden */
  14273. protected _isAnimationSheetEnabled: boolean;
  14274. /**
  14275. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14276. */
  14277. beginAnimationOnStart: boolean;
  14278. /**
  14279. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14280. */
  14281. beginAnimationFrom: number;
  14282. /**
  14283. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14284. */
  14285. beginAnimationTo: number;
  14286. /**
  14287. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14288. */
  14289. beginAnimationLoop: boolean;
  14290. /**
  14291. * Gets or sets a world offset applied to all particles
  14292. */
  14293. worldOffset: Vector3;
  14294. /**
  14295. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14296. */
  14297. isAnimationSheetEnabled: boolean;
  14298. /**
  14299. * Get hosting scene
  14300. * @returns the scene
  14301. */
  14302. getScene(): Scene;
  14303. /**
  14304. * You can use gravity if you want to give an orientation to your particles.
  14305. */
  14306. gravity: Vector3;
  14307. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14308. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14309. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14310. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14311. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14312. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14313. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14314. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14315. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14316. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14317. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14318. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14319. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14320. /**
  14321. * Defines the delay in milliseconds before starting the system (0 by default)
  14322. */
  14323. startDelay: number;
  14324. /**
  14325. * Gets the current list of drag gradients.
  14326. * You must use addDragGradient and removeDragGradient to udpate this list
  14327. * @returns the list of drag gradients
  14328. */
  14329. getDragGradients(): Nullable<Array<FactorGradient>>;
  14330. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14331. limitVelocityDamping: number;
  14332. /**
  14333. * Gets the current list of limit velocity gradients.
  14334. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14335. * @returns the list of limit velocity gradients
  14336. */
  14337. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14338. /**
  14339. * Gets the current list of color gradients.
  14340. * You must use addColorGradient and removeColorGradient to udpate this list
  14341. * @returns the list of color gradients
  14342. */
  14343. getColorGradients(): Nullable<Array<ColorGradient>>;
  14344. /**
  14345. * Gets the current list of size gradients.
  14346. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14347. * @returns the list of size gradients
  14348. */
  14349. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14350. /**
  14351. * Gets the current list of color remap gradients.
  14352. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14353. * @returns the list of color remap gradients
  14354. */
  14355. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14356. /**
  14357. * Gets the current list of alpha remap gradients.
  14358. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14359. * @returns the list of alpha remap gradients
  14360. */
  14361. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14362. /**
  14363. * Gets the current list of life time gradients.
  14364. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14365. * @returns the list of life time gradients
  14366. */
  14367. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14368. /**
  14369. * Gets the current list of angular speed gradients.
  14370. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14371. * @returns the list of angular speed gradients
  14372. */
  14373. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14374. /**
  14375. * Gets the current list of velocity gradients.
  14376. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14377. * @returns the list of velocity gradients
  14378. */
  14379. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14380. /**
  14381. * Gets the current list of start size gradients.
  14382. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14383. * @returns the list of start size gradients
  14384. */
  14385. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14386. /**
  14387. * Gets the current list of emit rate gradients.
  14388. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14389. * @returns the list of emit rate gradients
  14390. */
  14391. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14392. /**
  14393. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14394. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14395. */
  14396. direction1: Vector3;
  14397. /**
  14398. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14399. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14400. */
  14401. direction2: Vector3;
  14402. /**
  14403. * 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.
  14404. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14405. */
  14406. minEmitBox: Vector3;
  14407. /**
  14408. * 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.
  14409. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14410. */
  14411. maxEmitBox: Vector3;
  14412. /**
  14413. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14414. */
  14415. color1: Color4;
  14416. /**
  14417. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14418. */
  14419. color2: Color4;
  14420. /**
  14421. * Color the particle will have at the end of its lifetime
  14422. */
  14423. colorDead: Color4;
  14424. /**
  14425. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14426. */
  14427. textureMask: Color4;
  14428. /**
  14429. * The particle emitter type defines the emitter used by the particle system.
  14430. * It can be for example box, sphere, or cone...
  14431. */
  14432. particleEmitterType: IParticleEmitterType;
  14433. /** @hidden */
  14434. _isSubEmitter: boolean;
  14435. /**
  14436. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14437. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14438. */
  14439. billboardMode: number;
  14440. protected _isBillboardBased: boolean;
  14441. /**
  14442. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14443. */
  14444. isBillboardBased: boolean;
  14445. /**
  14446. * The scene the particle system belongs to.
  14447. */
  14448. protected _scene: Scene;
  14449. /**
  14450. * Local cache of defines for image processing.
  14451. */
  14452. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14453. /**
  14454. * Default configuration related to image processing available in the standard Material.
  14455. */
  14456. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14457. /**
  14458. * Gets the image processing configuration used either in this material.
  14459. */
  14460. /**
  14461. * Sets the Default image processing configuration used either in the this material.
  14462. *
  14463. * If sets to null, the scene one is in use.
  14464. */
  14465. imageProcessingConfiguration: ImageProcessingConfiguration;
  14466. /**
  14467. * Attaches a new image processing configuration to the Standard Material.
  14468. * @param configuration
  14469. */
  14470. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14471. /** @hidden */
  14472. protected _reset(): void;
  14473. /** @hidden */
  14474. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14475. /**
  14476. * Instantiates a particle system.
  14477. * 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.
  14478. * @param name The name of the particle system
  14479. */
  14480. constructor(name: string);
  14481. /**
  14482. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14483. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14484. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14485. * @returns the emitter
  14486. */
  14487. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14488. /**
  14489. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14490. * @param radius The radius of the hemisphere to emit from
  14491. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14492. * @returns the emitter
  14493. */
  14494. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14495. /**
  14496. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14497. * @param radius The radius of the sphere to emit from
  14498. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14499. * @returns the emitter
  14500. */
  14501. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14502. /**
  14503. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14504. * @param radius The radius of the sphere to emit from
  14505. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14506. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14507. * @returns the emitter
  14508. */
  14509. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14510. /**
  14511. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14512. * @param radius The radius of the emission cylinder
  14513. * @param height The height of the emission cylinder
  14514. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14515. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14516. * @returns the emitter
  14517. */
  14518. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14519. /**
  14520. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14521. * @param radius The radius of the cylinder to emit from
  14522. * @param height The height of the emission cylinder
  14523. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14524. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14525. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14526. * @returns the emitter
  14527. */
  14528. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14529. /**
  14530. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14531. * @param radius The radius of the cone to emit from
  14532. * @param angle The base angle of the cone
  14533. * @returns the emitter
  14534. */
  14535. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14536. /**
  14537. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14538. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14539. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14540. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14541. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14542. * @returns the emitter
  14543. */
  14544. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14545. }
  14546. }
  14547. declare module "babylonjs/Particles/subEmitter" {
  14548. import { Scene } from "babylonjs/scene";
  14549. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14550. /**
  14551. * Type of sub emitter
  14552. */
  14553. export enum SubEmitterType {
  14554. /**
  14555. * Attached to the particle over it's lifetime
  14556. */
  14557. ATTACHED = 0,
  14558. /**
  14559. * Created when the particle dies
  14560. */
  14561. END = 1
  14562. }
  14563. /**
  14564. * Sub emitter class used to emit particles from an existing particle
  14565. */
  14566. export class SubEmitter {
  14567. /**
  14568. * the particle system to be used by the sub emitter
  14569. */
  14570. particleSystem: ParticleSystem;
  14571. /**
  14572. * Type of the submitter (Default: END)
  14573. */
  14574. type: SubEmitterType;
  14575. /**
  14576. * 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)
  14577. * Note: This only is supported when using an emitter of type Mesh
  14578. */
  14579. inheritDirection: boolean;
  14580. /**
  14581. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14582. */
  14583. inheritedVelocityAmount: number;
  14584. /**
  14585. * Creates a sub emitter
  14586. * @param particleSystem the particle system to be used by the sub emitter
  14587. */
  14588. constructor(
  14589. /**
  14590. * the particle system to be used by the sub emitter
  14591. */
  14592. particleSystem: ParticleSystem);
  14593. /**
  14594. * Clones the sub emitter
  14595. * @returns the cloned sub emitter
  14596. */
  14597. clone(): SubEmitter;
  14598. /**
  14599. * Serialize current object to a JSON object
  14600. * @returns the serialized object
  14601. */
  14602. serialize(): any;
  14603. /** @hidden */
  14604. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14605. /**
  14606. * Creates a new SubEmitter from a serialized JSON version
  14607. * @param serializationObject defines the JSON object to read from
  14608. * @param scene defines the hosting scene
  14609. * @param rootUrl defines the rootUrl for data loading
  14610. * @returns a new SubEmitter
  14611. */
  14612. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14613. /** Release associated resources */
  14614. dispose(): void;
  14615. }
  14616. }
  14617. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14618. /** @hidden */
  14619. export var clipPlaneFragmentDeclaration: {
  14620. name: string;
  14621. shader: string;
  14622. };
  14623. }
  14624. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14625. /** @hidden */
  14626. export var imageProcessingDeclaration: {
  14627. name: string;
  14628. shader: string;
  14629. };
  14630. }
  14631. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14632. /** @hidden */
  14633. export var imageProcessingFunctions: {
  14634. name: string;
  14635. shader: string;
  14636. };
  14637. }
  14638. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14639. /** @hidden */
  14640. export var clipPlaneFragment: {
  14641. name: string;
  14642. shader: string;
  14643. };
  14644. }
  14645. declare module "babylonjs/Shaders/particles.fragment" {
  14646. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14647. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14648. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14649. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14650. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14651. /** @hidden */
  14652. export var particlesPixelShader: {
  14653. name: string;
  14654. shader: string;
  14655. };
  14656. }
  14657. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14658. /** @hidden */
  14659. export var clipPlaneVertexDeclaration: {
  14660. name: string;
  14661. shader: string;
  14662. };
  14663. }
  14664. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14665. /** @hidden */
  14666. export var clipPlaneVertex: {
  14667. name: string;
  14668. shader: string;
  14669. };
  14670. }
  14671. declare module "babylonjs/Shaders/particles.vertex" {
  14672. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14673. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14674. /** @hidden */
  14675. export var particlesVertexShader: {
  14676. name: string;
  14677. shader: string;
  14678. };
  14679. }
  14680. declare module "babylonjs/Particles/particleSystem" {
  14681. import { Nullable } from "babylonjs/types";
  14682. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14683. import { Observable } from "babylonjs/Misc/observable";
  14684. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14685. import { Effect } from "babylonjs/Materials/effect";
  14686. import { Scene, IDisposable } from "babylonjs/scene";
  14687. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14688. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14689. import { Particle } from "babylonjs/Particles/particle";
  14690. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14691. import "babylonjs/Shaders/particles.fragment";
  14692. import "babylonjs/Shaders/particles.vertex";
  14693. /**
  14694. * This represents a particle system in Babylon.
  14695. * 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.
  14696. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14697. * @example https://doc.babylonjs.com/babylon101/particles
  14698. */
  14699. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14700. /**
  14701. * Billboard mode will only apply to Y axis
  14702. */
  14703. static readonly BILLBOARDMODE_Y: number;
  14704. /**
  14705. * Billboard mode will apply to all axes
  14706. */
  14707. static readonly BILLBOARDMODE_ALL: number;
  14708. /**
  14709. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14710. */
  14711. static readonly BILLBOARDMODE_STRETCHED: number;
  14712. /**
  14713. * This function can be defined to provide custom update for active particles.
  14714. * This function will be called instead of regular update (age, position, color, etc.).
  14715. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14716. */
  14717. updateFunction: (particles: Particle[]) => void;
  14718. private _emitterWorldMatrix;
  14719. /**
  14720. * This function can be defined to specify initial direction for every new particle.
  14721. * It by default use the emitterType defined function
  14722. */
  14723. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14724. /**
  14725. * This function can be defined to specify initial position for every new particle.
  14726. * It by default use the emitterType defined function
  14727. */
  14728. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14729. /**
  14730. * @hidden
  14731. */
  14732. _inheritedVelocityOffset: Vector3;
  14733. /**
  14734. * An event triggered when the system is disposed
  14735. */
  14736. onDisposeObservable: Observable<ParticleSystem>;
  14737. private _onDisposeObserver;
  14738. /**
  14739. * Sets a callback that will be triggered when the system is disposed
  14740. */
  14741. onDispose: () => void;
  14742. private _particles;
  14743. private _epsilon;
  14744. private _capacity;
  14745. private _stockParticles;
  14746. private _newPartsExcess;
  14747. private _vertexData;
  14748. private _vertexBuffer;
  14749. private _vertexBuffers;
  14750. private _spriteBuffer;
  14751. private _indexBuffer;
  14752. private _effect;
  14753. private _customEffect;
  14754. private _cachedDefines;
  14755. private _scaledColorStep;
  14756. private _colorDiff;
  14757. private _scaledDirection;
  14758. private _scaledGravity;
  14759. private _currentRenderId;
  14760. private _alive;
  14761. private _useInstancing;
  14762. private _started;
  14763. private _stopped;
  14764. private _actualFrame;
  14765. private _scaledUpdateSpeed;
  14766. private _vertexBufferSize;
  14767. /** @hidden */
  14768. _currentEmitRateGradient: Nullable<FactorGradient>;
  14769. /** @hidden */
  14770. _currentEmitRate1: number;
  14771. /** @hidden */
  14772. _currentEmitRate2: number;
  14773. /** @hidden */
  14774. _currentStartSizeGradient: Nullable<FactorGradient>;
  14775. /** @hidden */
  14776. _currentStartSize1: number;
  14777. /** @hidden */
  14778. _currentStartSize2: number;
  14779. private readonly _rawTextureWidth;
  14780. private _rampGradientsTexture;
  14781. private _useRampGradients;
  14782. /** Gets or sets a boolean indicating that ramp gradients must be used
  14783. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14784. */
  14785. useRampGradients: boolean;
  14786. /**
  14787. * 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.
  14788. * 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: [])
  14789. */
  14790. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14791. private _subEmitters;
  14792. /**
  14793. * @hidden
  14794. * If the particle systems emitter should be disposed when the particle system is disposed
  14795. */
  14796. _disposeEmitterOnDispose: boolean;
  14797. /**
  14798. * The current active Sub-systems, this property is used by the root particle system only.
  14799. */
  14800. activeSubSystems: Array<ParticleSystem>;
  14801. private _rootParticleSystem;
  14802. /**
  14803. * Gets the current list of active particles
  14804. */
  14805. readonly particles: Particle[];
  14806. /**
  14807. * Returns the string "ParticleSystem"
  14808. * @returns a string containing the class name
  14809. */
  14810. getClassName(): string;
  14811. /**
  14812. * Instantiates a particle system.
  14813. * 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.
  14814. * @param name The name of the particle system
  14815. * @param capacity The max number of particles alive at the same time
  14816. * @param scene The scene the particle system belongs to
  14817. * @param customEffect a custom effect used to change the way particles are rendered by default
  14818. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14819. * @param epsilon Offset used to render the particles
  14820. */
  14821. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14822. private _addFactorGradient;
  14823. private _removeFactorGradient;
  14824. /**
  14825. * Adds a new life time gradient
  14826. * @param gradient defines the gradient to use (between 0 and 1)
  14827. * @param factor defines the life time factor to affect to the specified gradient
  14828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14829. * @returns the current particle system
  14830. */
  14831. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14832. /**
  14833. * Remove a specific life time gradient
  14834. * @param gradient defines the gradient to remove
  14835. * @returns the current particle system
  14836. */
  14837. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14838. /**
  14839. * Adds a new size gradient
  14840. * @param gradient defines the gradient to use (between 0 and 1)
  14841. * @param factor defines the size factor to affect to the specified gradient
  14842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14843. * @returns the current particle system
  14844. */
  14845. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14846. /**
  14847. * Remove a specific size gradient
  14848. * @param gradient defines the gradient to remove
  14849. * @returns the current particle system
  14850. */
  14851. removeSizeGradient(gradient: number): IParticleSystem;
  14852. /**
  14853. * Adds a new color remap gradient
  14854. * @param gradient defines the gradient to use (between 0 and 1)
  14855. * @param min defines the color remap minimal range
  14856. * @param max defines the color remap maximal range
  14857. * @returns the current particle system
  14858. */
  14859. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14860. /**
  14861. * Remove a specific color remap gradient
  14862. * @param gradient defines the gradient to remove
  14863. * @returns the current particle system
  14864. */
  14865. removeColorRemapGradient(gradient: number): IParticleSystem;
  14866. /**
  14867. * Adds a new alpha remap gradient
  14868. * @param gradient defines the gradient to use (between 0 and 1)
  14869. * @param min defines the alpha remap minimal range
  14870. * @param max defines the alpha remap maximal range
  14871. * @returns the current particle system
  14872. */
  14873. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14874. /**
  14875. * Remove a specific alpha remap gradient
  14876. * @param gradient defines the gradient to remove
  14877. * @returns the current particle system
  14878. */
  14879. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14880. /**
  14881. * Adds a new angular speed gradient
  14882. * @param gradient defines the gradient to use (between 0 and 1)
  14883. * @param factor defines the angular speed to affect to the specified gradient
  14884. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14885. * @returns the current particle system
  14886. */
  14887. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14888. /**
  14889. * Remove a specific angular speed gradient
  14890. * @param gradient defines the gradient to remove
  14891. * @returns the current particle system
  14892. */
  14893. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14894. /**
  14895. * Adds a new velocity gradient
  14896. * @param gradient defines the gradient to use (between 0 and 1)
  14897. * @param factor defines the velocity to affect to the specified gradient
  14898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14899. * @returns the current particle system
  14900. */
  14901. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14902. /**
  14903. * Remove a specific velocity gradient
  14904. * @param gradient defines the gradient to remove
  14905. * @returns the current particle system
  14906. */
  14907. removeVelocityGradient(gradient: number): IParticleSystem;
  14908. /**
  14909. * Adds a new limit velocity gradient
  14910. * @param gradient defines the gradient to use (between 0 and 1)
  14911. * @param factor defines the limit velocity value to affect to the specified gradient
  14912. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14913. * @returns the current particle system
  14914. */
  14915. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14916. /**
  14917. * Remove a specific limit velocity gradient
  14918. * @param gradient defines the gradient to remove
  14919. * @returns the current particle system
  14920. */
  14921. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14922. /**
  14923. * Adds a new drag gradient
  14924. * @param gradient defines the gradient to use (between 0 and 1)
  14925. * @param factor defines the drag value to affect to the specified gradient
  14926. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14927. * @returns the current particle system
  14928. */
  14929. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14930. /**
  14931. * Remove a specific drag gradient
  14932. * @param gradient defines the gradient to remove
  14933. * @returns the current particle system
  14934. */
  14935. removeDragGradient(gradient: number): IParticleSystem;
  14936. /**
  14937. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14938. * @param gradient defines the gradient to use (between 0 and 1)
  14939. * @param factor defines the emit rate value to affect to the specified gradient
  14940. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14941. * @returns the current particle system
  14942. */
  14943. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14944. /**
  14945. * Remove a specific emit rate gradient
  14946. * @param gradient defines the gradient to remove
  14947. * @returns the current particle system
  14948. */
  14949. removeEmitRateGradient(gradient: number): IParticleSystem;
  14950. /**
  14951. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14952. * @param gradient defines the gradient to use (between 0 and 1)
  14953. * @param factor defines the start size value to affect to the specified gradient
  14954. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14955. * @returns the current particle system
  14956. */
  14957. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14958. /**
  14959. * Remove a specific start size gradient
  14960. * @param gradient defines the gradient to remove
  14961. * @returns the current particle system
  14962. */
  14963. removeStartSizeGradient(gradient: number): IParticleSystem;
  14964. private _createRampGradientTexture;
  14965. /**
  14966. * Gets the current list of ramp gradients.
  14967. * You must use addRampGradient and removeRampGradient to udpate this list
  14968. * @returns the list of ramp gradients
  14969. */
  14970. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14971. /**
  14972. * Adds a new ramp gradient used to remap particle colors
  14973. * @param gradient defines the gradient to use (between 0 and 1)
  14974. * @param color defines the color to affect to the specified gradient
  14975. * @returns the current particle system
  14976. */
  14977. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14978. /**
  14979. * Remove a specific ramp gradient
  14980. * @param gradient defines the gradient to remove
  14981. * @returns the current particle system
  14982. */
  14983. removeRampGradient(gradient: number): ParticleSystem;
  14984. /**
  14985. * Adds a new color gradient
  14986. * @param gradient defines the gradient to use (between 0 and 1)
  14987. * @param color1 defines the color to affect to the specified gradient
  14988. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14989. * @returns this particle system
  14990. */
  14991. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14992. /**
  14993. * Remove a specific color gradient
  14994. * @param gradient defines the gradient to remove
  14995. * @returns this particle system
  14996. */
  14997. removeColorGradient(gradient: number): IParticleSystem;
  14998. private _fetchR;
  14999. protected _reset(): void;
  15000. private _resetEffect;
  15001. private _createVertexBuffers;
  15002. private _createIndexBuffer;
  15003. /**
  15004. * Gets the maximum number of particles active at the same time.
  15005. * @returns The max number of active particles.
  15006. */
  15007. getCapacity(): number;
  15008. /**
  15009. * Gets whether there are still active particles in the system.
  15010. * @returns True if it is alive, otherwise false.
  15011. */
  15012. isAlive(): boolean;
  15013. /**
  15014. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15015. * @returns True if it has been started, otherwise false.
  15016. */
  15017. isStarted(): boolean;
  15018. private _prepareSubEmitterInternalArray;
  15019. /**
  15020. * Starts the particle system and begins to emit
  15021. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15022. */
  15023. start(delay?: number): void;
  15024. /**
  15025. * Stops the particle system.
  15026. * @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.
  15027. */
  15028. stop(stopSubEmitters?: boolean): void;
  15029. /**
  15030. * Remove all active particles
  15031. */
  15032. reset(): void;
  15033. /**
  15034. * @hidden (for internal use only)
  15035. */
  15036. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15037. /**
  15038. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15039. * Its lifetime will start back at 0.
  15040. */
  15041. recycleParticle: (particle: Particle) => void;
  15042. private _stopSubEmitters;
  15043. private _createParticle;
  15044. private _removeFromRoot;
  15045. private _emitFromParticle;
  15046. private _update;
  15047. /** @hidden */
  15048. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15049. /** @hidden */
  15050. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15051. /** @hidden */
  15052. private _getEffect;
  15053. /**
  15054. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15055. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15056. */
  15057. animate(preWarmOnly?: boolean): void;
  15058. private _appendParticleVertices;
  15059. /**
  15060. * Rebuilds the particle system.
  15061. */
  15062. rebuild(): void;
  15063. /**
  15064. * Is this system ready to be used/rendered
  15065. * @return true if the system is ready
  15066. */
  15067. isReady(): boolean;
  15068. private _render;
  15069. /**
  15070. * Renders the particle system in its current state.
  15071. * @returns the current number of particles
  15072. */
  15073. render(): number;
  15074. /**
  15075. * Disposes the particle system and free the associated resources
  15076. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15077. */
  15078. dispose(disposeTexture?: boolean): void;
  15079. /**
  15080. * Clones the particle system.
  15081. * @param name The name of the cloned object
  15082. * @param newEmitter The new emitter to use
  15083. * @returns the cloned particle system
  15084. */
  15085. clone(name: string, newEmitter: any): ParticleSystem;
  15086. /**
  15087. * Serializes the particle system to a JSON object.
  15088. * @returns the JSON object
  15089. */
  15090. serialize(): any;
  15091. /** @hidden */
  15092. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15093. /** @hidden */
  15094. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15095. /**
  15096. * Parses a JSON object to create a particle system.
  15097. * @param parsedParticleSystem The JSON object to parse
  15098. * @param scene The scene to create the particle system in
  15099. * @param rootUrl The root url to use to load external dependencies like texture
  15100. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15101. * @returns the Parsed particle system
  15102. */
  15103. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15104. }
  15105. }
  15106. declare module "babylonjs/Particles/particle" {
  15107. import { Nullable } from "babylonjs/types";
  15108. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15109. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15110. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15111. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15112. /**
  15113. * A particle represents one of the element emitted by a particle system.
  15114. * This is mainly define by its coordinates, direction, velocity and age.
  15115. */
  15116. export class Particle {
  15117. /**
  15118. * The particle system the particle belongs to.
  15119. */
  15120. particleSystem: ParticleSystem;
  15121. private static _Count;
  15122. /**
  15123. * Unique ID of the particle
  15124. */
  15125. id: number;
  15126. /**
  15127. * The world position of the particle in the scene.
  15128. */
  15129. position: Vector3;
  15130. /**
  15131. * The world direction of the particle in the scene.
  15132. */
  15133. direction: Vector3;
  15134. /**
  15135. * The color of the particle.
  15136. */
  15137. color: Color4;
  15138. /**
  15139. * The color change of the particle per step.
  15140. */
  15141. colorStep: Color4;
  15142. /**
  15143. * Defines how long will the life of the particle be.
  15144. */
  15145. lifeTime: number;
  15146. /**
  15147. * The current age of the particle.
  15148. */
  15149. age: number;
  15150. /**
  15151. * The current size of the particle.
  15152. */
  15153. size: number;
  15154. /**
  15155. * The current scale of the particle.
  15156. */
  15157. scale: Vector2;
  15158. /**
  15159. * The current angle of the particle.
  15160. */
  15161. angle: number;
  15162. /**
  15163. * Defines how fast is the angle changing.
  15164. */
  15165. angularSpeed: number;
  15166. /**
  15167. * Defines the cell index used by the particle to be rendered from a sprite.
  15168. */
  15169. cellIndex: number;
  15170. /**
  15171. * The information required to support color remapping
  15172. */
  15173. remapData: Vector4;
  15174. /** @hidden */
  15175. _randomCellOffset?: number;
  15176. /** @hidden */
  15177. _initialDirection: Nullable<Vector3>;
  15178. /** @hidden */
  15179. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15180. /** @hidden */
  15181. _initialStartSpriteCellID: number;
  15182. /** @hidden */
  15183. _initialEndSpriteCellID: number;
  15184. /** @hidden */
  15185. _currentColorGradient: Nullable<ColorGradient>;
  15186. /** @hidden */
  15187. _currentColor1: Color4;
  15188. /** @hidden */
  15189. _currentColor2: Color4;
  15190. /** @hidden */
  15191. _currentSizeGradient: Nullable<FactorGradient>;
  15192. /** @hidden */
  15193. _currentSize1: number;
  15194. /** @hidden */
  15195. _currentSize2: number;
  15196. /** @hidden */
  15197. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15198. /** @hidden */
  15199. _currentAngularSpeed1: number;
  15200. /** @hidden */
  15201. _currentAngularSpeed2: number;
  15202. /** @hidden */
  15203. _currentVelocityGradient: Nullable<FactorGradient>;
  15204. /** @hidden */
  15205. _currentVelocity1: number;
  15206. /** @hidden */
  15207. _currentVelocity2: number;
  15208. /** @hidden */
  15209. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15210. /** @hidden */
  15211. _currentLimitVelocity1: number;
  15212. /** @hidden */
  15213. _currentLimitVelocity2: number;
  15214. /** @hidden */
  15215. _currentDragGradient: Nullable<FactorGradient>;
  15216. /** @hidden */
  15217. _currentDrag1: number;
  15218. /** @hidden */
  15219. _currentDrag2: number;
  15220. /** @hidden */
  15221. _randomNoiseCoordinates1: Vector3;
  15222. /** @hidden */
  15223. _randomNoiseCoordinates2: Vector3;
  15224. /**
  15225. * Creates a new instance Particle
  15226. * @param particleSystem the particle system the particle belongs to
  15227. */
  15228. constructor(
  15229. /**
  15230. * The particle system the particle belongs to.
  15231. */
  15232. particleSystem: ParticleSystem);
  15233. private updateCellInfoFromSystem;
  15234. /**
  15235. * Defines how the sprite cell index is updated for the particle
  15236. */
  15237. updateCellIndex(): void;
  15238. /** @hidden */
  15239. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15240. /** @hidden */
  15241. _inheritParticleInfoToSubEmitters(): void;
  15242. /** @hidden */
  15243. _reset(): void;
  15244. /**
  15245. * Copy the properties of particle to another one.
  15246. * @param other the particle to copy the information to.
  15247. */
  15248. copyTo(other: Particle): void;
  15249. }
  15250. }
  15251. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15252. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15253. import { Effect } from "babylonjs/Materials/effect";
  15254. import { Particle } from "babylonjs/Particles/particle";
  15255. /**
  15256. * Particle emitter represents a volume emitting particles.
  15257. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15258. */
  15259. export interface IParticleEmitterType {
  15260. /**
  15261. * Called by the particle System when the direction is computed for the created particle.
  15262. * @param worldMatrix is the world matrix of the particle system
  15263. * @param directionToUpdate is the direction vector to update with the result
  15264. * @param particle is the particle we are computed the direction for
  15265. */
  15266. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15267. /**
  15268. * Called by the particle System when the position is computed for the created particle.
  15269. * @param worldMatrix is the world matrix of the particle system
  15270. * @param positionToUpdate is the position vector to update with the result
  15271. * @param particle is the particle we are computed the position for
  15272. */
  15273. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15274. /**
  15275. * Clones the current emitter and returns a copy of it
  15276. * @returns the new emitter
  15277. */
  15278. clone(): IParticleEmitterType;
  15279. /**
  15280. * Called by the GPUParticleSystem to setup the update shader
  15281. * @param effect defines the update shader
  15282. */
  15283. applyToShader(effect: Effect): void;
  15284. /**
  15285. * Returns a string to use to update the GPU particles update shader
  15286. * @returns the effect defines string
  15287. */
  15288. getEffectDefines(): string;
  15289. /**
  15290. * Returns a string representing the class name
  15291. * @returns a string containing the class name
  15292. */
  15293. getClassName(): string;
  15294. /**
  15295. * Serializes the particle system to a JSON object.
  15296. * @returns the JSON object
  15297. */
  15298. serialize(): any;
  15299. /**
  15300. * Parse properties from a JSON object
  15301. * @param serializationObject defines the JSON object
  15302. */
  15303. parse(serializationObject: any): void;
  15304. }
  15305. }
  15306. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15307. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15308. import { Effect } from "babylonjs/Materials/effect";
  15309. import { Particle } from "babylonjs/Particles/particle";
  15310. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15311. /**
  15312. * Particle emitter emitting particles from the inside of a box.
  15313. * It emits the particles randomly between 2 given directions.
  15314. */
  15315. export class BoxParticleEmitter implements IParticleEmitterType {
  15316. /**
  15317. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15318. */
  15319. direction1: Vector3;
  15320. /**
  15321. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15322. */
  15323. direction2: Vector3;
  15324. /**
  15325. * 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.
  15326. */
  15327. minEmitBox: Vector3;
  15328. /**
  15329. * 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.
  15330. */
  15331. maxEmitBox: Vector3;
  15332. /**
  15333. * Creates a new instance BoxParticleEmitter
  15334. */
  15335. constructor();
  15336. /**
  15337. * Called by the particle System when the direction is computed for the created particle.
  15338. * @param worldMatrix is the world matrix of the particle system
  15339. * @param directionToUpdate is the direction vector to update with the result
  15340. * @param particle is the particle we are computed the direction for
  15341. */
  15342. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15343. /**
  15344. * Called by the particle System when the position is computed for the created particle.
  15345. * @param worldMatrix is the world matrix of the particle system
  15346. * @param positionToUpdate is the position vector to update with the result
  15347. * @param particle is the particle we are computed the position for
  15348. */
  15349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15350. /**
  15351. * Clones the current emitter and returns a copy of it
  15352. * @returns the new emitter
  15353. */
  15354. clone(): BoxParticleEmitter;
  15355. /**
  15356. * Called by the GPUParticleSystem to setup the update shader
  15357. * @param effect defines the update shader
  15358. */
  15359. applyToShader(effect: Effect): void;
  15360. /**
  15361. * Returns a string to use to update the GPU particles update shader
  15362. * @returns a string containng the defines string
  15363. */
  15364. getEffectDefines(): string;
  15365. /**
  15366. * Returns the string "BoxParticleEmitter"
  15367. * @returns a string containing the class name
  15368. */
  15369. getClassName(): string;
  15370. /**
  15371. * Serializes the particle system to a JSON object.
  15372. * @returns the JSON object
  15373. */
  15374. serialize(): any;
  15375. /**
  15376. * Parse properties from a JSON object
  15377. * @param serializationObject defines the JSON object
  15378. */
  15379. parse(serializationObject: any): void;
  15380. }
  15381. }
  15382. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15383. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15384. import { Effect } from "babylonjs/Materials/effect";
  15385. import { Particle } from "babylonjs/Particles/particle";
  15386. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15387. /**
  15388. * Particle emitter emitting particles from the inside of a cone.
  15389. * It emits the particles alongside the cone volume from the base to the particle.
  15390. * The emission direction might be randomized.
  15391. */
  15392. export class ConeParticleEmitter implements IParticleEmitterType {
  15393. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15394. directionRandomizer: number;
  15395. private _radius;
  15396. private _angle;
  15397. private _height;
  15398. /**
  15399. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15400. */
  15401. radiusRange: number;
  15402. /**
  15403. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15404. */
  15405. heightRange: number;
  15406. /**
  15407. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15408. */
  15409. emitFromSpawnPointOnly: boolean;
  15410. /**
  15411. * Gets or sets the radius of the emission cone
  15412. */
  15413. radius: number;
  15414. /**
  15415. * Gets or sets the angle of the emission cone
  15416. */
  15417. angle: number;
  15418. private _buildHeight;
  15419. /**
  15420. * Creates a new instance ConeParticleEmitter
  15421. * @param radius the radius of the emission cone (1 by default)
  15422. * @param angle the cone base angle (PI by default)
  15423. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15424. */
  15425. constructor(radius?: number, angle?: number,
  15426. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15427. directionRandomizer?: number);
  15428. /**
  15429. * Called by the particle System when the direction is computed for the created particle.
  15430. * @param worldMatrix is the world matrix of the particle system
  15431. * @param directionToUpdate is the direction vector to update with the result
  15432. * @param particle is the particle we are computed the direction for
  15433. */
  15434. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15435. /**
  15436. * Called by the particle System when the position is computed for the created particle.
  15437. * @param worldMatrix is the world matrix of the particle system
  15438. * @param positionToUpdate is the position vector to update with the result
  15439. * @param particle is the particle we are computed the position for
  15440. */
  15441. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15442. /**
  15443. * Clones the current emitter and returns a copy of it
  15444. * @returns the new emitter
  15445. */
  15446. clone(): ConeParticleEmitter;
  15447. /**
  15448. * Called by the GPUParticleSystem to setup the update shader
  15449. * @param effect defines the update shader
  15450. */
  15451. applyToShader(effect: Effect): void;
  15452. /**
  15453. * Returns a string to use to update the GPU particles update shader
  15454. * @returns a string containng the defines string
  15455. */
  15456. getEffectDefines(): string;
  15457. /**
  15458. * Returns the string "ConeParticleEmitter"
  15459. * @returns a string containing the class name
  15460. */
  15461. getClassName(): string;
  15462. /**
  15463. * Serializes the particle system to a JSON object.
  15464. * @returns the JSON object
  15465. */
  15466. serialize(): any;
  15467. /**
  15468. * Parse properties from a JSON object
  15469. * @param serializationObject defines the JSON object
  15470. */
  15471. parse(serializationObject: any): void;
  15472. }
  15473. }
  15474. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15475. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15476. import { Effect } from "babylonjs/Materials/effect";
  15477. import { Particle } from "babylonjs/Particles/particle";
  15478. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15479. /**
  15480. * Particle emitter emitting particles from the inside of a cylinder.
  15481. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15482. */
  15483. export class CylinderParticleEmitter implements IParticleEmitterType {
  15484. /**
  15485. * The radius of the emission cylinder.
  15486. */
  15487. radius: number;
  15488. /**
  15489. * The height of the emission cylinder.
  15490. */
  15491. height: number;
  15492. /**
  15493. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15494. */
  15495. radiusRange: number;
  15496. /**
  15497. * How much to randomize the particle direction [0-1].
  15498. */
  15499. directionRandomizer: number;
  15500. /**
  15501. * Creates a new instance CylinderParticleEmitter
  15502. * @param radius the radius of the emission cylinder (1 by default)
  15503. * @param height the height of the emission cylinder (1 by default)
  15504. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15505. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15506. */
  15507. constructor(
  15508. /**
  15509. * The radius of the emission cylinder.
  15510. */
  15511. radius?: number,
  15512. /**
  15513. * The height of the emission cylinder.
  15514. */
  15515. height?: number,
  15516. /**
  15517. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15518. */
  15519. radiusRange?: number,
  15520. /**
  15521. * How much to randomize the particle direction [0-1].
  15522. */
  15523. directionRandomizer?: number);
  15524. /**
  15525. * Called by the particle System when the direction is computed for the created particle.
  15526. * @param worldMatrix is the world matrix of the particle system
  15527. * @param directionToUpdate is the direction vector to update with the result
  15528. * @param particle is the particle we are computed the direction for
  15529. */
  15530. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15531. /**
  15532. * Called by the particle System when the position is computed for the created particle.
  15533. * @param worldMatrix is the world matrix of the particle system
  15534. * @param positionToUpdate is the position vector to update with the result
  15535. * @param particle is the particle we are computed the position for
  15536. */
  15537. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15538. /**
  15539. * Clones the current emitter and returns a copy of it
  15540. * @returns the new emitter
  15541. */
  15542. clone(): CylinderParticleEmitter;
  15543. /**
  15544. * Called by the GPUParticleSystem to setup the update shader
  15545. * @param effect defines the update shader
  15546. */
  15547. applyToShader(effect: Effect): void;
  15548. /**
  15549. * Returns a string to use to update the GPU particles update shader
  15550. * @returns a string containng the defines string
  15551. */
  15552. getEffectDefines(): string;
  15553. /**
  15554. * Returns the string "CylinderParticleEmitter"
  15555. * @returns a string containing the class name
  15556. */
  15557. getClassName(): string;
  15558. /**
  15559. * Serializes the particle system to a JSON object.
  15560. * @returns the JSON object
  15561. */
  15562. serialize(): any;
  15563. /**
  15564. * Parse properties from a JSON object
  15565. * @param serializationObject defines the JSON object
  15566. */
  15567. parse(serializationObject: any): void;
  15568. }
  15569. /**
  15570. * Particle emitter emitting particles from the inside of a cylinder.
  15571. * It emits the particles randomly between two vectors.
  15572. */
  15573. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15574. /**
  15575. * The min limit of the emission direction.
  15576. */
  15577. direction1: Vector3;
  15578. /**
  15579. * The max limit of the emission direction.
  15580. */
  15581. direction2: Vector3;
  15582. /**
  15583. * Creates a new instance CylinderDirectedParticleEmitter
  15584. * @param radius the radius of the emission cylinder (1 by default)
  15585. * @param height the height of the emission cylinder (1 by default)
  15586. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15587. * @param direction1 the min limit of the emission direction (up vector by default)
  15588. * @param direction2 the max limit of the emission direction (up vector by default)
  15589. */
  15590. constructor(radius?: number, height?: number, radiusRange?: number,
  15591. /**
  15592. * The min limit of the emission direction.
  15593. */
  15594. direction1?: Vector3,
  15595. /**
  15596. * The max limit of the emission direction.
  15597. */
  15598. direction2?: Vector3);
  15599. /**
  15600. * Called by the particle System when the direction is computed for the created particle.
  15601. * @param worldMatrix is the world matrix of the particle system
  15602. * @param directionToUpdate is the direction vector to update with the result
  15603. * @param particle is the particle we are computed the direction for
  15604. */
  15605. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15606. /**
  15607. * Clones the current emitter and returns a copy of it
  15608. * @returns the new emitter
  15609. */
  15610. clone(): CylinderDirectedParticleEmitter;
  15611. /**
  15612. * Called by the GPUParticleSystem to setup the update shader
  15613. * @param effect defines the update shader
  15614. */
  15615. applyToShader(effect: Effect): void;
  15616. /**
  15617. * Returns a string to use to update the GPU particles update shader
  15618. * @returns a string containng the defines string
  15619. */
  15620. getEffectDefines(): string;
  15621. /**
  15622. * Returns the string "CylinderDirectedParticleEmitter"
  15623. * @returns a string containing the class name
  15624. */
  15625. getClassName(): string;
  15626. /**
  15627. * Serializes the particle system to a JSON object.
  15628. * @returns the JSON object
  15629. */
  15630. serialize(): any;
  15631. /**
  15632. * Parse properties from a JSON object
  15633. * @param serializationObject defines the JSON object
  15634. */
  15635. parse(serializationObject: any): void;
  15636. }
  15637. }
  15638. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15639. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15640. import { Effect } from "babylonjs/Materials/effect";
  15641. import { Particle } from "babylonjs/Particles/particle";
  15642. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15643. /**
  15644. * Particle emitter emitting particles from the inside of a hemisphere.
  15645. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15646. */
  15647. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15648. /**
  15649. * The radius of the emission hemisphere.
  15650. */
  15651. radius: number;
  15652. /**
  15653. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15654. */
  15655. radiusRange: number;
  15656. /**
  15657. * How much to randomize the particle direction [0-1].
  15658. */
  15659. directionRandomizer: number;
  15660. /**
  15661. * Creates a new instance HemisphericParticleEmitter
  15662. * @param radius the radius of the emission hemisphere (1 by default)
  15663. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15664. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15665. */
  15666. constructor(
  15667. /**
  15668. * The radius of the emission hemisphere.
  15669. */
  15670. radius?: number,
  15671. /**
  15672. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15673. */
  15674. radiusRange?: number,
  15675. /**
  15676. * How much to randomize the particle direction [0-1].
  15677. */
  15678. directionRandomizer?: number);
  15679. /**
  15680. * Called by the particle System when the direction is computed for the created particle.
  15681. * @param worldMatrix is the world matrix of the particle system
  15682. * @param directionToUpdate is the direction vector to update with the result
  15683. * @param particle is the particle we are computed the direction for
  15684. */
  15685. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15686. /**
  15687. * Called by the particle System when the position is computed for the created particle.
  15688. * @param worldMatrix is the world matrix of the particle system
  15689. * @param positionToUpdate is the position vector to update with the result
  15690. * @param particle is the particle we are computed the position for
  15691. */
  15692. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15693. /**
  15694. * Clones the current emitter and returns a copy of it
  15695. * @returns the new emitter
  15696. */
  15697. clone(): HemisphericParticleEmitter;
  15698. /**
  15699. * Called by the GPUParticleSystem to setup the update shader
  15700. * @param effect defines the update shader
  15701. */
  15702. applyToShader(effect: Effect): void;
  15703. /**
  15704. * Returns a string to use to update the GPU particles update shader
  15705. * @returns a string containng the defines string
  15706. */
  15707. getEffectDefines(): string;
  15708. /**
  15709. * Returns the string "HemisphericParticleEmitter"
  15710. * @returns a string containing the class name
  15711. */
  15712. getClassName(): string;
  15713. /**
  15714. * Serializes the particle system to a JSON object.
  15715. * @returns the JSON object
  15716. */
  15717. serialize(): any;
  15718. /**
  15719. * Parse properties from a JSON object
  15720. * @param serializationObject defines the JSON object
  15721. */
  15722. parse(serializationObject: any): void;
  15723. }
  15724. }
  15725. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15726. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15727. import { Effect } from "babylonjs/Materials/effect";
  15728. import { Particle } from "babylonjs/Particles/particle";
  15729. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15730. /**
  15731. * Particle emitter emitting particles from a point.
  15732. * It emits the particles randomly between 2 given directions.
  15733. */
  15734. export class PointParticleEmitter implements IParticleEmitterType {
  15735. /**
  15736. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15737. */
  15738. direction1: Vector3;
  15739. /**
  15740. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15741. */
  15742. direction2: Vector3;
  15743. /**
  15744. * Creates a new instance PointParticleEmitter
  15745. */
  15746. constructor();
  15747. /**
  15748. * Called by the particle System when the direction is computed for the created particle.
  15749. * @param worldMatrix is the world matrix of the particle system
  15750. * @param directionToUpdate is the direction vector to update with the result
  15751. * @param particle is the particle we are computed the direction for
  15752. */
  15753. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15754. /**
  15755. * Called by the particle System when the position is computed for the created particle.
  15756. * @param worldMatrix is the world matrix of the particle system
  15757. * @param positionToUpdate is the position vector to update with the result
  15758. * @param particle is the particle we are computed the position for
  15759. */
  15760. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15761. /**
  15762. * Clones the current emitter and returns a copy of it
  15763. * @returns the new emitter
  15764. */
  15765. clone(): PointParticleEmitter;
  15766. /**
  15767. * Called by the GPUParticleSystem to setup the update shader
  15768. * @param effect defines the update shader
  15769. */
  15770. applyToShader(effect: Effect): void;
  15771. /**
  15772. * Returns a string to use to update the GPU particles update shader
  15773. * @returns a string containng the defines string
  15774. */
  15775. getEffectDefines(): string;
  15776. /**
  15777. * Returns the string "PointParticleEmitter"
  15778. * @returns a string containing the class name
  15779. */
  15780. getClassName(): string;
  15781. /**
  15782. * Serializes the particle system to a JSON object.
  15783. * @returns the JSON object
  15784. */
  15785. serialize(): any;
  15786. /**
  15787. * Parse properties from a JSON object
  15788. * @param serializationObject defines the JSON object
  15789. */
  15790. parse(serializationObject: any): void;
  15791. }
  15792. }
  15793. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15794. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15795. import { Effect } from "babylonjs/Materials/effect";
  15796. import { Particle } from "babylonjs/Particles/particle";
  15797. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15798. /**
  15799. * Particle emitter emitting particles from the inside of a sphere.
  15800. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15801. */
  15802. export class SphereParticleEmitter implements IParticleEmitterType {
  15803. /**
  15804. * The radius of the emission sphere.
  15805. */
  15806. radius: number;
  15807. /**
  15808. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15809. */
  15810. radiusRange: number;
  15811. /**
  15812. * How much to randomize the particle direction [0-1].
  15813. */
  15814. directionRandomizer: number;
  15815. /**
  15816. * Creates a new instance SphereParticleEmitter
  15817. * @param radius the radius of the emission sphere (1 by default)
  15818. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15819. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15820. */
  15821. constructor(
  15822. /**
  15823. * The radius of the emission sphere.
  15824. */
  15825. radius?: number,
  15826. /**
  15827. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15828. */
  15829. radiusRange?: number,
  15830. /**
  15831. * How much to randomize the particle direction [0-1].
  15832. */
  15833. directionRandomizer?: number);
  15834. /**
  15835. * Called by the particle System when the direction is computed for the created particle.
  15836. * @param worldMatrix is the world matrix of the particle system
  15837. * @param directionToUpdate is the direction vector to update with the result
  15838. * @param particle is the particle we are computed the direction for
  15839. */
  15840. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15841. /**
  15842. * Called by the particle System when the position is computed for the created particle.
  15843. * @param worldMatrix is the world matrix of the particle system
  15844. * @param positionToUpdate is the position vector to update with the result
  15845. * @param particle is the particle we are computed the position for
  15846. */
  15847. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15848. /**
  15849. * Clones the current emitter and returns a copy of it
  15850. * @returns the new emitter
  15851. */
  15852. clone(): SphereParticleEmitter;
  15853. /**
  15854. * Called by the GPUParticleSystem to setup the update shader
  15855. * @param effect defines the update shader
  15856. */
  15857. applyToShader(effect: Effect): void;
  15858. /**
  15859. * Returns a string to use to update the GPU particles update shader
  15860. * @returns a string containng the defines string
  15861. */
  15862. getEffectDefines(): string;
  15863. /**
  15864. * Returns the string "SphereParticleEmitter"
  15865. * @returns a string containing the class name
  15866. */
  15867. getClassName(): string;
  15868. /**
  15869. * Serializes the particle system to a JSON object.
  15870. * @returns the JSON object
  15871. */
  15872. serialize(): any;
  15873. /**
  15874. * Parse properties from a JSON object
  15875. * @param serializationObject defines the JSON object
  15876. */
  15877. parse(serializationObject: any): void;
  15878. }
  15879. /**
  15880. * Particle emitter emitting particles from the inside of a sphere.
  15881. * It emits the particles randomly between two vectors.
  15882. */
  15883. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15884. /**
  15885. * The min limit of the emission direction.
  15886. */
  15887. direction1: Vector3;
  15888. /**
  15889. * The max limit of the emission direction.
  15890. */
  15891. direction2: Vector3;
  15892. /**
  15893. * Creates a new instance SphereDirectedParticleEmitter
  15894. * @param radius the radius of the emission sphere (1 by default)
  15895. * @param direction1 the min limit of the emission direction (up vector by default)
  15896. * @param direction2 the max limit of the emission direction (up vector by default)
  15897. */
  15898. constructor(radius?: number,
  15899. /**
  15900. * The min limit of the emission direction.
  15901. */
  15902. direction1?: Vector3,
  15903. /**
  15904. * The max limit of the emission direction.
  15905. */
  15906. direction2?: Vector3);
  15907. /**
  15908. * Called by the particle System when the direction is computed for the created particle.
  15909. * @param worldMatrix is the world matrix of the particle system
  15910. * @param directionToUpdate is the direction vector to update with the result
  15911. * @param particle is the particle we are computed the direction for
  15912. */
  15913. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15914. /**
  15915. * Clones the current emitter and returns a copy of it
  15916. * @returns the new emitter
  15917. */
  15918. clone(): SphereDirectedParticleEmitter;
  15919. /**
  15920. * Called by the GPUParticleSystem to setup the update shader
  15921. * @param effect defines the update shader
  15922. */
  15923. applyToShader(effect: Effect): void;
  15924. /**
  15925. * Returns a string to use to update the GPU particles update shader
  15926. * @returns a string containng the defines string
  15927. */
  15928. getEffectDefines(): string;
  15929. /**
  15930. * Returns the string "SphereDirectedParticleEmitter"
  15931. * @returns a string containing the class name
  15932. */
  15933. getClassName(): string;
  15934. /**
  15935. * Serializes the particle system to a JSON object.
  15936. * @returns the JSON object
  15937. */
  15938. serialize(): any;
  15939. /**
  15940. * Parse properties from a JSON object
  15941. * @param serializationObject defines the JSON object
  15942. */
  15943. parse(serializationObject: any): void;
  15944. }
  15945. }
  15946. declare module "babylonjs/Particles/EmitterTypes/index" {
  15947. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15948. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15949. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15950. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15951. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15952. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15953. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15954. }
  15955. declare module "babylonjs/Particles/IParticleSystem" {
  15956. import { Nullable } from "babylonjs/types";
  15957. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15959. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15960. import { Texture } from "babylonjs/Materials/Textures/texture";
  15961. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15962. import { Scene } from "babylonjs/scene";
  15963. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15964. import { Animation } from "babylonjs/Animations/animation";
  15965. /**
  15966. * Interface representing a particle system in Babylon.js.
  15967. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15968. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15969. */
  15970. export interface IParticleSystem {
  15971. /**
  15972. * List of animations used by the particle system.
  15973. */
  15974. animations: Animation[];
  15975. /**
  15976. * The id of the Particle system.
  15977. */
  15978. id: string;
  15979. /**
  15980. * The name of the Particle system.
  15981. */
  15982. name: string;
  15983. /**
  15984. * The emitter represents the Mesh or position we are attaching the particle system to.
  15985. */
  15986. emitter: Nullable<AbstractMesh | Vector3>;
  15987. /**
  15988. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15989. */
  15990. isBillboardBased: boolean;
  15991. /**
  15992. * The rendering group used by the Particle system to chose when to render.
  15993. */
  15994. renderingGroupId: number;
  15995. /**
  15996. * The layer mask we are rendering the particles through.
  15997. */
  15998. layerMask: number;
  15999. /**
  16000. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16001. */
  16002. updateSpeed: number;
  16003. /**
  16004. * The amount of time the particle system is running (depends of the overall update speed).
  16005. */
  16006. targetStopDuration: number;
  16007. /**
  16008. * The texture used to render each particle. (this can be a spritesheet)
  16009. */
  16010. particleTexture: Nullable<Texture>;
  16011. /**
  16012. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16013. */
  16014. blendMode: number;
  16015. /**
  16016. * Minimum life time of emitting particles.
  16017. */
  16018. minLifeTime: number;
  16019. /**
  16020. * Maximum life time of emitting particles.
  16021. */
  16022. maxLifeTime: number;
  16023. /**
  16024. * Minimum Size of emitting particles.
  16025. */
  16026. minSize: number;
  16027. /**
  16028. * Maximum Size of emitting particles.
  16029. */
  16030. maxSize: number;
  16031. /**
  16032. * Minimum scale of emitting particles on X axis.
  16033. */
  16034. minScaleX: number;
  16035. /**
  16036. * Maximum scale of emitting particles on X axis.
  16037. */
  16038. maxScaleX: number;
  16039. /**
  16040. * Minimum scale of emitting particles on Y axis.
  16041. */
  16042. minScaleY: number;
  16043. /**
  16044. * Maximum scale of emitting particles on Y axis.
  16045. */
  16046. maxScaleY: number;
  16047. /**
  16048. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16049. */
  16050. color1: Color4;
  16051. /**
  16052. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16053. */
  16054. color2: Color4;
  16055. /**
  16056. * Color the particle will have at the end of its lifetime.
  16057. */
  16058. colorDead: Color4;
  16059. /**
  16060. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16061. */
  16062. emitRate: number;
  16063. /**
  16064. * You can use gravity if you want to give an orientation to your particles.
  16065. */
  16066. gravity: Vector3;
  16067. /**
  16068. * Minimum power of emitting particles.
  16069. */
  16070. minEmitPower: number;
  16071. /**
  16072. * Maximum power of emitting particles.
  16073. */
  16074. maxEmitPower: number;
  16075. /**
  16076. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16077. */
  16078. minAngularSpeed: number;
  16079. /**
  16080. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16081. */
  16082. maxAngularSpeed: number;
  16083. /**
  16084. * Gets or sets the minimal initial rotation in radians.
  16085. */
  16086. minInitialRotation: number;
  16087. /**
  16088. * Gets or sets the maximal initial rotation in radians.
  16089. */
  16090. maxInitialRotation: number;
  16091. /**
  16092. * The particle emitter type defines the emitter used by the particle system.
  16093. * It can be for example box, sphere, or cone...
  16094. */
  16095. particleEmitterType: Nullable<IParticleEmitterType>;
  16096. /**
  16097. * Defines the delay in milliseconds before starting the system (0 by default)
  16098. */
  16099. startDelay: number;
  16100. /**
  16101. * 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
  16102. */
  16103. preWarmCycles: number;
  16104. /**
  16105. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16106. */
  16107. preWarmStepOffset: number;
  16108. /**
  16109. * 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)
  16110. */
  16111. spriteCellChangeSpeed: number;
  16112. /**
  16113. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16114. */
  16115. startSpriteCellID: number;
  16116. /**
  16117. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16118. */
  16119. endSpriteCellID: number;
  16120. /**
  16121. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16122. */
  16123. spriteCellWidth: number;
  16124. /**
  16125. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16126. */
  16127. spriteCellHeight: number;
  16128. /**
  16129. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16130. */
  16131. spriteRandomStartCell: boolean;
  16132. /**
  16133. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16134. */
  16135. isAnimationSheetEnabled: boolean;
  16136. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16137. translationPivot: Vector2;
  16138. /**
  16139. * Gets or sets a texture used to add random noise to particle positions
  16140. */
  16141. noiseTexture: Nullable<BaseTexture>;
  16142. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16143. noiseStrength: Vector3;
  16144. /**
  16145. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16146. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16147. */
  16148. billboardMode: number;
  16149. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16150. limitVelocityDamping: number;
  16151. /**
  16152. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16153. */
  16154. beginAnimationOnStart: boolean;
  16155. /**
  16156. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16157. */
  16158. beginAnimationFrom: number;
  16159. /**
  16160. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16161. */
  16162. beginAnimationTo: number;
  16163. /**
  16164. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16165. */
  16166. beginAnimationLoop: boolean;
  16167. /**
  16168. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16169. */
  16170. disposeOnStop: boolean;
  16171. /**
  16172. * Gets the maximum number of particles active at the same time.
  16173. * @returns The max number of active particles.
  16174. */
  16175. getCapacity(): number;
  16176. /**
  16177. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16178. * @returns True if it has been started, otherwise false.
  16179. */
  16180. isStarted(): boolean;
  16181. /**
  16182. * Animates the particle system for this frame.
  16183. */
  16184. animate(): void;
  16185. /**
  16186. * Renders the particle system in its current state.
  16187. * @returns the current number of particles
  16188. */
  16189. render(): number;
  16190. /**
  16191. * Dispose the particle system and frees its associated resources.
  16192. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16193. */
  16194. dispose(disposeTexture?: boolean): void;
  16195. /**
  16196. * Clones the particle system.
  16197. * @param name The name of the cloned object
  16198. * @param newEmitter The new emitter to use
  16199. * @returns the cloned particle system
  16200. */
  16201. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16202. /**
  16203. * Serializes the particle system to a JSON object.
  16204. * @returns the JSON object
  16205. */
  16206. serialize(): any;
  16207. /**
  16208. * Rebuild the particle system
  16209. */
  16210. rebuild(): void;
  16211. /**
  16212. * Starts the particle system and begins to emit
  16213. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16214. */
  16215. start(delay?: number): void;
  16216. /**
  16217. * Stops the particle system.
  16218. */
  16219. stop(): void;
  16220. /**
  16221. * Remove all active particles
  16222. */
  16223. reset(): void;
  16224. /**
  16225. * Is this system ready to be used/rendered
  16226. * @return true if the system is ready
  16227. */
  16228. isReady(): boolean;
  16229. /**
  16230. * Adds a new color gradient
  16231. * @param gradient defines the gradient to use (between 0 and 1)
  16232. * @param color1 defines the color to affect to the specified gradient
  16233. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16234. * @returns the current particle system
  16235. */
  16236. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16237. /**
  16238. * Remove a specific color gradient
  16239. * @param gradient defines the gradient to remove
  16240. * @returns the current particle system
  16241. */
  16242. removeColorGradient(gradient: number): IParticleSystem;
  16243. /**
  16244. * Adds a new size gradient
  16245. * @param gradient defines the gradient to use (between 0 and 1)
  16246. * @param factor defines the size factor to affect to the specified gradient
  16247. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16248. * @returns the current particle system
  16249. */
  16250. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16251. /**
  16252. * Remove a specific size gradient
  16253. * @param gradient defines the gradient to remove
  16254. * @returns the current particle system
  16255. */
  16256. removeSizeGradient(gradient: number): IParticleSystem;
  16257. /**
  16258. * Gets the current list of color gradients.
  16259. * You must use addColorGradient and removeColorGradient to udpate this list
  16260. * @returns the list of color gradients
  16261. */
  16262. getColorGradients(): Nullable<Array<ColorGradient>>;
  16263. /**
  16264. * Gets the current list of size gradients.
  16265. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16266. * @returns the list of size gradients
  16267. */
  16268. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16269. /**
  16270. * Gets the current list of angular speed gradients.
  16271. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16272. * @returns the list of angular speed gradients
  16273. */
  16274. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16275. /**
  16276. * Adds a new angular speed gradient
  16277. * @param gradient defines the gradient to use (between 0 and 1)
  16278. * @param factor defines the angular speed to affect to the specified gradient
  16279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16280. * @returns the current particle system
  16281. */
  16282. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16283. /**
  16284. * Remove a specific angular speed gradient
  16285. * @param gradient defines the gradient to remove
  16286. * @returns the current particle system
  16287. */
  16288. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16289. /**
  16290. * Gets the current list of velocity gradients.
  16291. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16292. * @returns the list of velocity gradients
  16293. */
  16294. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16295. /**
  16296. * Adds a new velocity gradient
  16297. * @param gradient defines the gradient to use (between 0 and 1)
  16298. * @param factor defines the velocity to affect to the specified gradient
  16299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16300. * @returns the current particle system
  16301. */
  16302. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16303. /**
  16304. * Remove a specific velocity gradient
  16305. * @param gradient defines the gradient to remove
  16306. * @returns the current particle system
  16307. */
  16308. removeVelocityGradient(gradient: number): IParticleSystem;
  16309. /**
  16310. * Gets the current list of limit velocity gradients.
  16311. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16312. * @returns the list of limit velocity gradients
  16313. */
  16314. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16315. /**
  16316. * Adds a new limit velocity gradient
  16317. * @param gradient defines the gradient to use (between 0 and 1)
  16318. * @param factor defines the limit velocity to affect to the specified gradient
  16319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16320. * @returns the current particle system
  16321. */
  16322. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16323. /**
  16324. * Remove a specific limit velocity gradient
  16325. * @param gradient defines the gradient to remove
  16326. * @returns the current particle system
  16327. */
  16328. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16329. /**
  16330. * Adds a new drag gradient
  16331. * @param gradient defines the gradient to use (between 0 and 1)
  16332. * @param factor defines the drag to affect to the specified gradient
  16333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16334. * @returns the current particle system
  16335. */
  16336. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16337. /**
  16338. * Remove a specific drag gradient
  16339. * @param gradient defines the gradient to remove
  16340. * @returns the current particle system
  16341. */
  16342. removeDragGradient(gradient: number): IParticleSystem;
  16343. /**
  16344. * Gets the current list of drag gradients.
  16345. * You must use addDragGradient and removeDragGradient to udpate this list
  16346. * @returns the list of drag gradients
  16347. */
  16348. getDragGradients(): Nullable<Array<FactorGradient>>;
  16349. /**
  16350. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16351. * @param gradient defines the gradient to use (between 0 and 1)
  16352. * @param factor defines the emit rate to affect to the specified gradient
  16353. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16354. * @returns the current particle system
  16355. */
  16356. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16357. /**
  16358. * Remove a specific emit rate gradient
  16359. * @param gradient defines the gradient to remove
  16360. * @returns the current particle system
  16361. */
  16362. removeEmitRateGradient(gradient: number): IParticleSystem;
  16363. /**
  16364. * Gets the current list of emit rate gradients.
  16365. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16366. * @returns the list of emit rate gradients
  16367. */
  16368. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16369. /**
  16370. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16371. * @param gradient defines the gradient to use (between 0 and 1)
  16372. * @param factor defines the start size to affect to the specified gradient
  16373. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16374. * @returns the current particle system
  16375. */
  16376. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16377. /**
  16378. * Remove a specific start size gradient
  16379. * @param gradient defines the gradient to remove
  16380. * @returns the current particle system
  16381. */
  16382. removeStartSizeGradient(gradient: number): IParticleSystem;
  16383. /**
  16384. * Gets the current list of start size gradients.
  16385. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16386. * @returns the list of start size gradients
  16387. */
  16388. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16389. /**
  16390. * Adds a new life time gradient
  16391. * @param gradient defines the gradient to use (between 0 and 1)
  16392. * @param factor defines the life time factor to affect to the specified gradient
  16393. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16394. * @returns the current particle system
  16395. */
  16396. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16397. /**
  16398. * Remove a specific life time gradient
  16399. * @param gradient defines the gradient to remove
  16400. * @returns the current particle system
  16401. */
  16402. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16403. /**
  16404. * Gets the current list of life time gradients.
  16405. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16406. * @returns the list of life time gradients
  16407. */
  16408. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16409. /**
  16410. * Gets the current list of color gradients.
  16411. * You must use addColorGradient and removeColorGradient to udpate this list
  16412. * @returns the list of color gradients
  16413. */
  16414. getColorGradients(): Nullable<Array<ColorGradient>>;
  16415. /**
  16416. * Adds a new ramp gradient used to remap particle colors
  16417. * @param gradient defines the gradient to use (between 0 and 1)
  16418. * @param color defines the color to affect to the specified gradient
  16419. * @returns the current particle system
  16420. */
  16421. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16422. /**
  16423. * Gets the current list of ramp gradients.
  16424. * You must use addRampGradient and removeRampGradient to udpate this list
  16425. * @returns the list of ramp gradients
  16426. */
  16427. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16428. /** Gets or sets a boolean indicating that ramp gradients must be used
  16429. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16430. */
  16431. useRampGradients: boolean;
  16432. /**
  16433. * Adds a new color remap gradient
  16434. * @param gradient defines the gradient to use (between 0 and 1)
  16435. * @param min defines the color remap minimal range
  16436. * @param max defines the color remap maximal range
  16437. * @returns the current particle system
  16438. */
  16439. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16440. /**
  16441. * Gets the current list of color remap gradients.
  16442. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16443. * @returns the list of color remap gradients
  16444. */
  16445. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16446. /**
  16447. * Adds a new alpha remap gradient
  16448. * @param gradient defines the gradient to use (between 0 and 1)
  16449. * @param min defines the alpha remap minimal range
  16450. * @param max defines the alpha remap maximal range
  16451. * @returns the current particle system
  16452. */
  16453. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16454. /**
  16455. * Gets the current list of alpha remap gradients.
  16456. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16457. * @returns the list of alpha remap gradients
  16458. */
  16459. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16460. /**
  16461. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16462. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16463. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16464. * @returns the emitter
  16465. */
  16466. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16467. /**
  16468. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16469. * @param radius The radius of the hemisphere to emit from
  16470. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16471. * @returns the emitter
  16472. */
  16473. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16474. /**
  16475. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16476. * @param radius The radius of the sphere to emit from
  16477. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16478. * @returns the emitter
  16479. */
  16480. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16481. /**
  16482. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16483. * @param radius The radius of the sphere to emit from
  16484. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16485. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16486. * @returns the emitter
  16487. */
  16488. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16489. /**
  16490. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16491. * @param radius The radius of the emission cylinder
  16492. * @param height The height of the emission cylinder
  16493. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16494. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16495. * @returns the emitter
  16496. */
  16497. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16498. /**
  16499. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16500. * @param radius The radius of the cylinder to emit from
  16501. * @param height The height of the emission cylinder
  16502. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16503. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16504. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16505. * @returns the emitter
  16506. */
  16507. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16508. /**
  16509. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16510. * @param radius The radius of the cone to emit from
  16511. * @param angle The base angle of the cone
  16512. * @returns the emitter
  16513. */
  16514. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16515. /**
  16516. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16517. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16518. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16519. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16520. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16521. * @returns the emitter
  16522. */
  16523. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16524. /**
  16525. * Get hosting scene
  16526. * @returns the scene
  16527. */
  16528. getScene(): Scene;
  16529. }
  16530. }
  16531. declare module "babylonjs/Meshes/instancedMesh" {
  16532. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16533. import { Vector3 } from "babylonjs/Maths/math";
  16534. import { Camera } from "babylonjs/Cameras/camera";
  16535. import { Node } from "babylonjs/node";
  16536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16537. import { Mesh } from "babylonjs/Meshes/mesh";
  16538. import { Material } from "babylonjs/Materials/material";
  16539. import { Skeleton } from "babylonjs/Bones/skeleton";
  16540. /**
  16541. * Creates an instance based on a source mesh.
  16542. */
  16543. export class InstancedMesh extends AbstractMesh {
  16544. private _sourceMesh;
  16545. private _currentLOD;
  16546. /** @hidden */
  16547. _indexInSourceMeshInstanceArray: number;
  16548. constructor(name: string, source: Mesh);
  16549. /**
  16550. * Returns the string "InstancedMesh".
  16551. */
  16552. getClassName(): string;
  16553. /**
  16554. * If the source mesh receives shadows
  16555. */
  16556. readonly receiveShadows: boolean;
  16557. /**
  16558. * The material of the source mesh
  16559. */
  16560. readonly material: Nullable<Material>;
  16561. /**
  16562. * Visibility of the source mesh
  16563. */
  16564. readonly visibility: number;
  16565. /**
  16566. * Skeleton of the source mesh
  16567. */
  16568. readonly skeleton: Nullable<Skeleton>;
  16569. /**
  16570. * Rendering ground id of the source mesh
  16571. */
  16572. renderingGroupId: number;
  16573. /**
  16574. * Returns the total number of vertices (integer).
  16575. */
  16576. getTotalVertices(): number;
  16577. /**
  16578. * Returns a positive integer : the total number of indices in this mesh geometry.
  16579. * @returns the numner of indices or zero if the mesh has no geometry.
  16580. */
  16581. getTotalIndices(): number;
  16582. /**
  16583. * The source mesh of the instance
  16584. */
  16585. readonly sourceMesh: Mesh;
  16586. /**
  16587. * Is this node ready to be used/rendered
  16588. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16589. * @return {boolean} is it ready
  16590. */
  16591. isReady(completeCheck?: boolean): boolean;
  16592. /**
  16593. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16594. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16595. * @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.
  16596. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16597. */
  16598. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16599. /**
  16600. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16601. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16602. * The `data` are either a numeric array either a Float32Array.
  16603. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16604. * 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).
  16605. * Note that a new underlying VertexBuffer object is created each call.
  16606. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16607. *
  16608. * Possible `kind` values :
  16609. * - VertexBuffer.PositionKind
  16610. * - VertexBuffer.UVKind
  16611. * - VertexBuffer.UV2Kind
  16612. * - VertexBuffer.UV3Kind
  16613. * - VertexBuffer.UV4Kind
  16614. * - VertexBuffer.UV5Kind
  16615. * - VertexBuffer.UV6Kind
  16616. * - VertexBuffer.ColorKind
  16617. * - VertexBuffer.MatricesIndicesKind
  16618. * - VertexBuffer.MatricesIndicesExtraKind
  16619. * - VertexBuffer.MatricesWeightsKind
  16620. * - VertexBuffer.MatricesWeightsExtraKind
  16621. *
  16622. * Returns the Mesh.
  16623. */
  16624. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16625. /**
  16626. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16627. * If the mesh has no geometry, it is simply returned as it is.
  16628. * The `data` are either a numeric array either a Float32Array.
  16629. * No new underlying VertexBuffer object is created.
  16630. * 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.
  16631. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16632. *
  16633. * Possible `kind` values :
  16634. * - VertexBuffer.PositionKind
  16635. * - VertexBuffer.UVKind
  16636. * - VertexBuffer.UV2Kind
  16637. * - VertexBuffer.UV3Kind
  16638. * - VertexBuffer.UV4Kind
  16639. * - VertexBuffer.UV5Kind
  16640. * - VertexBuffer.UV6Kind
  16641. * - VertexBuffer.ColorKind
  16642. * - VertexBuffer.MatricesIndicesKind
  16643. * - VertexBuffer.MatricesIndicesExtraKind
  16644. * - VertexBuffer.MatricesWeightsKind
  16645. * - VertexBuffer.MatricesWeightsExtraKind
  16646. *
  16647. * Returns the Mesh.
  16648. */
  16649. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16650. /**
  16651. * Sets the mesh indices.
  16652. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16653. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16654. * This method creates a new index buffer each call.
  16655. * Returns the Mesh.
  16656. */
  16657. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16658. /**
  16659. * Boolean : True if the mesh owns the requested kind of data.
  16660. */
  16661. isVerticesDataPresent(kind: string): boolean;
  16662. /**
  16663. * Returns an array of indices (IndicesArray).
  16664. */
  16665. getIndices(): Nullable<IndicesArray>;
  16666. readonly _positions: Nullable<Vector3[]>;
  16667. /**
  16668. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16669. * This means the mesh underlying bounding box and sphere are recomputed.
  16670. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16671. * @returns the current mesh
  16672. */
  16673. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16674. /** @hidden */
  16675. _preActivate(): InstancedMesh;
  16676. /** @hidden */
  16677. _activate(renderId: number): InstancedMesh;
  16678. /**
  16679. * Returns the current associated LOD AbstractMesh.
  16680. */
  16681. getLOD(camera: Camera): AbstractMesh;
  16682. /** @hidden */
  16683. _syncSubMeshes(): InstancedMesh;
  16684. /** @hidden */
  16685. _generatePointsArray(): boolean;
  16686. /**
  16687. * Creates a new InstancedMesh from the current mesh.
  16688. * - name (string) : the cloned mesh name
  16689. * - newParent (optional Node) : the optional Node to parent the clone to.
  16690. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16691. *
  16692. * Returns the clone.
  16693. */
  16694. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16695. /**
  16696. * Disposes the InstancedMesh.
  16697. * Returns nothing.
  16698. */
  16699. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16700. }
  16701. }
  16702. declare module "babylonjs/Materials/shaderMaterial" {
  16703. import { Scene } from "babylonjs/scene";
  16704. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16706. import { Mesh } from "babylonjs/Meshes/mesh";
  16707. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16708. import { Texture } from "babylonjs/Materials/Textures/texture";
  16709. import { Material } from "babylonjs/Materials/material";
  16710. /**
  16711. * Defines the options associated with the creation of a shader material.
  16712. */
  16713. export interface IShaderMaterialOptions {
  16714. /**
  16715. * Does the material work in alpha blend mode
  16716. */
  16717. needAlphaBlending: boolean;
  16718. /**
  16719. * Does the material work in alpha test mode
  16720. */
  16721. needAlphaTesting: boolean;
  16722. /**
  16723. * The list of attribute names used in the shader
  16724. */
  16725. attributes: string[];
  16726. /**
  16727. * The list of unifrom names used in the shader
  16728. */
  16729. uniforms: string[];
  16730. /**
  16731. * The list of UBO names used in the shader
  16732. */
  16733. uniformBuffers: string[];
  16734. /**
  16735. * The list of sampler names used in the shader
  16736. */
  16737. samplers: string[];
  16738. /**
  16739. * The list of defines used in the shader
  16740. */
  16741. defines: string[];
  16742. }
  16743. /**
  16744. * 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.
  16745. *
  16746. * This returned material effects how the mesh will look based on the code in the shaders.
  16747. *
  16748. * @see http://doc.babylonjs.com/how_to/shader_material
  16749. */
  16750. export class ShaderMaterial extends Material {
  16751. private _shaderPath;
  16752. private _options;
  16753. private _textures;
  16754. private _textureArrays;
  16755. private _floats;
  16756. private _ints;
  16757. private _floatsArrays;
  16758. private _colors3;
  16759. private _colors3Arrays;
  16760. private _colors4;
  16761. private _vectors2;
  16762. private _vectors3;
  16763. private _vectors4;
  16764. private _matrices;
  16765. private _matrices3x3;
  16766. private _matrices2x2;
  16767. private _vectors2Arrays;
  16768. private _vectors3Arrays;
  16769. private _cachedWorldViewMatrix;
  16770. private _renderId;
  16771. /**
  16772. * Instantiate a new shader material.
  16773. * 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.
  16774. * This returned material effects how the mesh will look based on the code in the shaders.
  16775. * @see http://doc.babylonjs.com/how_to/shader_material
  16776. * @param name Define the name of the material in the scene
  16777. * @param scene Define the scene the material belongs to
  16778. * @param shaderPath Defines the route to the shader code in one of three ways:
  16779. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16780. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16781. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16782. * @param options Define the options used to create the shader
  16783. */
  16784. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16785. /**
  16786. * Gets the current class name of the material e.g. "ShaderMaterial"
  16787. * Mainly use in serialization.
  16788. * @returns the class name
  16789. */
  16790. getClassName(): string;
  16791. /**
  16792. * Specifies if the material will require alpha blending
  16793. * @returns a boolean specifying if alpha blending is needed
  16794. */
  16795. needAlphaBlending(): boolean;
  16796. /**
  16797. * Specifies if this material should be rendered in alpha test mode
  16798. * @returns a boolean specifying if an alpha test is needed.
  16799. */
  16800. needAlphaTesting(): boolean;
  16801. private _checkUniform;
  16802. /**
  16803. * Set a texture in the shader.
  16804. * @param name Define the name of the uniform samplers as defined in the shader
  16805. * @param texture Define the texture to bind to this sampler
  16806. * @return the material itself allowing "fluent" like uniform updates
  16807. */
  16808. setTexture(name: string, texture: Texture): ShaderMaterial;
  16809. /**
  16810. * Set a texture array in the shader.
  16811. * @param name Define the name of the uniform sampler array as defined in the shader
  16812. * @param textures Define the list of textures to bind to this sampler
  16813. * @return the material itself allowing "fluent" like uniform updates
  16814. */
  16815. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16816. /**
  16817. * Set a float in the shader.
  16818. * @param name Define the name of the uniform as defined in the shader
  16819. * @param value Define the value to give to the uniform
  16820. * @return the material itself allowing "fluent" like uniform updates
  16821. */
  16822. setFloat(name: string, value: number): ShaderMaterial;
  16823. /**
  16824. * Set a int in the shader.
  16825. * @param name Define the name of the uniform as defined in the shader
  16826. * @param value Define the value to give to the uniform
  16827. * @return the material itself allowing "fluent" like uniform updates
  16828. */
  16829. setInt(name: string, value: number): ShaderMaterial;
  16830. /**
  16831. * Set an array of floats in the shader.
  16832. * @param name Define the name of the uniform as defined in the shader
  16833. * @param value Define the value to give to the uniform
  16834. * @return the material itself allowing "fluent" like uniform updates
  16835. */
  16836. setFloats(name: string, value: number[]): ShaderMaterial;
  16837. /**
  16838. * Set a vec3 in the shader from a Color3.
  16839. * @param name Define the name of the uniform as defined in the shader
  16840. * @param value Define the value to give to the uniform
  16841. * @return the material itself allowing "fluent" like uniform updates
  16842. */
  16843. setColor3(name: string, value: Color3): ShaderMaterial;
  16844. /**
  16845. * Set a vec3 array in the shader from a Color3 array.
  16846. * @param name Define the name of the uniform as defined in the shader
  16847. * @param value Define the value to give to the uniform
  16848. * @return the material itself allowing "fluent" like uniform updates
  16849. */
  16850. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16851. /**
  16852. * Set a vec4 in the shader from a Color4.
  16853. * @param name Define the name of the uniform as defined in the shader
  16854. * @param value Define the value to give to the uniform
  16855. * @return the material itself allowing "fluent" like uniform updates
  16856. */
  16857. setColor4(name: string, value: Color4): ShaderMaterial;
  16858. /**
  16859. * Set a vec2 in the shader from a Vector2.
  16860. * @param name Define the name of the uniform as defined in the shader
  16861. * @param value Define the value to give to the uniform
  16862. * @return the material itself allowing "fluent" like uniform updates
  16863. */
  16864. setVector2(name: string, value: Vector2): ShaderMaterial;
  16865. /**
  16866. * Set a vec3 in the shader from a Vector3.
  16867. * @param name Define the name of the uniform as defined in the shader
  16868. * @param value Define the value to give to the uniform
  16869. * @return the material itself allowing "fluent" like uniform updates
  16870. */
  16871. setVector3(name: string, value: Vector3): ShaderMaterial;
  16872. /**
  16873. * Set a vec4 in the shader from a Vector4.
  16874. * @param name Define the name of the uniform as defined in the shader
  16875. * @param value Define the value to give to the uniform
  16876. * @return the material itself allowing "fluent" like uniform updates
  16877. */
  16878. setVector4(name: string, value: Vector4): ShaderMaterial;
  16879. /**
  16880. * Set a mat4 in the shader from a Matrix.
  16881. * @param name Define the name of the uniform as defined in the shader
  16882. * @param value Define the value to give to the uniform
  16883. * @return the material itself allowing "fluent" like uniform updates
  16884. */
  16885. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16886. /**
  16887. * Set a mat3 in the shader from a Float32Array.
  16888. * @param name Define the name of the uniform as defined in the shader
  16889. * @param value Define the value to give to the uniform
  16890. * @return the material itself allowing "fluent" like uniform updates
  16891. */
  16892. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16893. /**
  16894. * Set a mat2 in the shader from a Float32Array.
  16895. * @param name Define the name of the uniform as defined in the shader
  16896. * @param value Define the value to give to the uniform
  16897. * @return the material itself allowing "fluent" like uniform updates
  16898. */
  16899. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16900. /**
  16901. * Set a vec2 array in the shader from a number array.
  16902. * @param name Define the name of the uniform as defined in the shader
  16903. * @param value Define the value to give to the uniform
  16904. * @return the material itself allowing "fluent" like uniform updates
  16905. */
  16906. setArray2(name: string, value: number[]): ShaderMaterial;
  16907. /**
  16908. * Set a vec3 array in the shader from a number array.
  16909. * @param name Define the name of the uniform as defined in the shader
  16910. * @param value Define the value to give to the uniform
  16911. * @return the material itself allowing "fluent" like uniform updates
  16912. */
  16913. setArray3(name: string, value: number[]): ShaderMaterial;
  16914. private _checkCache;
  16915. /**
  16916. * Checks if the material is ready to render the requested mesh
  16917. * @param mesh Define the mesh to render
  16918. * @param useInstances Define whether or not the material is used with instances
  16919. * @returns true if ready, otherwise false
  16920. */
  16921. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16922. /**
  16923. * Binds the world matrix to the material
  16924. * @param world defines the world transformation matrix
  16925. */
  16926. bindOnlyWorldMatrix(world: Matrix): void;
  16927. /**
  16928. * Binds the material to the mesh
  16929. * @param world defines the world transformation matrix
  16930. * @param mesh defines the mesh to bind the material to
  16931. */
  16932. bind(world: Matrix, mesh?: Mesh): void;
  16933. /**
  16934. * Gets the active textures from the material
  16935. * @returns an array of textures
  16936. */
  16937. getActiveTextures(): BaseTexture[];
  16938. /**
  16939. * Specifies if the material uses a texture
  16940. * @param texture defines the texture to check against the material
  16941. * @returns a boolean specifying if the material uses the texture
  16942. */
  16943. hasTexture(texture: BaseTexture): boolean;
  16944. /**
  16945. * Makes a duplicate of the material, and gives it a new name
  16946. * @param name defines the new name for the duplicated material
  16947. * @returns the cloned material
  16948. */
  16949. clone(name: string): ShaderMaterial;
  16950. /**
  16951. * Disposes the material
  16952. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16953. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16954. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16955. */
  16956. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16957. /**
  16958. * Serializes this material in a JSON representation
  16959. * @returns the serialized material object
  16960. */
  16961. serialize(): any;
  16962. /**
  16963. * Creates a shader material from parsed shader material data
  16964. * @param source defines the JSON represnetation of the material
  16965. * @param scene defines the hosting scene
  16966. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16967. * @returns a new material
  16968. */
  16969. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16970. }
  16971. }
  16972. declare module "babylonjs/Shaders/color.fragment" {
  16973. /** @hidden */
  16974. export var colorPixelShader: {
  16975. name: string;
  16976. shader: string;
  16977. };
  16978. }
  16979. declare module "babylonjs/Shaders/color.vertex" {
  16980. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16981. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16982. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16983. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16984. /** @hidden */
  16985. export var colorVertexShader: {
  16986. name: string;
  16987. shader: string;
  16988. };
  16989. }
  16990. declare module "babylonjs/Meshes/linesMesh" {
  16991. import { Nullable } from "babylonjs/types";
  16992. import { Scene } from "babylonjs/scene";
  16993. import { Color3 } from "babylonjs/Maths/math";
  16994. import { Node } from "babylonjs/node";
  16995. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16996. import { Mesh } from "babylonjs/Meshes/mesh";
  16997. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16998. import { Effect } from "babylonjs/Materials/effect";
  16999. import { Material } from "babylonjs/Materials/material";
  17000. import "babylonjs/Shaders/color.fragment";
  17001. import "babylonjs/Shaders/color.vertex";
  17002. /**
  17003. * Line mesh
  17004. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17005. */
  17006. export class LinesMesh extends Mesh {
  17007. /**
  17008. * If vertex color should be applied to the mesh
  17009. */
  17010. useVertexColor?: boolean | undefined;
  17011. /**
  17012. * If vertex alpha should be applied to the mesh
  17013. */
  17014. useVertexAlpha?: boolean | undefined;
  17015. /**
  17016. * Color of the line (Default: White)
  17017. */
  17018. color: Color3;
  17019. /**
  17020. * Alpha of the line (Default: 1)
  17021. */
  17022. alpha: number;
  17023. /**
  17024. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17025. * This margin is expressed in world space coordinates, so its value may vary.
  17026. * Default value is 0.1
  17027. */
  17028. intersectionThreshold: number;
  17029. private _colorShader;
  17030. /**
  17031. * Creates a new LinesMesh
  17032. * @param name defines the name
  17033. * @param scene defines the hosting scene
  17034. * @param parent defines the parent mesh if any
  17035. * @param source defines the optional source LinesMesh used to clone data from
  17036. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17037. * When false, achieved by calling a clone(), also passing False.
  17038. * This will make creation of children, recursive.
  17039. * @param useVertexColor defines if this LinesMesh supports vertex color
  17040. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17041. */
  17042. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17043. /**
  17044. * If vertex color should be applied to the mesh
  17045. */
  17046. useVertexColor?: boolean | undefined,
  17047. /**
  17048. * If vertex alpha should be applied to the mesh
  17049. */
  17050. useVertexAlpha?: boolean | undefined);
  17051. /**
  17052. * Returns the string "LineMesh"
  17053. */
  17054. getClassName(): string;
  17055. /**
  17056. * @hidden
  17057. */
  17058. /**
  17059. * @hidden
  17060. */
  17061. material: Material;
  17062. /**
  17063. * @hidden
  17064. */
  17065. readonly checkCollisions: boolean;
  17066. /** @hidden */
  17067. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17068. /** @hidden */
  17069. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17070. /**
  17071. * Disposes of the line mesh
  17072. * @param doNotRecurse If children should be disposed
  17073. */
  17074. dispose(doNotRecurse?: boolean): void;
  17075. /**
  17076. * Returns a new LineMesh object cloned from the current one.
  17077. */
  17078. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17079. /**
  17080. * Creates a new InstancedLinesMesh object from the mesh model.
  17081. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17082. * @param name defines the name of the new instance
  17083. * @returns a new InstancedLinesMesh
  17084. */
  17085. createInstance(name: string): InstancedLinesMesh;
  17086. }
  17087. /**
  17088. * Creates an instance based on a source LinesMesh
  17089. */
  17090. export class InstancedLinesMesh extends InstancedMesh {
  17091. /**
  17092. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17093. * This margin is expressed in world space coordinates, so its value may vary.
  17094. * Initilized with the intersectionThreshold value of the source LinesMesh
  17095. */
  17096. intersectionThreshold: number;
  17097. constructor(name: string, source: LinesMesh);
  17098. /**
  17099. * Returns the string "InstancedLinesMesh".
  17100. */
  17101. getClassName(): string;
  17102. }
  17103. }
  17104. declare module "babylonjs/Shaders/line.fragment" {
  17105. /** @hidden */
  17106. export var linePixelShader: {
  17107. name: string;
  17108. shader: string;
  17109. };
  17110. }
  17111. declare module "babylonjs/Shaders/line.vertex" {
  17112. /** @hidden */
  17113. export var lineVertexShader: {
  17114. name: string;
  17115. shader: string;
  17116. };
  17117. }
  17118. declare module "babylonjs/Rendering/edgesRenderer" {
  17119. import { Nullable } from "babylonjs/types";
  17120. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17122. import { Vector3 } from "babylonjs/Maths/math";
  17123. import { IDisposable } from "babylonjs/scene";
  17124. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17125. import "babylonjs/Shaders/line.fragment";
  17126. import "babylonjs/Shaders/line.vertex";
  17127. module "babylonjs/Meshes/abstractMesh" {
  17128. interface AbstractMesh {
  17129. /**
  17130. * Disables the mesh edge rendering mode
  17131. * @returns the currentAbstractMesh
  17132. */
  17133. disableEdgesRendering(): AbstractMesh;
  17134. /**
  17135. * Enables the edge rendering mode on the mesh.
  17136. * This mode makes the mesh edges visible
  17137. * @param epsilon defines the maximal distance between two angles to detect a face
  17138. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17139. * @returns the currentAbstractMesh
  17140. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17141. */
  17142. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17143. /**
  17144. * Gets the edgesRenderer associated with the mesh
  17145. */
  17146. edgesRenderer: Nullable<EdgesRenderer>;
  17147. }
  17148. }
  17149. module "babylonjs/Meshes/linesMesh" {
  17150. interface LinesMesh {
  17151. /**
  17152. * Enables the edge rendering mode on the mesh.
  17153. * This mode makes the mesh edges visible
  17154. * @param epsilon defines the maximal distance between two angles to detect a face
  17155. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17156. * @returns the currentAbstractMesh
  17157. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17158. */
  17159. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17160. }
  17161. }
  17162. module "babylonjs/Meshes/linesMesh" {
  17163. interface InstancedLinesMesh {
  17164. /**
  17165. * Enables the edge rendering mode on the mesh.
  17166. * This mode makes the mesh edges visible
  17167. * @param epsilon defines the maximal distance between two angles to detect a face
  17168. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17169. * @returns the current InstancedLinesMesh
  17170. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17171. */
  17172. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17173. }
  17174. }
  17175. /**
  17176. * Defines the minimum contract an Edges renderer should follow.
  17177. */
  17178. export interface IEdgesRenderer extends IDisposable {
  17179. /**
  17180. * Gets or sets a boolean indicating if the edgesRenderer is active
  17181. */
  17182. isEnabled: boolean;
  17183. /**
  17184. * Renders the edges of the attached mesh,
  17185. */
  17186. render(): void;
  17187. /**
  17188. * Checks wether or not the edges renderer is ready to render.
  17189. * @return true if ready, otherwise false.
  17190. */
  17191. isReady(): boolean;
  17192. }
  17193. /**
  17194. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17195. */
  17196. export class EdgesRenderer implements IEdgesRenderer {
  17197. /**
  17198. * Define the size of the edges with an orthographic camera
  17199. */
  17200. edgesWidthScalerForOrthographic: number;
  17201. /**
  17202. * Define the size of the edges with a perspective camera
  17203. */
  17204. edgesWidthScalerForPerspective: number;
  17205. protected _source: AbstractMesh;
  17206. protected _linesPositions: number[];
  17207. protected _linesNormals: number[];
  17208. protected _linesIndices: number[];
  17209. protected _epsilon: number;
  17210. protected _indicesCount: number;
  17211. protected _lineShader: ShaderMaterial;
  17212. protected _ib: WebGLBuffer;
  17213. protected _buffers: {
  17214. [key: string]: Nullable<VertexBuffer>;
  17215. };
  17216. protected _checkVerticesInsteadOfIndices: boolean;
  17217. private _meshRebuildObserver;
  17218. private _meshDisposeObserver;
  17219. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17220. isEnabled: boolean;
  17221. /**
  17222. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17223. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17224. * @param source Mesh used to create edges
  17225. * @param epsilon sum of angles in adjacency to check for edge
  17226. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17227. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17228. */
  17229. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17230. protected _prepareRessources(): void;
  17231. /** @hidden */
  17232. _rebuild(): void;
  17233. /**
  17234. * Releases the required resources for the edges renderer
  17235. */
  17236. dispose(): void;
  17237. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17238. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17239. /**
  17240. * Checks if the pair of p0 and p1 is en edge
  17241. * @param faceIndex
  17242. * @param edge
  17243. * @param faceNormals
  17244. * @param p0
  17245. * @param p1
  17246. * @private
  17247. */
  17248. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17249. /**
  17250. * push line into the position, normal and index buffer
  17251. * @protected
  17252. */
  17253. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17254. /**
  17255. * Generates lines edges from adjacencjes
  17256. * @private
  17257. */
  17258. _generateEdgesLines(): void;
  17259. /**
  17260. * Checks wether or not the edges renderer is ready to render.
  17261. * @return true if ready, otherwise false.
  17262. */
  17263. isReady(): boolean;
  17264. /**
  17265. * Renders the edges of the attached mesh,
  17266. */
  17267. render(): void;
  17268. }
  17269. /**
  17270. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17271. */
  17272. export class LineEdgesRenderer extends EdgesRenderer {
  17273. /**
  17274. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17275. * @param source LineMesh used to generate edges
  17276. * @param epsilon not important (specified angle for edge detection)
  17277. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17278. */
  17279. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17280. /**
  17281. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17282. */
  17283. _generateEdgesLines(): void;
  17284. }
  17285. }
  17286. declare module "babylonjs/Rendering/renderingGroup" {
  17287. import { SmartArray } from "babylonjs/Misc/smartArray";
  17288. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17290. import { Nullable } from "babylonjs/types";
  17291. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17292. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17293. import { Material } from "babylonjs/Materials/material";
  17294. import { Scene } from "babylonjs/scene";
  17295. /**
  17296. * This represents the object necessary to create a rendering group.
  17297. * This is exclusively used and created by the rendering manager.
  17298. * To modify the behavior, you use the available helpers in your scene or meshes.
  17299. * @hidden
  17300. */
  17301. export class RenderingGroup {
  17302. index: number;
  17303. private _scene;
  17304. private _opaqueSubMeshes;
  17305. private _transparentSubMeshes;
  17306. private _alphaTestSubMeshes;
  17307. private _depthOnlySubMeshes;
  17308. private _particleSystems;
  17309. private _spriteManagers;
  17310. private _opaqueSortCompareFn;
  17311. private _alphaTestSortCompareFn;
  17312. private _transparentSortCompareFn;
  17313. private _renderOpaque;
  17314. private _renderAlphaTest;
  17315. private _renderTransparent;
  17316. private _edgesRenderers;
  17317. onBeforeTransparentRendering: () => void;
  17318. /**
  17319. * Set the opaque sort comparison function.
  17320. * If null the sub meshes will be render in the order they were created
  17321. */
  17322. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17323. /**
  17324. * Set the alpha test sort comparison function.
  17325. * If null the sub meshes will be render in the order they were created
  17326. */
  17327. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17328. /**
  17329. * Set the transparent sort comparison function.
  17330. * If null the sub meshes will be render in the order they were created
  17331. */
  17332. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17333. /**
  17334. * Creates a new rendering group.
  17335. * @param index The rendering group index
  17336. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17337. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17338. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17339. */
  17340. 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>);
  17341. /**
  17342. * Render all the sub meshes contained in the group.
  17343. * @param customRenderFunction Used to override the default render behaviour of the group.
  17344. * @returns true if rendered some submeshes.
  17345. */
  17346. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17347. /**
  17348. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17349. * @param subMeshes The submeshes to render
  17350. */
  17351. private renderOpaqueSorted;
  17352. /**
  17353. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17354. * @param subMeshes The submeshes to render
  17355. */
  17356. private renderAlphaTestSorted;
  17357. /**
  17358. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17359. * @param subMeshes The submeshes to render
  17360. */
  17361. private renderTransparentSorted;
  17362. /**
  17363. * Renders the submeshes in a specified order.
  17364. * @param subMeshes The submeshes to sort before render
  17365. * @param sortCompareFn The comparison function use to sort
  17366. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17367. * @param transparent Specifies to activate blending if true
  17368. */
  17369. private static renderSorted;
  17370. /**
  17371. * Renders the submeshes in the order they were dispatched (no sort applied).
  17372. * @param subMeshes The submeshes to render
  17373. */
  17374. private static renderUnsorted;
  17375. /**
  17376. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17377. * are rendered back to front if in the same alpha index.
  17378. *
  17379. * @param a The first submesh
  17380. * @param b The second submesh
  17381. * @returns The result of the comparison
  17382. */
  17383. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17384. /**
  17385. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17386. * are rendered back to front.
  17387. *
  17388. * @param a The first submesh
  17389. * @param b The second submesh
  17390. * @returns The result of the comparison
  17391. */
  17392. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17393. /**
  17394. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17395. * are rendered front to back (prevent overdraw).
  17396. *
  17397. * @param a The first submesh
  17398. * @param b The second submesh
  17399. * @returns The result of the comparison
  17400. */
  17401. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17402. /**
  17403. * Resets the different lists of submeshes to prepare a new frame.
  17404. */
  17405. prepare(): void;
  17406. dispose(): void;
  17407. /**
  17408. * Inserts the submesh in its correct queue depending on its material.
  17409. * @param subMesh The submesh to dispatch
  17410. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17411. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17412. */
  17413. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17414. dispatchSprites(spriteManager: ISpriteManager): void;
  17415. dispatchParticles(particleSystem: IParticleSystem): void;
  17416. private _renderParticles;
  17417. private _renderSprites;
  17418. }
  17419. }
  17420. declare module "babylonjs/Rendering/renderingManager" {
  17421. import { Nullable } from "babylonjs/types";
  17422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17423. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17424. import { SmartArray } from "babylonjs/Misc/smartArray";
  17425. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17426. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17427. import { Material } from "babylonjs/Materials/material";
  17428. import { Scene } from "babylonjs/scene";
  17429. import { Camera } from "babylonjs/Cameras/camera";
  17430. /**
  17431. * Interface describing the different options available in the rendering manager
  17432. * regarding Auto Clear between groups.
  17433. */
  17434. export interface IRenderingManagerAutoClearSetup {
  17435. /**
  17436. * Defines whether or not autoclear is enable.
  17437. */
  17438. autoClear: boolean;
  17439. /**
  17440. * Defines whether or not to autoclear the depth buffer.
  17441. */
  17442. depth: boolean;
  17443. /**
  17444. * Defines whether or not to autoclear the stencil buffer.
  17445. */
  17446. stencil: boolean;
  17447. }
  17448. /**
  17449. * This class is used by the onRenderingGroupObservable
  17450. */
  17451. export class RenderingGroupInfo {
  17452. /**
  17453. * The Scene that being rendered
  17454. */
  17455. scene: Scene;
  17456. /**
  17457. * The camera currently used for the rendering pass
  17458. */
  17459. camera: Nullable<Camera>;
  17460. /**
  17461. * The ID of the renderingGroup being processed
  17462. */
  17463. renderingGroupId: number;
  17464. }
  17465. /**
  17466. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17467. * It is enable to manage the different groups as well as the different necessary sort functions.
  17468. * This should not be used directly aside of the few static configurations
  17469. */
  17470. export class RenderingManager {
  17471. /**
  17472. * The max id used for rendering groups (not included)
  17473. */
  17474. static MAX_RENDERINGGROUPS: number;
  17475. /**
  17476. * The min id used for rendering groups (included)
  17477. */
  17478. static MIN_RENDERINGGROUPS: number;
  17479. /**
  17480. * Used to globally prevent autoclearing scenes.
  17481. */
  17482. static AUTOCLEAR: boolean;
  17483. /**
  17484. * @hidden
  17485. */
  17486. _useSceneAutoClearSetup: boolean;
  17487. private _scene;
  17488. private _renderingGroups;
  17489. private _depthStencilBufferAlreadyCleaned;
  17490. private _autoClearDepthStencil;
  17491. private _customOpaqueSortCompareFn;
  17492. private _customAlphaTestSortCompareFn;
  17493. private _customTransparentSortCompareFn;
  17494. private _renderingGroupInfo;
  17495. /**
  17496. * Instantiates a new rendering group for a particular scene
  17497. * @param scene Defines the scene the groups belongs to
  17498. */
  17499. constructor(scene: Scene);
  17500. private _clearDepthStencilBuffer;
  17501. /**
  17502. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17503. * @hidden
  17504. */
  17505. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17506. /**
  17507. * Resets the different information of the group to prepare a new frame
  17508. * @hidden
  17509. */
  17510. reset(): void;
  17511. /**
  17512. * Dispose and release the group and its associated resources.
  17513. * @hidden
  17514. */
  17515. dispose(): void;
  17516. /**
  17517. * Clear the info related to rendering groups preventing retention points during dispose.
  17518. */
  17519. freeRenderingGroups(): void;
  17520. private _prepareRenderingGroup;
  17521. /**
  17522. * Add a sprite manager to the rendering manager in order to render it this frame.
  17523. * @param spriteManager Define the sprite manager to render
  17524. */
  17525. dispatchSprites(spriteManager: ISpriteManager): void;
  17526. /**
  17527. * Add a particle system to the rendering manager in order to render it this frame.
  17528. * @param particleSystem Define the particle system to render
  17529. */
  17530. dispatchParticles(particleSystem: IParticleSystem): void;
  17531. /**
  17532. * Add a submesh to the manager in order to render it this frame
  17533. * @param subMesh The submesh to dispatch
  17534. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17535. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17536. */
  17537. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17538. /**
  17539. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17540. * This allowed control for front to back rendering or reversly depending of the special needs.
  17541. *
  17542. * @param renderingGroupId The rendering group id corresponding to its index
  17543. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17544. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17545. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17546. */
  17547. 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;
  17548. /**
  17549. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17550. *
  17551. * @param renderingGroupId The rendering group id corresponding to its index
  17552. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17553. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17554. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17555. */
  17556. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17557. /**
  17558. * Gets the current auto clear configuration for one rendering group of the rendering
  17559. * manager.
  17560. * @param index the rendering group index to get the information for
  17561. * @returns The auto clear setup for the requested rendering group
  17562. */
  17563. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17564. }
  17565. }
  17566. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17567. import { Observable } from "babylonjs/Misc/observable";
  17568. import { SmartArray } from "babylonjs/Misc/smartArray";
  17569. import { Nullable } from "babylonjs/types";
  17570. import { Camera } from "babylonjs/Cameras/camera";
  17571. import { Scene } from "babylonjs/scene";
  17572. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17573. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17575. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17576. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17577. import { Texture } from "babylonjs/Materials/Textures/texture";
  17578. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17579. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17580. import { Engine } from "babylonjs/Engines/engine";
  17581. /**
  17582. * This Helps creating a texture that will be created from a camera in your scene.
  17583. * It is basically a dynamic texture that could be used to create special effects for instance.
  17584. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17585. */
  17586. export class RenderTargetTexture extends Texture {
  17587. isCube: boolean;
  17588. /**
  17589. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17590. */
  17591. static readonly REFRESHRATE_RENDER_ONCE: number;
  17592. /**
  17593. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17594. */
  17595. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17596. /**
  17597. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17598. * the central point of your effect and can save a lot of performances.
  17599. */
  17600. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17601. /**
  17602. * Use this predicate to dynamically define the list of mesh you want to render.
  17603. * If set, the renderList property will be overwritten.
  17604. */
  17605. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17606. private _renderList;
  17607. /**
  17608. * Use this list to define the list of mesh you want to render.
  17609. */
  17610. renderList: Nullable<Array<AbstractMesh>>;
  17611. private _hookArray;
  17612. /**
  17613. * Define if particles should be rendered in your texture.
  17614. */
  17615. renderParticles: boolean;
  17616. /**
  17617. * Define if sprites should be rendered in your texture.
  17618. */
  17619. renderSprites: boolean;
  17620. /**
  17621. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17622. */
  17623. coordinatesMode: number;
  17624. /**
  17625. * Define the camera used to render the texture.
  17626. */
  17627. activeCamera: Nullable<Camera>;
  17628. /**
  17629. * Override the render function of the texture with your own one.
  17630. */
  17631. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17632. /**
  17633. * Define if camera post processes should be use while rendering the texture.
  17634. */
  17635. useCameraPostProcesses: boolean;
  17636. /**
  17637. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17638. */
  17639. ignoreCameraViewport: boolean;
  17640. private _postProcessManager;
  17641. private _postProcesses;
  17642. private _resizeObserver;
  17643. /**
  17644. * An event triggered when the texture is unbind.
  17645. */
  17646. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17647. /**
  17648. * An event triggered when the texture is unbind.
  17649. */
  17650. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17651. private _onAfterUnbindObserver;
  17652. /**
  17653. * Set a after unbind callback in the texture.
  17654. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17655. */
  17656. onAfterUnbind: () => void;
  17657. /**
  17658. * An event triggered before rendering the texture
  17659. */
  17660. onBeforeRenderObservable: Observable<number>;
  17661. private _onBeforeRenderObserver;
  17662. /**
  17663. * Set a before render callback in the texture.
  17664. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17665. */
  17666. onBeforeRender: (faceIndex: number) => void;
  17667. /**
  17668. * An event triggered after rendering the texture
  17669. */
  17670. onAfterRenderObservable: Observable<number>;
  17671. private _onAfterRenderObserver;
  17672. /**
  17673. * Set a after render callback in the texture.
  17674. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17675. */
  17676. onAfterRender: (faceIndex: number) => void;
  17677. /**
  17678. * An event triggered after the texture clear
  17679. */
  17680. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17681. private _onClearObserver;
  17682. /**
  17683. * Set a clear callback in the texture.
  17684. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17685. */
  17686. onClear: (Engine: Engine) => void;
  17687. /**
  17688. * Define the clear color of the Render Target if it should be different from the scene.
  17689. */
  17690. clearColor: Color4;
  17691. protected _size: number | {
  17692. width: number;
  17693. height: number;
  17694. };
  17695. protected _initialSizeParameter: number | {
  17696. width: number;
  17697. height: number;
  17698. } | {
  17699. ratio: number;
  17700. };
  17701. protected _sizeRatio: Nullable<number>;
  17702. /** @hidden */
  17703. _generateMipMaps: boolean;
  17704. protected _renderingManager: RenderingManager;
  17705. /** @hidden */
  17706. _waitingRenderList: string[];
  17707. protected _doNotChangeAspectRatio: boolean;
  17708. protected _currentRefreshId: number;
  17709. protected _refreshRate: number;
  17710. protected _textureMatrix: Matrix;
  17711. protected _samples: number;
  17712. protected _renderTargetOptions: RenderTargetCreationOptions;
  17713. /**
  17714. * Gets render target creation options that were used.
  17715. */
  17716. readonly renderTargetOptions: RenderTargetCreationOptions;
  17717. protected _engine: Engine;
  17718. protected _onRatioRescale(): void;
  17719. /**
  17720. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17721. * It must define where the camera used to render the texture is set
  17722. */
  17723. boundingBoxPosition: Vector3;
  17724. private _boundingBoxSize;
  17725. /**
  17726. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17727. * When defined, the cubemap will switch to local mode
  17728. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17729. * @example https://www.babylonjs-playground.com/#RNASML
  17730. */
  17731. boundingBoxSize: Vector3;
  17732. /**
  17733. * In case the RTT has been created with a depth texture, get the associated
  17734. * depth texture.
  17735. * Otherwise, return null.
  17736. */
  17737. depthStencilTexture: Nullable<InternalTexture>;
  17738. /**
  17739. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17740. * or used a shadow, depth texture...
  17741. * @param name The friendly name of the texture
  17742. * @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)
  17743. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17744. * @param generateMipMaps True if mip maps need to be generated after render.
  17745. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17746. * @param type The type of the buffer in the RTT (int, half float, float...)
  17747. * @param isCube True if a cube texture needs to be created
  17748. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17749. * @param generateDepthBuffer True to generate a depth buffer
  17750. * @param generateStencilBuffer True to generate a stencil buffer
  17751. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17752. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17753. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17754. */
  17755. constructor(name: string, size: number | {
  17756. width: number;
  17757. height: number;
  17758. } | {
  17759. ratio: number;
  17760. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17761. /**
  17762. * Creates a depth stencil texture.
  17763. * This is only available in WebGL 2 or with the depth texture extension available.
  17764. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17765. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17766. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17767. */
  17768. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17769. private _processSizeParameter;
  17770. /**
  17771. * Define the number of samples to use in case of MSAA.
  17772. * It defaults to one meaning no MSAA has been enabled.
  17773. */
  17774. samples: number;
  17775. /**
  17776. * Resets the refresh counter of the texture and start bak from scratch.
  17777. * Could be useful to regenerate the texture if it is setup to render only once.
  17778. */
  17779. resetRefreshCounter(): void;
  17780. /**
  17781. * Define the refresh rate of the texture or the rendering frequency.
  17782. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17783. */
  17784. refreshRate: number;
  17785. /**
  17786. * Adds a post process to the render target rendering passes.
  17787. * @param postProcess define the post process to add
  17788. */
  17789. addPostProcess(postProcess: PostProcess): void;
  17790. /**
  17791. * Clear all the post processes attached to the render target
  17792. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17793. */
  17794. clearPostProcesses(dispose?: boolean): void;
  17795. /**
  17796. * Remove one of the post process from the list of attached post processes to the texture
  17797. * @param postProcess define the post process to remove from the list
  17798. */
  17799. removePostProcess(postProcess: PostProcess): void;
  17800. /** @hidden */
  17801. _shouldRender(): boolean;
  17802. /**
  17803. * Gets the actual render size of the texture.
  17804. * @returns the width of the render size
  17805. */
  17806. getRenderSize(): number;
  17807. /**
  17808. * Gets the actual render width of the texture.
  17809. * @returns the width of the render size
  17810. */
  17811. getRenderWidth(): number;
  17812. /**
  17813. * Gets the actual render height of the texture.
  17814. * @returns the height of the render size
  17815. */
  17816. getRenderHeight(): number;
  17817. /**
  17818. * Get if the texture can be rescaled or not.
  17819. */
  17820. readonly canRescale: boolean;
  17821. /**
  17822. * Resize the texture using a ratio.
  17823. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17824. */
  17825. scale(ratio: number): void;
  17826. /**
  17827. * Get the texture reflection matrix used to rotate/transform the reflection.
  17828. * @returns the reflection matrix
  17829. */
  17830. getReflectionTextureMatrix(): Matrix;
  17831. /**
  17832. * Resize the texture to a new desired size.
  17833. * Be carrefull as it will recreate all the data in the new texture.
  17834. * @param size Define the new size. It can be:
  17835. * - a number for squared texture,
  17836. * - an object containing { width: number, height: number }
  17837. * - or an object containing a ratio { ratio: number }
  17838. */
  17839. resize(size: number | {
  17840. width: number;
  17841. height: number;
  17842. } | {
  17843. ratio: number;
  17844. }): void;
  17845. /**
  17846. * Renders all the objects from the render list into the texture.
  17847. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17848. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17849. */
  17850. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17851. private _bestReflectionRenderTargetDimension;
  17852. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17853. private renderToTarget;
  17854. /**
  17855. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17856. * This allowed control for front to back rendering or reversly depending of the special needs.
  17857. *
  17858. * @param renderingGroupId The rendering group id corresponding to its index
  17859. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17860. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17861. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17862. */
  17863. 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;
  17864. /**
  17865. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17866. *
  17867. * @param renderingGroupId The rendering group id corresponding to its index
  17868. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17869. */
  17870. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17871. /**
  17872. * Clones the texture.
  17873. * @returns the cloned texture
  17874. */
  17875. clone(): RenderTargetTexture;
  17876. /**
  17877. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17878. * @returns The JSON representation of the texture
  17879. */
  17880. serialize(): any;
  17881. /**
  17882. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17883. */
  17884. disposeFramebufferObjects(): void;
  17885. /**
  17886. * Dispose the texture and release its associated resources.
  17887. */
  17888. dispose(): void;
  17889. /** @hidden */
  17890. _rebuild(): void;
  17891. /**
  17892. * Clear the info related to rendering groups preventing retention point in material dispose.
  17893. */
  17894. freeRenderingGroups(): void;
  17895. }
  17896. }
  17897. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17898. import { Scene } from "babylonjs/scene";
  17899. import { Plane } from "babylonjs/Maths/math";
  17900. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17901. /**
  17902. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17903. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17904. * You can then easily use it as a reflectionTexture on a flat surface.
  17905. * In case the surface is not a plane, please consider relying on reflection probes.
  17906. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17907. */
  17908. export class MirrorTexture extends RenderTargetTexture {
  17909. private scene;
  17910. /**
  17911. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17912. * 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.
  17913. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17914. */
  17915. mirrorPlane: Plane;
  17916. /**
  17917. * Define the blur ratio used to blur the reflection if needed.
  17918. */
  17919. blurRatio: number;
  17920. /**
  17921. * Define the adaptive blur kernel used to blur the reflection if needed.
  17922. * This will autocompute the closest best match for the `blurKernel`
  17923. */
  17924. adaptiveBlurKernel: number;
  17925. /**
  17926. * Define the blur kernel used to blur the reflection if needed.
  17927. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17928. */
  17929. blurKernel: number;
  17930. /**
  17931. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17932. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17933. */
  17934. blurKernelX: number;
  17935. /**
  17936. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17937. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17938. */
  17939. blurKernelY: number;
  17940. private _autoComputeBlurKernel;
  17941. protected _onRatioRescale(): void;
  17942. private _updateGammaSpace;
  17943. private _imageProcessingConfigChangeObserver;
  17944. private _transformMatrix;
  17945. private _mirrorMatrix;
  17946. private _savedViewMatrix;
  17947. private _blurX;
  17948. private _blurY;
  17949. private _adaptiveBlurKernel;
  17950. private _blurKernelX;
  17951. private _blurKernelY;
  17952. private _blurRatio;
  17953. /**
  17954. * Instantiates a Mirror Texture.
  17955. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17956. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17957. * You can then easily use it as a reflectionTexture on a flat surface.
  17958. * In case the surface is not a plane, please consider relying on reflection probes.
  17959. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17960. * @param name
  17961. * @param size
  17962. * @param scene
  17963. * @param generateMipMaps
  17964. * @param type
  17965. * @param samplingMode
  17966. * @param generateDepthBuffer
  17967. */
  17968. constructor(name: string, size: number | {
  17969. width: number;
  17970. height: number;
  17971. } | {
  17972. ratio: number;
  17973. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17974. private _preparePostProcesses;
  17975. /**
  17976. * Clone the mirror texture.
  17977. * @returns the cloned texture
  17978. */
  17979. clone(): MirrorTexture;
  17980. /**
  17981. * Serialize the texture to a JSON representation you could use in Parse later on
  17982. * @returns the serialized JSON representation
  17983. */
  17984. serialize(): any;
  17985. /**
  17986. * Dispose the texture and release its associated resources.
  17987. */
  17988. dispose(): void;
  17989. }
  17990. }
  17991. declare module "babylonjs/Materials/Textures/texture" {
  17992. import { Observable } from "babylonjs/Misc/observable";
  17993. import { Nullable } from "babylonjs/types";
  17994. import { Scene } from "babylonjs/scene";
  17995. import { Matrix } from "babylonjs/Maths/math";
  17996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17997. /**
  17998. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17999. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18000. */
  18001. export class Texture extends BaseTexture {
  18002. /** @hidden */
  18003. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18004. /** @hidden */
  18005. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18006. /** @hidden */
  18007. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18008. /** nearest is mag = nearest and min = nearest and mip = linear */
  18009. static readonly NEAREST_SAMPLINGMODE: number;
  18010. /** nearest is mag = nearest and min = nearest and mip = linear */
  18011. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18012. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18013. static readonly BILINEAR_SAMPLINGMODE: number;
  18014. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18015. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18016. /** Trilinear is mag = linear and min = linear and mip = linear */
  18017. static readonly TRILINEAR_SAMPLINGMODE: number;
  18018. /** Trilinear is mag = linear and min = linear and mip = linear */
  18019. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18020. /** mag = nearest and min = nearest and mip = nearest */
  18021. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18022. /** mag = nearest and min = linear and mip = nearest */
  18023. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18024. /** mag = nearest and min = linear and mip = linear */
  18025. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18026. /** mag = nearest and min = linear and mip = none */
  18027. static readonly NEAREST_LINEAR: number;
  18028. /** mag = nearest and min = nearest and mip = none */
  18029. static readonly NEAREST_NEAREST: number;
  18030. /** mag = linear and min = nearest and mip = nearest */
  18031. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18032. /** mag = linear and min = nearest and mip = linear */
  18033. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18034. /** mag = linear and min = linear and mip = none */
  18035. static readonly LINEAR_LINEAR: number;
  18036. /** mag = linear and min = nearest and mip = none */
  18037. static readonly LINEAR_NEAREST: number;
  18038. /** Explicit coordinates mode */
  18039. static readonly EXPLICIT_MODE: number;
  18040. /** Spherical coordinates mode */
  18041. static readonly SPHERICAL_MODE: number;
  18042. /** Planar coordinates mode */
  18043. static readonly PLANAR_MODE: number;
  18044. /** Cubic coordinates mode */
  18045. static readonly CUBIC_MODE: number;
  18046. /** Projection coordinates mode */
  18047. static readonly PROJECTION_MODE: number;
  18048. /** Inverse Cubic coordinates mode */
  18049. static readonly SKYBOX_MODE: number;
  18050. /** Inverse Cubic coordinates mode */
  18051. static readonly INVCUBIC_MODE: number;
  18052. /** Equirectangular coordinates mode */
  18053. static readonly EQUIRECTANGULAR_MODE: number;
  18054. /** Equirectangular Fixed coordinates mode */
  18055. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18056. /** Equirectangular Fixed Mirrored coordinates mode */
  18057. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18058. /** Texture is not repeating outside of 0..1 UVs */
  18059. static readonly CLAMP_ADDRESSMODE: number;
  18060. /** Texture is repeating outside of 0..1 UVs */
  18061. static readonly WRAP_ADDRESSMODE: number;
  18062. /** Texture is repeating and mirrored */
  18063. static readonly MIRROR_ADDRESSMODE: number;
  18064. /**
  18065. * 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
  18066. */
  18067. static UseSerializedUrlIfAny: boolean;
  18068. /**
  18069. * Define the url of the texture.
  18070. */
  18071. url: Nullable<string>;
  18072. /**
  18073. * Define an offset on the texture to offset the u coordinates of the UVs
  18074. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18075. */
  18076. uOffset: number;
  18077. /**
  18078. * Define an offset on the texture to offset the v coordinates of the UVs
  18079. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18080. */
  18081. vOffset: number;
  18082. /**
  18083. * Define an offset on the texture to scale the u coordinates of the UVs
  18084. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18085. */
  18086. uScale: number;
  18087. /**
  18088. * Define an offset on the texture to scale the v coordinates of the UVs
  18089. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18090. */
  18091. vScale: number;
  18092. /**
  18093. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18094. * @see http://doc.babylonjs.com/how_to/more_materials
  18095. */
  18096. uAng: number;
  18097. /**
  18098. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18099. * @see http://doc.babylonjs.com/how_to/more_materials
  18100. */
  18101. vAng: number;
  18102. /**
  18103. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18104. * @see http://doc.babylonjs.com/how_to/more_materials
  18105. */
  18106. wAng: number;
  18107. /**
  18108. * Defines the center of rotation (U)
  18109. */
  18110. uRotationCenter: number;
  18111. /**
  18112. * Defines the center of rotation (V)
  18113. */
  18114. vRotationCenter: number;
  18115. /**
  18116. * Defines the center of rotation (W)
  18117. */
  18118. wRotationCenter: number;
  18119. /**
  18120. * Are mip maps generated for this texture or not.
  18121. */
  18122. readonly noMipmap: boolean;
  18123. private _noMipmap;
  18124. /** @hidden */
  18125. _invertY: boolean;
  18126. private _rowGenerationMatrix;
  18127. private _cachedTextureMatrix;
  18128. private _projectionModeMatrix;
  18129. private _t0;
  18130. private _t1;
  18131. private _t2;
  18132. private _cachedUOffset;
  18133. private _cachedVOffset;
  18134. private _cachedUScale;
  18135. private _cachedVScale;
  18136. private _cachedUAng;
  18137. private _cachedVAng;
  18138. private _cachedWAng;
  18139. private _cachedProjectionMatrixId;
  18140. private _cachedCoordinatesMode;
  18141. /** @hidden */
  18142. protected _initialSamplingMode: number;
  18143. /** @hidden */
  18144. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18145. private _deleteBuffer;
  18146. protected _format: Nullable<number>;
  18147. private _delayedOnLoad;
  18148. private _delayedOnError;
  18149. /**
  18150. * Observable triggered once the texture has been loaded.
  18151. */
  18152. onLoadObservable: Observable<Texture>;
  18153. protected _isBlocking: boolean;
  18154. /**
  18155. * Is the texture preventing material to render while loading.
  18156. * If false, a default texture will be used instead of the loading one during the preparation step.
  18157. */
  18158. isBlocking: boolean;
  18159. /**
  18160. * Get the current sampling mode associated with the texture.
  18161. */
  18162. readonly samplingMode: number;
  18163. /**
  18164. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18165. */
  18166. readonly invertY: boolean;
  18167. /**
  18168. * Instantiates a new texture.
  18169. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18170. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18171. * @param url define the url of the picture to load as a texture
  18172. * @param scene define the scene the texture will belong to
  18173. * @param noMipmap define if the texture will require mip maps or not
  18174. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18175. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18176. * @param onLoad define a callback triggered when the texture has been loaded
  18177. * @param onError define a callback triggered when an error occurred during the loading session
  18178. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18179. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18180. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18181. */
  18182. 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);
  18183. /**
  18184. * Update the url (and optional buffer) of this texture if url was null during construction.
  18185. * @param url the url of the texture
  18186. * @param buffer the buffer of the texture (defaults to null)
  18187. * @param onLoad callback called when the texture is loaded (defaults to null)
  18188. */
  18189. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18190. /**
  18191. * Finish the loading sequence of a texture flagged as delayed load.
  18192. * @hidden
  18193. */
  18194. delayLoad(): void;
  18195. private _prepareRowForTextureGeneration;
  18196. /**
  18197. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18198. * @returns the transform matrix of the texture.
  18199. */
  18200. getTextureMatrix(): Matrix;
  18201. /**
  18202. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18203. * @returns The reflection texture transform
  18204. */
  18205. getReflectionTextureMatrix(): Matrix;
  18206. /**
  18207. * Clones the texture.
  18208. * @returns the cloned texture
  18209. */
  18210. clone(): Texture;
  18211. /**
  18212. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18213. * @returns The JSON representation of the texture
  18214. */
  18215. serialize(): any;
  18216. /**
  18217. * Get the current class name of the texture useful for serialization or dynamic coding.
  18218. * @returns "Texture"
  18219. */
  18220. getClassName(): string;
  18221. /**
  18222. * Dispose the texture and release its associated resources.
  18223. */
  18224. dispose(): void;
  18225. /**
  18226. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18227. * @param parsedTexture Define the JSON representation of the texture
  18228. * @param scene Define the scene the parsed texture should be instantiated in
  18229. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18230. * @returns The parsed texture if successful
  18231. */
  18232. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18233. /**
  18234. * Creates a texture from its base 64 representation.
  18235. * @param data Define the base64 payload without the data: prefix
  18236. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18237. * @param scene Define the scene the texture should belong to
  18238. * @param noMipmap Forces the texture to not create mip map information if true
  18239. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18240. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18241. * @param onLoad define a callback triggered when the texture has been loaded
  18242. * @param onError define a callback triggered when an error occurred during the loading session
  18243. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18244. * @returns the created texture
  18245. */
  18246. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18247. /**
  18248. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18249. * @param data Define the base64 payload without the data: prefix
  18250. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18251. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18252. * @param scene Define the scene the texture should belong to
  18253. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18254. * @param noMipmap Forces the texture to not create mip map information if true
  18255. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18256. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18257. * @param onLoad define a callback triggered when the texture has been loaded
  18258. * @param onError define a callback triggered when an error occurred during the loading session
  18259. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18260. * @returns the created texture
  18261. */
  18262. 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;
  18263. }
  18264. }
  18265. declare module "babylonjs/Materials/Textures/rawTexture" {
  18266. import { Scene } from "babylonjs/scene";
  18267. import { Texture } from "babylonjs/Materials/Textures/texture";
  18268. /**
  18269. * Raw texture can help creating a texture directly from an array of data.
  18270. * This can be super useful if you either get the data from an uncompressed source or
  18271. * if you wish to create your texture pixel by pixel.
  18272. */
  18273. export class RawTexture extends Texture {
  18274. /**
  18275. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18276. */
  18277. format: number;
  18278. private _engine;
  18279. /**
  18280. * Instantiates a new RawTexture.
  18281. * Raw texture can help creating a texture directly from an array of data.
  18282. * This can be super useful if you either get the data from an uncompressed source or
  18283. * if you wish to create your texture pixel by pixel.
  18284. * @param data define the array of data to use to create the texture
  18285. * @param width define the width of the texture
  18286. * @param height define the height of the texture
  18287. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18288. * @param scene define the scene the texture belongs to
  18289. * @param generateMipMaps define whether mip maps should be generated or not
  18290. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18291. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18292. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18293. */
  18294. constructor(data: ArrayBufferView, width: number, height: number,
  18295. /**
  18296. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18297. */
  18298. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18299. /**
  18300. * Updates the texture underlying data.
  18301. * @param data Define the new data of the texture
  18302. */
  18303. update(data: ArrayBufferView): void;
  18304. /**
  18305. * Creates a luminance texture from some data.
  18306. * @param data Define the texture data
  18307. * @param width Define the width of the texture
  18308. * @param height Define the height of the texture
  18309. * @param scene Define the scene the texture belongs to
  18310. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18311. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18312. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18313. * @returns the luminance texture
  18314. */
  18315. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18316. /**
  18317. * Creates a luminance alpha texture from some data.
  18318. * @param data Define the texture data
  18319. * @param width Define the width of the texture
  18320. * @param height Define the height of the texture
  18321. * @param scene Define the scene the texture belongs to
  18322. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18323. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18324. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18325. * @returns the luminance alpha texture
  18326. */
  18327. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18328. /**
  18329. * Creates an alpha texture from some data.
  18330. * @param data Define the texture data
  18331. * @param width Define the width of the texture
  18332. * @param height Define the height of the texture
  18333. * @param scene Define the scene the texture belongs to
  18334. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18335. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18336. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18337. * @returns the alpha texture
  18338. */
  18339. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18340. /**
  18341. * Creates a RGB texture from some data.
  18342. * @param data Define the texture data
  18343. * @param width Define the width of the texture
  18344. * @param height Define the height of the texture
  18345. * @param scene Define the scene the texture belongs to
  18346. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18347. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18348. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18349. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18350. * @returns the RGB alpha texture
  18351. */
  18352. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18353. /**
  18354. * Creates a RGBA texture from some data.
  18355. * @param data Define the texture data
  18356. * @param width Define the width of the texture
  18357. * @param height Define the height of the texture
  18358. * @param scene Define the scene the texture belongs to
  18359. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18360. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18361. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18362. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18363. * @returns the RGBA texture
  18364. */
  18365. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18366. /**
  18367. * Creates a R texture from some data.
  18368. * @param data Define the texture data
  18369. * @param width Define the width of the texture
  18370. * @param height Define the height of the texture
  18371. * @param scene Define the scene the texture belongs to
  18372. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18373. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18374. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18375. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18376. * @returns the R texture
  18377. */
  18378. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18379. }
  18380. }
  18381. declare module "babylonjs/Animations/runtimeAnimation" {
  18382. import { Animation } from "babylonjs/Animations/animation";
  18383. import { Animatable } from "babylonjs/Animations/animatable";
  18384. import { Scene } from "babylonjs/scene";
  18385. /**
  18386. * Defines a runtime animation
  18387. */
  18388. export class RuntimeAnimation {
  18389. private _events;
  18390. /**
  18391. * The current frame of the runtime animation
  18392. */
  18393. private _currentFrame;
  18394. /**
  18395. * The animation used by the runtime animation
  18396. */
  18397. private _animation;
  18398. /**
  18399. * The target of the runtime animation
  18400. */
  18401. private _target;
  18402. /**
  18403. * The initiating animatable
  18404. */
  18405. private _host;
  18406. /**
  18407. * The original value of the runtime animation
  18408. */
  18409. private _originalValue;
  18410. /**
  18411. * The original blend value of the runtime animation
  18412. */
  18413. private _originalBlendValue;
  18414. /**
  18415. * The offsets cache of the runtime animation
  18416. */
  18417. private _offsetsCache;
  18418. /**
  18419. * The high limits cache of the runtime animation
  18420. */
  18421. private _highLimitsCache;
  18422. /**
  18423. * Specifies if the runtime animation has been stopped
  18424. */
  18425. private _stopped;
  18426. /**
  18427. * The blending factor of the runtime animation
  18428. */
  18429. private _blendingFactor;
  18430. /**
  18431. * The BabylonJS scene
  18432. */
  18433. private _scene;
  18434. /**
  18435. * The current value of the runtime animation
  18436. */
  18437. private _currentValue;
  18438. /** @hidden */
  18439. _workValue: any;
  18440. /**
  18441. * The active target of the runtime animation
  18442. */
  18443. private _activeTarget;
  18444. /**
  18445. * The target path of the runtime animation
  18446. */
  18447. private _targetPath;
  18448. /**
  18449. * The weight of the runtime animation
  18450. */
  18451. private _weight;
  18452. /**
  18453. * The ratio offset of the runtime animation
  18454. */
  18455. private _ratioOffset;
  18456. /**
  18457. * The previous delay of the runtime animation
  18458. */
  18459. private _previousDelay;
  18460. /**
  18461. * The previous ratio of the runtime animation
  18462. */
  18463. private _previousRatio;
  18464. /**
  18465. * Gets the current frame of the runtime animation
  18466. */
  18467. readonly currentFrame: number;
  18468. /**
  18469. * Gets the weight of the runtime animation
  18470. */
  18471. readonly weight: number;
  18472. /**
  18473. * Gets the current value of the runtime animation
  18474. */
  18475. readonly currentValue: any;
  18476. /**
  18477. * Gets the target path of the runtime animation
  18478. */
  18479. readonly targetPath: string;
  18480. /**
  18481. * Gets the actual target of the runtime animation
  18482. */
  18483. readonly target: any;
  18484. /**
  18485. * Create a new RuntimeAnimation object
  18486. * @param target defines the target of the animation
  18487. * @param animation defines the source animation object
  18488. * @param scene defines the hosting scene
  18489. * @param host defines the initiating Animatable
  18490. */
  18491. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18492. /**
  18493. * Gets the animation from the runtime animation
  18494. */
  18495. readonly animation: Animation;
  18496. /**
  18497. * Resets the runtime animation to the beginning
  18498. * @param restoreOriginal defines whether to restore the target property to the original value
  18499. */
  18500. reset(restoreOriginal?: boolean): void;
  18501. /**
  18502. * Specifies if the runtime animation is stopped
  18503. * @returns Boolean specifying if the runtime animation is stopped
  18504. */
  18505. isStopped(): boolean;
  18506. /**
  18507. * Disposes of the runtime animation
  18508. */
  18509. dispose(): void;
  18510. /**
  18511. * Interpolates the animation from the current frame
  18512. * @param currentFrame The frame to interpolate the animation to
  18513. * @param repeatCount The number of times that the animation should loop
  18514. * @param loopMode The type of looping mode to use
  18515. * @param offsetValue Animation offset value
  18516. * @param highLimitValue The high limit value
  18517. * @returns The interpolated value
  18518. */
  18519. private _interpolate;
  18520. /**
  18521. * Apply the interpolated value to the target
  18522. * @param currentValue defines the value computed by the animation
  18523. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18524. */
  18525. setValue(currentValue: any, weight?: number): void;
  18526. private _setValue;
  18527. /**
  18528. * Gets the loop pmode of the runtime animation
  18529. * @returns Loop Mode
  18530. */
  18531. private _getCorrectLoopMode;
  18532. /**
  18533. * Move the current animation to a given frame
  18534. * @param frame defines the frame to move to
  18535. */
  18536. goToFrame(frame: number): void;
  18537. /**
  18538. * @hidden Internal use only
  18539. */
  18540. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18541. /**
  18542. * Execute the current animation
  18543. * @param delay defines the delay to add to the current frame
  18544. * @param from defines the lower bound of the animation range
  18545. * @param to defines the upper bound of the animation range
  18546. * @param loop defines if the current animation must loop
  18547. * @param speedRatio defines the current speed ratio
  18548. * @param weight defines the weight of the animation (default is -1 so no weight)
  18549. * @param onLoop optional callback called when animation loops
  18550. * @returns a boolean indicating if the animation is running
  18551. */
  18552. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18553. }
  18554. }
  18555. declare module "babylonjs/Animations/animatable" {
  18556. import { Animation } from "babylonjs/Animations/animation";
  18557. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18558. import { Nullable } from "babylonjs/types";
  18559. import { Observable } from "babylonjs/Misc/observable";
  18560. import { Scene } from "babylonjs/scene";
  18561. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18562. import { Node } from "babylonjs/node";
  18563. /**
  18564. * Class used to store an actual running animation
  18565. */
  18566. export class Animatable {
  18567. /** defines the target object */
  18568. target: any;
  18569. /** defines the starting frame number (default is 0) */
  18570. fromFrame: number;
  18571. /** defines the ending frame number (default is 100) */
  18572. toFrame: number;
  18573. /** defines if the animation must loop (default is false) */
  18574. loopAnimation: boolean;
  18575. /** defines a callback to call when animation ends if it is not looping */
  18576. onAnimationEnd?: (() => void) | null | undefined;
  18577. /** defines a callback to call when animation loops */
  18578. onAnimationLoop?: (() => void) | null | undefined;
  18579. private _localDelayOffset;
  18580. private _pausedDelay;
  18581. private _runtimeAnimations;
  18582. private _paused;
  18583. private _scene;
  18584. private _speedRatio;
  18585. private _weight;
  18586. private _syncRoot;
  18587. /**
  18588. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18589. * This will only apply for non looping animation (default is true)
  18590. */
  18591. disposeOnEnd: boolean;
  18592. /**
  18593. * Gets a boolean indicating if the animation has started
  18594. */
  18595. animationStarted: boolean;
  18596. /**
  18597. * Observer raised when the animation ends
  18598. */
  18599. onAnimationEndObservable: Observable<Animatable>;
  18600. /**
  18601. * Observer raised when the animation loops
  18602. */
  18603. onAnimationLoopObservable: Observable<Animatable>;
  18604. /**
  18605. * Gets the root Animatable used to synchronize and normalize animations
  18606. */
  18607. readonly syncRoot: Animatable;
  18608. /**
  18609. * Gets the current frame of the first RuntimeAnimation
  18610. * Used to synchronize Animatables
  18611. */
  18612. readonly masterFrame: number;
  18613. /**
  18614. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18615. */
  18616. weight: number;
  18617. /**
  18618. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18619. */
  18620. speedRatio: number;
  18621. /**
  18622. * Creates a new Animatable
  18623. * @param scene defines the hosting scene
  18624. * @param target defines the target object
  18625. * @param fromFrame defines the starting frame number (default is 0)
  18626. * @param toFrame defines the ending frame number (default is 100)
  18627. * @param loopAnimation defines if the animation must loop (default is false)
  18628. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18629. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18630. * @param animations defines a group of animation to add to the new Animatable
  18631. * @param onAnimationLoop defines a callback to call when animation loops
  18632. */
  18633. constructor(scene: Scene,
  18634. /** defines the target object */
  18635. target: any,
  18636. /** defines the starting frame number (default is 0) */
  18637. fromFrame?: number,
  18638. /** defines the ending frame number (default is 100) */
  18639. toFrame?: number,
  18640. /** defines if the animation must loop (default is false) */
  18641. loopAnimation?: boolean, speedRatio?: number,
  18642. /** defines a callback to call when animation ends if it is not looping */
  18643. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18644. /** defines a callback to call when animation loops */
  18645. onAnimationLoop?: (() => void) | null | undefined);
  18646. /**
  18647. * Synchronize and normalize current Animatable with a source Animatable
  18648. * This is useful when using animation weights and when animations are not of the same length
  18649. * @param root defines the root Animatable to synchronize with
  18650. * @returns the current Animatable
  18651. */
  18652. syncWith(root: Animatable): Animatable;
  18653. /**
  18654. * Gets the list of runtime animations
  18655. * @returns an array of RuntimeAnimation
  18656. */
  18657. getAnimations(): RuntimeAnimation[];
  18658. /**
  18659. * Adds more animations to the current animatable
  18660. * @param target defines the target of the animations
  18661. * @param animations defines the new animations to add
  18662. */
  18663. appendAnimations(target: any, animations: Animation[]): void;
  18664. /**
  18665. * Gets the source animation for a specific property
  18666. * @param property defines the propertyu to look for
  18667. * @returns null or the source animation for the given property
  18668. */
  18669. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18670. /**
  18671. * Gets the runtime animation for a specific property
  18672. * @param property defines the propertyu to look for
  18673. * @returns null or the runtime animation for the given property
  18674. */
  18675. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18676. /**
  18677. * Resets the animatable to its original state
  18678. */
  18679. reset(): void;
  18680. /**
  18681. * Allows the animatable to blend with current running animations
  18682. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18683. * @param blendingSpeed defines the blending speed to use
  18684. */
  18685. enableBlending(blendingSpeed: number): void;
  18686. /**
  18687. * Disable animation blending
  18688. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18689. */
  18690. disableBlending(): void;
  18691. /**
  18692. * Jump directly to a given frame
  18693. * @param frame defines the frame to jump to
  18694. */
  18695. goToFrame(frame: number): void;
  18696. /**
  18697. * Pause the animation
  18698. */
  18699. pause(): void;
  18700. /**
  18701. * Restart the animation
  18702. */
  18703. restart(): void;
  18704. private _raiseOnAnimationEnd;
  18705. /**
  18706. * Stop and delete the current animation
  18707. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18708. * @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)
  18709. */
  18710. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18711. /**
  18712. * Wait asynchronously for the animation to end
  18713. * @returns a promise which will be fullfilled when the animation ends
  18714. */
  18715. waitAsync(): Promise<Animatable>;
  18716. /** @hidden */
  18717. _animate(delay: number): boolean;
  18718. }
  18719. module "babylonjs/scene" {
  18720. interface Scene {
  18721. /** @hidden */
  18722. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18723. /** @hidden */
  18724. _processLateAnimationBindingsForMatrices(holder: {
  18725. totalWeight: number;
  18726. animations: RuntimeAnimation[];
  18727. originalValue: Matrix;
  18728. }): any;
  18729. /** @hidden */
  18730. _processLateAnimationBindingsForQuaternions(holder: {
  18731. totalWeight: number;
  18732. animations: RuntimeAnimation[];
  18733. originalValue: Quaternion;
  18734. }, refQuaternion: Quaternion): Quaternion;
  18735. /** @hidden */
  18736. _processLateAnimationBindings(): void;
  18737. /**
  18738. * Will start the animation sequence of a given target
  18739. * @param target defines the target
  18740. * @param from defines from which frame should animation start
  18741. * @param to defines until which frame should animation run.
  18742. * @param weight defines the weight to apply to the animation (1.0 by default)
  18743. * @param loop defines if the animation loops
  18744. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18745. * @param onAnimationEnd defines the function to be executed when the animation ends
  18746. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18747. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18748. * @param onAnimationLoop defines the callback to call when an animation loops
  18749. * @returns the animatable object created for this animation
  18750. */
  18751. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18752. /**
  18753. * Will start the animation sequence of a given target
  18754. * @param target defines the target
  18755. * @param from defines from which frame should animation start
  18756. * @param to defines until which frame should animation run.
  18757. * @param loop defines if the animation loops
  18758. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18759. * @param onAnimationEnd defines the function to be executed when the animation ends
  18760. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18761. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18762. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18763. * @param onAnimationLoop defines the callback to call when an animation loops
  18764. * @returns the animatable object created for this animation
  18765. */
  18766. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18767. /**
  18768. * Will start the animation sequence of a given target and its hierarchy
  18769. * @param target defines the target
  18770. * @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.
  18771. * @param from defines from which frame should animation start
  18772. * @param to defines until which frame should animation run.
  18773. * @param loop defines if the animation loops
  18774. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18775. * @param onAnimationEnd defines the function to be executed when the animation ends
  18776. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18777. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18778. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18779. * @param onAnimationLoop defines the callback to call when an animation loops
  18780. * @returns the list of created animatables
  18781. */
  18782. 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[];
  18783. /**
  18784. * Begin a new animation on a given node
  18785. * @param target defines the target where the animation will take place
  18786. * @param animations defines the list of animations to start
  18787. * @param from defines the initial value
  18788. * @param to defines the final value
  18789. * @param loop defines if you want animation to loop (off by default)
  18790. * @param speedRatio defines the speed ratio to apply to all animations
  18791. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18792. * @param onAnimationLoop defines the callback to call when an animation loops
  18793. * @returns the list of created animatables
  18794. */
  18795. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18796. /**
  18797. * Begin a new animation on a given node and its hierarchy
  18798. * @param target defines the root node where the animation will take place
  18799. * @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.
  18800. * @param animations defines the list of animations to start
  18801. * @param from defines the initial value
  18802. * @param to defines the final value
  18803. * @param loop defines if you want animation to loop (off by default)
  18804. * @param speedRatio defines the speed ratio to apply to all animations
  18805. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18806. * @param onAnimationLoop defines the callback to call when an animation loops
  18807. * @returns the list of animatables created for all nodes
  18808. */
  18809. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18810. /**
  18811. * Gets the animatable associated with a specific target
  18812. * @param target defines the target of the animatable
  18813. * @returns the required animatable if found
  18814. */
  18815. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18816. /**
  18817. * Gets all animatables associated with a given target
  18818. * @param target defines the target to look animatables for
  18819. * @returns an array of Animatables
  18820. */
  18821. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18822. /**
  18823. * Will stop the animation of the given target
  18824. * @param target - the target
  18825. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18826. * @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)
  18827. */
  18828. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18829. /**
  18830. * Stops and removes all animations that have been applied to the scene
  18831. */
  18832. stopAllAnimations(): void;
  18833. }
  18834. }
  18835. module "babylonjs/Bones/bone" {
  18836. interface Bone {
  18837. /**
  18838. * Copy an animation range from another bone
  18839. * @param source defines the source bone
  18840. * @param rangeName defines the range name to copy
  18841. * @param frameOffset defines the frame offset
  18842. * @param rescaleAsRequired defines if rescaling must be applied if required
  18843. * @param skelDimensionsRatio defines the scaling ratio
  18844. * @returns true if operation was successful
  18845. */
  18846. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18847. }
  18848. }
  18849. }
  18850. declare module "babylonjs/Bones/skeleton" {
  18851. import { Bone } from "babylonjs/Bones/bone";
  18852. import { IAnimatable } from "babylonjs/Misc/tools";
  18853. import { Observable } from "babylonjs/Misc/observable";
  18854. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18855. import { Scene } from "babylonjs/scene";
  18856. import { Nullable } from "babylonjs/types";
  18857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18858. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18859. import { Animatable } from "babylonjs/Animations/animatable";
  18860. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18861. import { Animation } from "babylonjs/Animations/animation";
  18862. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18863. /**
  18864. * Class used to handle skinning animations
  18865. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18866. */
  18867. export class Skeleton implements IAnimatable {
  18868. /** defines the skeleton name */
  18869. name: string;
  18870. /** defines the skeleton Id */
  18871. id: string;
  18872. /**
  18873. * Defines the list of child bones
  18874. */
  18875. bones: Bone[];
  18876. /**
  18877. * Defines an estimate of the dimension of the skeleton at rest
  18878. */
  18879. dimensionsAtRest: Vector3;
  18880. /**
  18881. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18882. */
  18883. needInitialSkinMatrix: boolean;
  18884. /**
  18885. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18886. */
  18887. overrideMesh: Nullable<AbstractMesh>;
  18888. /**
  18889. * Gets the list of animations attached to this skeleton
  18890. */
  18891. animations: Array<Animation>;
  18892. private _scene;
  18893. private _isDirty;
  18894. private _transformMatrices;
  18895. private _transformMatrixTexture;
  18896. private _meshesWithPoseMatrix;
  18897. private _animatables;
  18898. private _identity;
  18899. private _synchronizedWithMesh;
  18900. private _ranges;
  18901. private _lastAbsoluteTransformsUpdateId;
  18902. private _canUseTextureForBones;
  18903. /** @hidden */
  18904. _numBonesWithLinkedTransformNode: number;
  18905. /**
  18906. * Specifies if the skeleton should be serialized
  18907. */
  18908. doNotSerialize: boolean;
  18909. /**
  18910. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18911. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18912. */
  18913. useTextureToStoreBoneMatrices: boolean;
  18914. private _animationPropertiesOverride;
  18915. /**
  18916. * Gets or sets the animation properties override
  18917. */
  18918. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18919. /**
  18920. * An observable triggered before computing the skeleton's matrices
  18921. */
  18922. onBeforeComputeObservable: Observable<Skeleton>;
  18923. /**
  18924. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18925. */
  18926. readonly isUsingTextureForMatrices: boolean;
  18927. /**
  18928. * Creates a new skeleton
  18929. * @param name defines the skeleton name
  18930. * @param id defines the skeleton Id
  18931. * @param scene defines the hosting scene
  18932. */
  18933. constructor(
  18934. /** defines the skeleton name */
  18935. name: string,
  18936. /** defines the skeleton Id */
  18937. id: string, scene: Scene);
  18938. /**
  18939. * Gets the current object class name.
  18940. * @return the class name
  18941. */
  18942. getClassName(): string;
  18943. /**
  18944. * Returns an array containing the root bones
  18945. * @returns an array containing the root bones
  18946. */
  18947. getChildren(): Array<Bone>;
  18948. /**
  18949. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18950. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18951. * @returns a Float32Array containing matrices data
  18952. */
  18953. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18954. /**
  18955. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18956. * @returns a raw texture containing the data
  18957. */
  18958. getTransformMatrixTexture(): Nullable<RawTexture>;
  18959. /**
  18960. * Gets the current hosting scene
  18961. * @returns a scene object
  18962. */
  18963. getScene(): Scene;
  18964. /**
  18965. * Gets a string representing the current skeleton data
  18966. * @param fullDetails defines a boolean indicating if we want a verbose version
  18967. * @returns a string representing the current skeleton data
  18968. */
  18969. toString(fullDetails?: boolean): string;
  18970. /**
  18971. * Get bone's index searching by name
  18972. * @param name defines bone's name to search for
  18973. * @return the indice of the bone. Returns -1 if not found
  18974. */
  18975. getBoneIndexByName(name: string): number;
  18976. /**
  18977. * Creater a new animation range
  18978. * @param name defines the name of the range
  18979. * @param from defines the start key
  18980. * @param to defines the end key
  18981. */
  18982. createAnimationRange(name: string, from: number, to: number): void;
  18983. /**
  18984. * Delete a specific animation range
  18985. * @param name defines the name of the range
  18986. * @param deleteFrames defines if frames must be removed as well
  18987. */
  18988. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18989. /**
  18990. * Gets a specific animation range
  18991. * @param name defines the name of the range to look for
  18992. * @returns the requested animation range or null if not found
  18993. */
  18994. getAnimationRange(name: string): Nullable<AnimationRange>;
  18995. /**
  18996. * Gets the list of all animation ranges defined on this skeleton
  18997. * @returns an array
  18998. */
  18999. getAnimationRanges(): Nullable<AnimationRange>[];
  19000. /**
  19001. * Copy animation range from a source skeleton.
  19002. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19003. * @param source defines the source skeleton
  19004. * @param name defines the name of the range to copy
  19005. * @param rescaleAsRequired defines if rescaling must be applied if required
  19006. * @returns true if operation was successful
  19007. */
  19008. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19009. /**
  19010. * Forces the skeleton to go to rest pose
  19011. */
  19012. returnToRest(): void;
  19013. private _getHighestAnimationFrame;
  19014. /**
  19015. * Begin a specific animation range
  19016. * @param name defines the name of the range to start
  19017. * @param loop defines if looping must be turned on (false by default)
  19018. * @param speedRatio defines the speed ratio to apply (1 by default)
  19019. * @param onAnimationEnd defines a callback which will be called when animation will end
  19020. * @returns a new animatable
  19021. */
  19022. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19023. /** @hidden */
  19024. _markAsDirty(): void;
  19025. /** @hidden */
  19026. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19027. /** @hidden */
  19028. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19029. private _computeTransformMatrices;
  19030. /**
  19031. * Build all resources required to render a skeleton
  19032. */
  19033. prepare(): void;
  19034. /**
  19035. * Gets the list of animatables currently running for this skeleton
  19036. * @returns an array of animatables
  19037. */
  19038. getAnimatables(): IAnimatable[];
  19039. /**
  19040. * Clone the current skeleton
  19041. * @param name defines the name of the new skeleton
  19042. * @param id defines the id of the enw skeleton
  19043. * @returns the new skeleton
  19044. */
  19045. clone(name: string, id: string): Skeleton;
  19046. /**
  19047. * Enable animation blending for this skeleton
  19048. * @param blendingSpeed defines the blending speed to apply
  19049. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19050. */
  19051. enableBlending(blendingSpeed?: number): void;
  19052. /**
  19053. * Releases all resources associated with the current skeleton
  19054. */
  19055. dispose(): void;
  19056. /**
  19057. * Serialize the skeleton in a JSON object
  19058. * @returns a JSON object
  19059. */
  19060. serialize(): any;
  19061. /**
  19062. * Creates a new skeleton from serialized data
  19063. * @param parsedSkeleton defines the serialized data
  19064. * @param scene defines the hosting scene
  19065. * @returns a new skeleton
  19066. */
  19067. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19068. /**
  19069. * Compute all node absolute transforms
  19070. * @param forceUpdate defines if computation must be done even if cache is up to date
  19071. */
  19072. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19073. /**
  19074. * Gets the root pose matrix
  19075. * @returns a matrix
  19076. */
  19077. getPoseMatrix(): Nullable<Matrix>;
  19078. /**
  19079. * Sorts bones per internal index
  19080. */
  19081. sortBones(): void;
  19082. private _sortBones;
  19083. }
  19084. }
  19085. declare module "babylonjs/Morph/morphTarget" {
  19086. import { IAnimatable } from "babylonjs/Misc/tools";
  19087. import { Observable } from "babylonjs/Misc/observable";
  19088. import { Nullable, FloatArray } from "babylonjs/types";
  19089. import { Scene } from "babylonjs/scene";
  19090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19091. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19092. /**
  19093. * Defines a target to use with MorphTargetManager
  19094. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19095. */
  19096. export class MorphTarget implements IAnimatable {
  19097. /** defines the name of the target */
  19098. name: string;
  19099. /**
  19100. * Gets or sets the list of animations
  19101. */
  19102. animations: import("babylonjs/Animations/animation").Animation[];
  19103. private _scene;
  19104. private _positions;
  19105. private _normals;
  19106. private _tangents;
  19107. private _influence;
  19108. /**
  19109. * Observable raised when the influence changes
  19110. */
  19111. onInfluenceChanged: Observable<boolean>;
  19112. /** @hidden */
  19113. _onDataLayoutChanged: Observable<void>;
  19114. /**
  19115. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19116. */
  19117. influence: number;
  19118. /**
  19119. * Gets or sets the id of the morph Target
  19120. */
  19121. id: string;
  19122. private _animationPropertiesOverride;
  19123. /**
  19124. * Gets or sets the animation properties override
  19125. */
  19126. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19127. /**
  19128. * Creates a new MorphTarget
  19129. * @param name defines the name of the target
  19130. * @param influence defines the influence to use
  19131. * @param scene defines the scene the morphtarget belongs to
  19132. */
  19133. constructor(
  19134. /** defines the name of the target */
  19135. name: string, influence?: number, scene?: Nullable<Scene>);
  19136. /**
  19137. * Gets a boolean defining if the target contains position data
  19138. */
  19139. readonly hasPositions: boolean;
  19140. /**
  19141. * Gets a boolean defining if the target contains normal data
  19142. */
  19143. readonly hasNormals: boolean;
  19144. /**
  19145. * Gets a boolean defining if the target contains tangent data
  19146. */
  19147. readonly hasTangents: boolean;
  19148. /**
  19149. * Affects position data to this target
  19150. * @param data defines the position data to use
  19151. */
  19152. setPositions(data: Nullable<FloatArray>): void;
  19153. /**
  19154. * Gets the position data stored in this target
  19155. * @returns a FloatArray containing the position data (or null if not present)
  19156. */
  19157. getPositions(): Nullable<FloatArray>;
  19158. /**
  19159. * Affects normal data to this target
  19160. * @param data defines the normal data to use
  19161. */
  19162. setNormals(data: Nullable<FloatArray>): void;
  19163. /**
  19164. * Gets the normal data stored in this target
  19165. * @returns a FloatArray containing the normal data (or null if not present)
  19166. */
  19167. getNormals(): Nullable<FloatArray>;
  19168. /**
  19169. * Affects tangent data to this target
  19170. * @param data defines the tangent data to use
  19171. */
  19172. setTangents(data: Nullable<FloatArray>): void;
  19173. /**
  19174. * Gets the tangent data stored in this target
  19175. * @returns a FloatArray containing the tangent data (or null if not present)
  19176. */
  19177. getTangents(): Nullable<FloatArray>;
  19178. /**
  19179. * Serializes the current target into a Serialization object
  19180. * @returns the serialized object
  19181. */
  19182. serialize(): any;
  19183. /**
  19184. * Returns the string "MorphTarget"
  19185. * @returns "MorphTarget"
  19186. */
  19187. getClassName(): string;
  19188. /**
  19189. * Creates a new target from serialized data
  19190. * @param serializationObject defines the serialized data to use
  19191. * @returns a new MorphTarget
  19192. */
  19193. static Parse(serializationObject: any): MorphTarget;
  19194. /**
  19195. * Creates a MorphTarget from mesh data
  19196. * @param mesh defines the source mesh
  19197. * @param name defines the name to use for the new target
  19198. * @param influence defines the influence to attach to the target
  19199. * @returns a new MorphTarget
  19200. */
  19201. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19202. }
  19203. }
  19204. declare module "babylonjs/Morph/morphTargetManager" {
  19205. import { Nullable } from "babylonjs/types";
  19206. import { Scene } from "babylonjs/scene";
  19207. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19208. /**
  19209. * This class is used to deform meshes using morphing between different targets
  19210. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19211. */
  19212. export class MorphTargetManager {
  19213. private _targets;
  19214. private _targetInfluenceChangedObservers;
  19215. private _targetDataLayoutChangedObservers;
  19216. private _activeTargets;
  19217. private _scene;
  19218. private _influences;
  19219. private _supportsNormals;
  19220. private _supportsTangents;
  19221. private _vertexCount;
  19222. private _uniqueId;
  19223. private _tempInfluences;
  19224. /**
  19225. * Creates a new MorphTargetManager
  19226. * @param scene defines the current scene
  19227. */
  19228. constructor(scene?: Nullable<Scene>);
  19229. /**
  19230. * Gets the unique ID of this manager
  19231. */
  19232. readonly uniqueId: number;
  19233. /**
  19234. * Gets the number of vertices handled by this manager
  19235. */
  19236. readonly vertexCount: number;
  19237. /**
  19238. * Gets a boolean indicating if this manager supports morphing of normals
  19239. */
  19240. readonly supportsNormals: boolean;
  19241. /**
  19242. * Gets a boolean indicating if this manager supports morphing of tangents
  19243. */
  19244. readonly supportsTangents: boolean;
  19245. /**
  19246. * Gets the number of targets stored in this manager
  19247. */
  19248. readonly numTargets: number;
  19249. /**
  19250. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19251. */
  19252. readonly numInfluencers: number;
  19253. /**
  19254. * Gets the list of influences (one per target)
  19255. */
  19256. readonly influences: Float32Array;
  19257. /**
  19258. * Gets the active target at specified index. An active target is a target with an influence > 0
  19259. * @param index defines the index to check
  19260. * @returns the requested target
  19261. */
  19262. getActiveTarget(index: number): MorphTarget;
  19263. /**
  19264. * Gets the target at specified index
  19265. * @param index defines the index to check
  19266. * @returns the requested target
  19267. */
  19268. getTarget(index: number): MorphTarget;
  19269. /**
  19270. * Add a new target to this manager
  19271. * @param target defines the target to add
  19272. */
  19273. addTarget(target: MorphTarget): void;
  19274. /**
  19275. * Removes a target from the manager
  19276. * @param target defines the target to remove
  19277. */
  19278. removeTarget(target: MorphTarget): void;
  19279. /**
  19280. * Serializes the current manager into a Serialization object
  19281. * @returns the serialized object
  19282. */
  19283. serialize(): any;
  19284. private _syncActiveTargets;
  19285. /**
  19286. * Syncrhonize the targets with all the meshes using this morph target manager
  19287. */
  19288. synchronize(): void;
  19289. /**
  19290. * Creates a new MorphTargetManager from serialized data
  19291. * @param serializationObject defines the serialized data
  19292. * @param scene defines the hosting scene
  19293. * @returns the new MorphTargetManager
  19294. */
  19295. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19296. }
  19297. }
  19298. declare module "babylonjs/Meshes/groundMesh" {
  19299. import { Scene } from "babylonjs/scene";
  19300. import { Vector3 } from "babylonjs/Maths/math";
  19301. import { Mesh } from "babylonjs/Meshes/mesh";
  19302. /**
  19303. * Mesh representing the gorund
  19304. */
  19305. export class GroundMesh extends Mesh {
  19306. /** If octree should be generated */
  19307. generateOctree: boolean;
  19308. private _heightQuads;
  19309. /** @hidden */
  19310. _subdivisionsX: number;
  19311. /** @hidden */
  19312. _subdivisionsY: number;
  19313. /** @hidden */
  19314. _width: number;
  19315. /** @hidden */
  19316. _height: number;
  19317. /** @hidden */
  19318. _minX: number;
  19319. /** @hidden */
  19320. _maxX: number;
  19321. /** @hidden */
  19322. _minZ: number;
  19323. /** @hidden */
  19324. _maxZ: number;
  19325. constructor(name: string, scene: Scene);
  19326. /**
  19327. * "GroundMesh"
  19328. * @returns "GroundMesh"
  19329. */
  19330. getClassName(): string;
  19331. /**
  19332. * The minimum of x and y subdivisions
  19333. */
  19334. readonly subdivisions: number;
  19335. /**
  19336. * X subdivisions
  19337. */
  19338. readonly subdivisionsX: number;
  19339. /**
  19340. * Y subdivisions
  19341. */
  19342. readonly subdivisionsY: number;
  19343. /**
  19344. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19345. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19346. * @param chunksCount the number of subdivisions for x and y
  19347. * @param octreeBlocksSize (Default: 32)
  19348. */
  19349. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19350. /**
  19351. * Returns a height (y) value in the Worl system :
  19352. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19353. * @param x x coordinate
  19354. * @param z z coordinate
  19355. * @returns the ground y position if (x, z) are outside the ground surface.
  19356. */
  19357. getHeightAtCoordinates(x: number, z: number): number;
  19358. /**
  19359. * Returns a normalized vector (Vector3) orthogonal to the ground
  19360. * at the ground coordinates (x, z) expressed in the World system.
  19361. * @param x x coordinate
  19362. * @param z z coordinate
  19363. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19364. */
  19365. getNormalAtCoordinates(x: number, z: number): Vector3;
  19366. /**
  19367. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19368. * at the ground coordinates (x, z) expressed in the World system.
  19369. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19370. * @param x x coordinate
  19371. * @param z z coordinate
  19372. * @param ref vector to store the result
  19373. * @returns the GroundMesh.
  19374. */
  19375. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19376. /**
  19377. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19378. * if the ground has been updated.
  19379. * This can be used in the render loop.
  19380. * @returns the GroundMesh.
  19381. */
  19382. updateCoordinateHeights(): GroundMesh;
  19383. private _getFacetAt;
  19384. private _initHeightQuads;
  19385. private _computeHeightQuads;
  19386. /**
  19387. * Serializes this ground mesh
  19388. * @param serializationObject object to write serialization to
  19389. */
  19390. serialize(serializationObject: any): void;
  19391. /**
  19392. * Parses a serialized ground mesh
  19393. * @param parsedMesh the serialized mesh
  19394. * @param scene the scene to create the ground mesh in
  19395. * @returns the created ground mesh
  19396. */
  19397. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19398. }
  19399. }
  19400. declare module "babylonjs/Physics/physicsJoint" {
  19401. import { Vector3 } from "babylonjs/Maths/math";
  19402. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19403. /**
  19404. * Interface for Physics-Joint data
  19405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19406. */
  19407. export interface PhysicsJointData {
  19408. /**
  19409. * The main pivot of the joint
  19410. */
  19411. mainPivot?: Vector3;
  19412. /**
  19413. * The connected pivot of the joint
  19414. */
  19415. connectedPivot?: Vector3;
  19416. /**
  19417. * The main axis of the joint
  19418. */
  19419. mainAxis?: Vector3;
  19420. /**
  19421. * The connected axis of the joint
  19422. */
  19423. connectedAxis?: Vector3;
  19424. /**
  19425. * The collision of the joint
  19426. */
  19427. collision?: boolean;
  19428. /**
  19429. * Native Oimo/Cannon/Energy data
  19430. */
  19431. nativeParams?: any;
  19432. }
  19433. /**
  19434. * This is a holder class for the physics joint created by the physics plugin
  19435. * It holds a set of functions to control the underlying joint
  19436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19437. */
  19438. export class PhysicsJoint {
  19439. /**
  19440. * The type of the physics joint
  19441. */
  19442. type: number;
  19443. /**
  19444. * The data for the physics joint
  19445. */
  19446. jointData: PhysicsJointData;
  19447. private _physicsJoint;
  19448. protected _physicsPlugin: IPhysicsEnginePlugin;
  19449. /**
  19450. * Initializes the physics joint
  19451. * @param type The type of the physics joint
  19452. * @param jointData The data for the physics joint
  19453. */
  19454. constructor(
  19455. /**
  19456. * The type of the physics joint
  19457. */
  19458. type: number,
  19459. /**
  19460. * The data for the physics joint
  19461. */
  19462. jointData: PhysicsJointData);
  19463. /**
  19464. * Gets the physics joint
  19465. */
  19466. /**
  19467. * Sets the physics joint
  19468. */
  19469. physicsJoint: any;
  19470. /**
  19471. * Sets the physics plugin
  19472. */
  19473. physicsPlugin: IPhysicsEnginePlugin;
  19474. /**
  19475. * Execute a function that is physics-plugin specific.
  19476. * @param {Function} func the function that will be executed.
  19477. * It accepts two parameters: the physics world and the physics joint
  19478. */
  19479. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19480. /**
  19481. * Distance-Joint type
  19482. */
  19483. static DistanceJoint: number;
  19484. /**
  19485. * Hinge-Joint type
  19486. */
  19487. static HingeJoint: number;
  19488. /**
  19489. * Ball-and-Socket joint type
  19490. */
  19491. static BallAndSocketJoint: number;
  19492. /**
  19493. * Wheel-Joint type
  19494. */
  19495. static WheelJoint: number;
  19496. /**
  19497. * Slider-Joint type
  19498. */
  19499. static SliderJoint: number;
  19500. /**
  19501. * Prismatic-Joint type
  19502. */
  19503. static PrismaticJoint: number;
  19504. /**
  19505. * Universal-Joint type
  19506. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19507. */
  19508. static UniversalJoint: number;
  19509. /**
  19510. * Hinge-Joint 2 type
  19511. */
  19512. static Hinge2Joint: number;
  19513. /**
  19514. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19515. */
  19516. static PointToPointJoint: number;
  19517. /**
  19518. * Spring-Joint type
  19519. */
  19520. static SpringJoint: number;
  19521. /**
  19522. * Lock-Joint type
  19523. */
  19524. static LockJoint: number;
  19525. }
  19526. /**
  19527. * A class representing a physics distance joint
  19528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19529. */
  19530. export class DistanceJoint extends PhysicsJoint {
  19531. /**
  19532. *
  19533. * @param jointData The data for the Distance-Joint
  19534. */
  19535. constructor(jointData: DistanceJointData);
  19536. /**
  19537. * Update the predefined distance.
  19538. * @param maxDistance The maximum preferred distance
  19539. * @param minDistance The minimum preferred distance
  19540. */
  19541. updateDistance(maxDistance: number, minDistance?: number): void;
  19542. }
  19543. /**
  19544. * Represents a Motor-Enabled Joint
  19545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19546. */
  19547. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19548. /**
  19549. * Initializes the Motor-Enabled Joint
  19550. * @param type The type of the joint
  19551. * @param jointData The physica joint data for the joint
  19552. */
  19553. constructor(type: number, jointData: PhysicsJointData);
  19554. /**
  19555. * Set the motor values.
  19556. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19557. * @param force the force to apply
  19558. * @param maxForce max force for this motor.
  19559. */
  19560. setMotor(force?: number, maxForce?: number): void;
  19561. /**
  19562. * Set the motor's limits.
  19563. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19564. * @param upperLimit The upper limit of the motor
  19565. * @param lowerLimit The lower limit of the motor
  19566. */
  19567. setLimit(upperLimit: number, lowerLimit?: number): void;
  19568. }
  19569. /**
  19570. * This class represents a single physics Hinge-Joint
  19571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19572. */
  19573. export class HingeJoint extends MotorEnabledJoint {
  19574. /**
  19575. * Initializes the Hinge-Joint
  19576. * @param jointData The joint data for the Hinge-Joint
  19577. */
  19578. constructor(jointData: PhysicsJointData);
  19579. /**
  19580. * Set the motor values.
  19581. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19582. * @param {number} force the force to apply
  19583. * @param {number} maxForce max force for this motor.
  19584. */
  19585. setMotor(force?: number, maxForce?: number): void;
  19586. /**
  19587. * Set the motor's limits.
  19588. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19589. * @param upperLimit The upper limit of the motor
  19590. * @param lowerLimit The lower limit of the motor
  19591. */
  19592. setLimit(upperLimit: number, lowerLimit?: number): void;
  19593. }
  19594. /**
  19595. * This class represents a dual hinge physics joint (same as wheel joint)
  19596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19597. */
  19598. export class Hinge2Joint extends MotorEnabledJoint {
  19599. /**
  19600. * Initializes the Hinge2-Joint
  19601. * @param jointData The joint data for the Hinge2-Joint
  19602. */
  19603. constructor(jointData: PhysicsJointData);
  19604. /**
  19605. * Set the motor values.
  19606. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19607. * @param {number} targetSpeed the speed the motor is to reach
  19608. * @param {number} maxForce max force for this motor.
  19609. * @param {motorIndex} the motor's index, 0 or 1.
  19610. */
  19611. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19612. /**
  19613. * Set the motor limits.
  19614. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19615. * @param {number} upperLimit the upper limit
  19616. * @param {number} lowerLimit lower limit
  19617. * @param {motorIndex} the motor's index, 0 or 1.
  19618. */
  19619. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19620. }
  19621. /**
  19622. * Interface for a motor enabled joint
  19623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19624. */
  19625. export interface IMotorEnabledJoint {
  19626. /**
  19627. * Physics joint
  19628. */
  19629. physicsJoint: any;
  19630. /**
  19631. * Sets the motor of the motor-enabled joint
  19632. * @param force The force of the motor
  19633. * @param maxForce The maximum force of the motor
  19634. * @param motorIndex The index of the motor
  19635. */
  19636. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19637. /**
  19638. * Sets the limit of the motor
  19639. * @param upperLimit The upper limit of the motor
  19640. * @param lowerLimit The lower limit of the motor
  19641. * @param motorIndex The index of the motor
  19642. */
  19643. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19644. }
  19645. /**
  19646. * Joint data for a Distance-Joint
  19647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19648. */
  19649. export interface DistanceJointData extends PhysicsJointData {
  19650. /**
  19651. * Max distance the 2 joint objects can be apart
  19652. */
  19653. maxDistance: number;
  19654. }
  19655. /**
  19656. * Joint data from a spring joint
  19657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19658. */
  19659. export interface SpringJointData extends PhysicsJointData {
  19660. /**
  19661. * Length of the spring
  19662. */
  19663. length: number;
  19664. /**
  19665. * Stiffness of the spring
  19666. */
  19667. stiffness: number;
  19668. /**
  19669. * Damping of the spring
  19670. */
  19671. damping: number;
  19672. /** this callback will be called when applying the force to the impostors. */
  19673. forceApplicationCallback: () => void;
  19674. }
  19675. }
  19676. declare module "babylonjs/Physics/IPhysicsEngine" {
  19677. import { Nullable } from "babylonjs/types";
  19678. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19680. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19681. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19682. /**
  19683. * Interface used to describe a physics joint
  19684. */
  19685. export interface PhysicsImpostorJoint {
  19686. /** Defines the main impostor to which the joint is linked */
  19687. mainImpostor: PhysicsImpostor;
  19688. /** Defines the impostor that is connected to the main impostor using this joint */
  19689. connectedImpostor: PhysicsImpostor;
  19690. /** Defines the joint itself */
  19691. joint: PhysicsJoint;
  19692. }
  19693. /** @hidden */
  19694. export interface IPhysicsEnginePlugin {
  19695. world: any;
  19696. name: string;
  19697. setGravity(gravity: Vector3): void;
  19698. setTimeStep(timeStep: number): void;
  19699. getTimeStep(): number;
  19700. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19701. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19702. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19703. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19704. removePhysicsBody(impostor: PhysicsImpostor): void;
  19705. generateJoint(joint: PhysicsImpostorJoint): void;
  19706. removeJoint(joint: PhysicsImpostorJoint): void;
  19707. isSupported(): boolean;
  19708. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19709. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19710. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19711. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19712. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19713. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19714. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19715. getBodyMass(impostor: PhysicsImpostor): number;
  19716. getBodyFriction(impostor: PhysicsImpostor): number;
  19717. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19718. getBodyRestitution(impostor: PhysicsImpostor): number;
  19719. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19720. sleepBody(impostor: PhysicsImpostor): void;
  19721. wakeUpBody(impostor: PhysicsImpostor): void;
  19722. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19723. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19724. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19725. getRadius(impostor: PhysicsImpostor): number;
  19726. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19727. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19728. dispose(): void;
  19729. }
  19730. /**
  19731. * Interface used to define a physics engine
  19732. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19733. */
  19734. export interface IPhysicsEngine {
  19735. /**
  19736. * Gets the gravity vector used by the simulation
  19737. */
  19738. gravity: Vector3;
  19739. /**
  19740. * Sets the gravity vector used by the simulation
  19741. * @param gravity defines the gravity vector to use
  19742. */
  19743. setGravity(gravity: Vector3): void;
  19744. /**
  19745. * Set the time step of the physics engine.
  19746. * Default is 1/60.
  19747. * To slow it down, enter 1/600 for example.
  19748. * To speed it up, 1/30
  19749. * @param newTimeStep the new timestep to apply to this world.
  19750. */
  19751. setTimeStep(newTimeStep: number): void;
  19752. /**
  19753. * Get the time step of the physics engine.
  19754. * @returns the current time step
  19755. */
  19756. getTimeStep(): number;
  19757. /**
  19758. * Release all resources
  19759. */
  19760. dispose(): void;
  19761. /**
  19762. * Gets the name of the current physics plugin
  19763. * @returns the name of the plugin
  19764. */
  19765. getPhysicsPluginName(): string;
  19766. /**
  19767. * Adding a new impostor for the impostor tracking.
  19768. * This will be done by the impostor itself.
  19769. * @param impostor the impostor to add
  19770. */
  19771. addImpostor(impostor: PhysicsImpostor): void;
  19772. /**
  19773. * Remove an impostor from the engine.
  19774. * This impostor and its mesh will not longer be updated by the physics engine.
  19775. * @param impostor the impostor to remove
  19776. */
  19777. removeImpostor(impostor: PhysicsImpostor): void;
  19778. /**
  19779. * Add a joint to the physics engine
  19780. * @param mainImpostor defines the main impostor to which the joint is added.
  19781. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19782. * @param joint defines the joint that will connect both impostors.
  19783. */
  19784. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19785. /**
  19786. * Removes a joint from the simulation
  19787. * @param mainImpostor defines the impostor used with the joint
  19788. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19789. * @param joint defines the joint to remove
  19790. */
  19791. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19792. /**
  19793. * Gets the current plugin used to run the simulation
  19794. * @returns current plugin
  19795. */
  19796. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19797. /**
  19798. * Gets the list of physic impostors
  19799. * @returns an array of PhysicsImpostor
  19800. */
  19801. getImpostors(): Array<PhysicsImpostor>;
  19802. /**
  19803. * Gets the impostor for a physics enabled object
  19804. * @param object defines the object impersonated by the impostor
  19805. * @returns the PhysicsImpostor or null if not found
  19806. */
  19807. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19808. /**
  19809. * Gets the impostor for a physics body object
  19810. * @param body defines physics body used by the impostor
  19811. * @returns the PhysicsImpostor or null if not found
  19812. */
  19813. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19814. /**
  19815. * Called by the scene. No need to call it.
  19816. * @param delta defines the timespam between frames
  19817. */
  19818. _step(delta: number): void;
  19819. }
  19820. }
  19821. declare module "babylonjs/Physics/physicsImpostor" {
  19822. import { Nullable, IndicesArray } from "babylonjs/types";
  19823. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19824. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19826. import { Scene } from "babylonjs/scene";
  19827. import { Bone } from "babylonjs/Bones/bone";
  19828. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19829. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19830. /**
  19831. * The interface for the physics imposter parameters
  19832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19833. */
  19834. export interface PhysicsImpostorParameters {
  19835. /**
  19836. * The mass of the physics imposter
  19837. */
  19838. mass: number;
  19839. /**
  19840. * The friction of the physics imposter
  19841. */
  19842. friction?: number;
  19843. /**
  19844. * The coefficient of restitution of the physics imposter
  19845. */
  19846. restitution?: number;
  19847. /**
  19848. * The native options of the physics imposter
  19849. */
  19850. nativeOptions?: any;
  19851. /**
  19852. * Specifies if the parent should be ignored
  19853. */
  19854. ignoreParent?: boolean;
  19855. /**
  19856. * Specifies if bi-directional transformations should be disabled
  19857. */
  19858. disableBidirectionalTransformation?: boolean;
  19859. }
  19860. /**
  19861. * Interface for a physics-enabled object
  19862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19863. */
  19864. export interface IPhysicsEnabledObject {
  19865. /**
  19866. * The position of the physics-enabled object
  19867. */
  19868. position: Vector3;
  19869. /**
  19870. * The rotation of the physics-enabled object
  19871. */
  19872. rotationQuaternion: Nullable<Quaternion>;
  19873. /**
  19874. * The scale of the physics-enabled object
  19875. */
  19876. scaling: Vector3;
  19877. /**
  19878. * The rotation of the physics-enabled object
  19879. */
  19880. rotation?: Vector3;
  19881. /**
  19882. * The parent of the physics-enabled object
  19883. */
  19884. parent?: any;
  19885. /**
  19886. * The bounding info of the physics-enabled object
  19887. * @returns The bounding info of the physics-enabled object
  19888. */
  19889. getBoundingInfo(): BoundingInfo;
  19890. /**
  19891. * Computes the world matrix
  19892. * @param force Specifies if the world matrix should be computed by force
  19893. * @returns A world matrix
  19894. */
  19895. computeWorldMatrix(force: boolean): Matrix;
  19896. /**
  19897. * Gets the world matrix
  19898. * @returns A world matrix
  19899. */
  19900. getWorldMatrix?(): Matrix;
  19901. /**
  19902. * Gets the child meshes
  19903. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19904. * @returns An array of abstract meshes
  19905. */
  19906. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19907. /**
  19908. * Gets the vertex data
  19909. * @param kind The type of vertex data
  19910. * @returns A nullable array of numbers, or a float32 array
  19911. */
  19912. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19913. /**
  19914. * Gets the indices from the mesh
  19915. * @returns A nullable array of index arrays
  19916. */
  19917. getIndices?(): Nullable<IndicesArray>;
  19918. /**
  19919. * Gets the scene from the mesh
  19920. * @returns the indices array or null
  19921. */
  19922. getScene?(): Scene;
  19923. /**
  19924. * Gets the absolute position from the mesh
  19925. * @returns the absolute position
  19926. */
  19927. getAbsolutePosition(): Vector3;
  19928. /**
  19929. * Gets the absolute pivot point from the mesh
  19930. * @returns the absolute pivot point
  19931. */
  19932. getAbsolutePivotPoint(): Vector3;
  19933. /**
  19934. * Rotates the mesh
  19935. * @param axis The axis of rotation
  19936. * @param amount The amount of rotation
  19937. * @param space The space of the rotation
  19938. * @returns The rotation transform node
  19939. */
  19940. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19941. /**
  19942. * Translates the mesh
  19943. * @param axis The axis of translation
  19944. * @param distance The distance of translation
  19945. * @param space The space of the translation
  19946. * @returns The transform node
  19947. */
  19948. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19949. /**
  19950. * Sets the absolute position of the mesh
  19951. * @param absolutePosition The absolute position of the mesh
  19952. * @returns The transform node
  19953. */
  19954. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19955. /**
  19956. * Gets the class name of the mesh
  19957. * @returns The class name
  19958. */
  19959. getClassName(): string;
  19960. }
  19961. /**
  19962. * Represents a physics imposter
  19963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19964. */
  19965. export class PhysicsImpostor {
  19966. /**
  19967. * The physics-enabled object used as the physics imposter
  19968. */
  19969. object: IPhysicsEnabledObject;
  19970. /**
  19971. * The type of the physics imposter
  19972. */
  19973. type: number;
  19974. private _options;
  19975. private _scene?;
  19976. /**
  19977. * The default object size of the imposter
  19978. */
  19979. static DEFAULT_OBJECT_SIZE: Vector3;
  19980. /**
  19981. * The identity quaternion of the imposter
  19982. */
  19983. static IDENTITY_QUATERNION: Quaternion;
  19984. /** @hidden */
  19985. _pluginData: any;
  19986. private _physicsEngine;
  19987. private _physicsBody;
  19988. private _bodyUpdateRequired;
  19989. private _onBeforePhysicsStepCallbacks;
  19990. private _onAfterPhysicsStepCallbacks;
  19991. /** @hidden */
  19992. _onPhysicsCollideCallbacks: Array<{
  19993. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19994. otherImpostors: Array<PhysicsImpostor>;
  19995. }>;
  19996. private _deltaPosition;
  19997. private _deltaRotation;
  19998. private _deltaRotationConjugated;
  19999. private _parent;
  20000. private _isDisposed;
  20001. private static _tmpVecs;
  20002. private static _tmpQuat;
  20003. /**
  20004. * Specifies if the physics imposter is disposed
  20005. */
  20006. readonly isDisposed: boolean;
  20007. /**
  20008. * Gets the mass of the physics imposter
  20009. */
  20010. mass: number;
  20011. /**
  20012. * Gets the coefficient of friction
  20013. */
  20014. /**
  20015. * Sets the coefficient of friction
  20016. */
  20017. friction: number;
  20018. /**
  20019. * Gets the coefficient of restitution
  20020. */
  20021. /**
  20022. * Sets the coefficient of restitution
  20023. */
  20024. restitution: number;
  20025. /**
  20026. * The unique id of the physics imposter
  20027. * set by the physics engine when adding this impostor to the array
  20028. */
  20029. uniqueId: number;
  20030. private _joints;
  20031. /**
  20032. * Initializes the physics imposter
  20033. * @param object The physics-enabled object used as the physics imposter
  20034. * @param type The type of the physics imposter
  20035. * @param _options The options for the physics imposter
  20036. * @param _scene The Babylon scene
  20037. */
  20038. constructor(
  20039. /**
  20040. * The physics-enabled object used as the physics imposter
  20041. */
  20042. object: IPhysicsEnabledObject,
  20043. /**
  20044. * The type of the physics imposter
  20045. */
  20046. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20047. /**
  20048. * This function will completly initialize this impostor.
  20049. * It will create a new body - but only if this mesh has no parent.
  20050. * If it has, this impostor will not be used other than to define the impostor
  20051. * of the child mesh.
  20052. * @hidden
  20053. */
  20054. _init(): void;
  20055. private _getPhysicsParent;
  20056. /**
  20057. * Should a new body be generated.
  20058. * @returns boolean specifying if body initialization is required
  20059. */
  20060. isBodyInitRequired(): boolean;
  20061. /**
  20062. * Sets the updated scaling
  20063. * @param updated Specifies if the scaling is updated
  20064. */
  20065. setScalingUpdated(): void;
  20066. /**
  20067. * Force a regeneration of this or the parent's impostor's body.
  20068. * Use under cautious - This will remove all joints already implemented.
  20069. */
  20070. forceUpdate(): void;
  20071. /**
  20072. * Gets the body that holds this impostor. Either its own, or its parent.
  20073. */
  20074. /**
  20075. * Set the physics body. Used mainly by the physics engine/plugin
  20076. */
  20077. physicsBody: any;
  20078. /**
  20079. * Get the parent of the physics imposter
  20080. * @returns Physics imposter or null
  20081. */
  20082. /**
  20083. * Sets the parent of the physics imposter
  20084. */
  20085. parent: Nullable<PhysicsImpostor>;
  20086. /**
  20087. * Resets the update flags
  20088. */
  20089. resetUpdateFlags(): void;
  20090. /**
  20091. * Gets the object extend size
  20092. * @returns the object extend size
  20093. */
  20094. getObjectExtendSize(): Vector3;
  20095. /**
  20096. * Gets the object center
  20097. * @returns The object center
  20098. */
  20099. getObjectCenter(): Vector3;
  20100. /**
  20101. * Get a specific parametes from the options parameter
  20102. * @param paramName The object parameter name
  20103. * @returns The object parameter
  20104. */
  20105. getParam(paramName: string): any;
  20106. /**
  20107. * Sets a specific parameter in the options given to the physics plugin
  20108. * @param paramName The parameter name
  20109. * @param value The value of the parameter
  20110. */
  20111. setParam(paramName: string, value: number): void;
  20112. /**
  20113. * Specifically change the body's mass option. Won't recreate the physics body object
  20114. * @param mass The mass of the physics imposter
  20115. */
  20116. setMass(mass: number): void;
  20117. /**
  20118. * Gets the linear velocity
  20119. * @returns linear velocity or null
  20120. */
  20121. getLinearVelocity(): Nullable<Vector3>;
  20122. /**
  20123. * Sets the linear velocity
  20124. * @param velocity linear velocity or null
  20125. */
  20126. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20127. /**
  20128. * Gets the angular velocity
  20129. * @returns angular velocity or null
  20130. */
  20131. getAngularVelocity(): Nullable<Vector3>;
  20132. /**
  20133. * Sets the angular velocity
  20134. * @param velocity The velocity or null
  20135. */
  20136. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20137. /**
  20138. * Execute a function with the physics plugin native code
  20139. * Provide a function the will have two variables - the world object and the physics body object
  20140. * @param func The function to execute with the physics plugin native code
  20141. */
  20142. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20143. /**
  20144. * Register a function that will be executed before the physics world is stepping forward
  20145. * @param func The function to execute before the physics world is stepped forward
  20146. */
  20147. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20148. /**
  20149. * Unregister a function that will be executed before the physics world is stepping forward
  20150. * @param func The function to execute before the physics world is stepped forward
  20151. */
  20152. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20153. /**
  20154. * Register a function that will be executed after the physics step
  20155. * @param func The function to execute after physics step
  20156. */
  20157. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20158. /**
  20159. * Unregisters a function that will be executed after the physics step
  20160. * @param func The function to execute after physics step
  20161. */
  20162. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20163. /**
  20164. * register a function that will be executed when this impostor collides against a different body
  20165. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20166. * @param func Callback that is executed on collision
  20167. */
  20168. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20169. /**
  20170. * Unregisters the physics imposter on contact
  20171. * @param collideAgainst The physics object to collide against
  20172. * @param func Callback to execute on collision
  20173. */
  20174. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20175. private _tmpQuat;
  20176. private _tmpQuat2;
  20177. /**
  20178. * Get the parent rotation
  20179. * @returns The parent rotation
  20180. */
  20181. getParentsRotation(): Quaternion;
  20182. /**
  20183. * this function is executed by the physics engine.
  20184. */
  20185. beforeStep: () => void;
  20186. /**
  20187. * this function is executed by the physics engine
  20188. */
  20189. afterStep: () => void;
  20190. /**
  20191. * Legacy collision detection event support
  20192. */
  20193. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20194. /**
  20195. * event and body object due to cannon's event-based architecture.
  20196. */
  20197. onCollide: (e: {
  20198. body: any;
  20199. }) => void;
  20200. /**
  20201. * Apply a force
  20202. * @param force The force to apply
  20203. * @param contactPoint The contact point for the force
  20204. * @returns The physics imposter
  20205. */
  20206. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20207. /**
  20208. * Apply an impulse
  20209. * @param force The impulse force
  20210. * @param contactPoint The contact point for the impulse force
  20211. * @returns The physics imposter
  20212. */
  20213. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20214. /**
  20215. * A help function to create a joint
  20216. * @param otherImpostor A physics imposter used to create a joint
  20217. * @param jointType The type of joint
  20218. * @param jointData The data for the joint
  20219. * @returns The physics imposter
  20220. */
  20221. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20222. /**
  20223. * Add a joint to this impostor with a different impostor
  20224. * @param otherImpostor A physics imposter used to add a joint
  20225. * @param joint The joint to add
  20226. * @returns The physics imposter
  20227. */
  20228. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20229. /**
  20230. * Will keep this body still, in a sleep mode.
  20231. * @returns the physics imposter
  20232. */
  20233. sleep(): PhysicsImpostor;
  20234. /**
  20235. * Wake the body up.
  20236. * @returns The physics imposter
  20237. */
  20238. wakeUp(): PhysicsImpostor;
  20239. /**
  20240. * Clones the physics imposter
  20241. * @param newObject The physics imposter clones to this physics-enabled object
  20242. * @returns A nullable physics imposter
  20243. */
  20244. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20245. /**
  20246. * Disposes the physics imposter
  20247. */
  20248. dispose(): void;
  20249. /**
  20250. * Sets the delta position
  20251. * @param position The delta position amount
  20252. */
  20253. setDeltaPosition(position: Vector3): void;
  20254. /**
  20255. * Sets the delta rotation
  20256. * @param rotation The delta rotation amount
  20257. */
  20258. setDeltaRotation(rotation: Quaternion): void;
  20259. /**
  20260. * Gets the box size of the physics imposter and stores the result in the input parameter
  20261. * @param result Stores the box size
  20262. * @returns The physics imposter
  20263. */
  20264. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20265. /**
  20266. * Gets the radius of the physics imposter
  20267. * @returns Radius of the physics imposter
  20268. */
  20269. getRadius(): number;
  20270. /**
  20271. * Sync a bone with this impostor
  20272. * @param bone The bone to sync to the impostor.
  20273. * @param boneMesh The mesh that the bone is influencing.
  20274. * @param jointPivot The pivot of the joint / bone in local space.
  20275. * @param distToJoint Optional distance from the impostor to the joint.
  20276. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20277. */
  20278. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20279. /**
  20280. * Sync impostor to a bone
  20281. * @param bone The bone that the impostor will be synced to.
  20282. * @param boneMesh The mesh that the bone is influencing.
  20283. * @param jointPivot The pivot of the joint / bone in local space.
  20284. * @param distToJoint Optional distance from the impostor to the joint.
  20285. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20286. * @param boneAxis Optional vector3 axis the bone is aligned with
  20287. */
  20288. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20289. /**
  20290. * No-Imposter type
  20291. */
  20292. static NoImpostor: number;
  20293. /**
  20294. * Sphere-Imposter type
  20295. */
  20296. static SphereImpostor: number;
  20297. /**
  20298. * Box-Imposter type
  20299. */
  20300. static BoxImpostor: number;
  20301. /**
  20302. * Plane-Imposter type
  20303. */
  20304. static PlaneImpostor: number;
  20305. /**
  20306. * Mesh-imposter type
  20307. */
  20308. static MeshImpostor: number;
  20309. /**
  20310. * Cylinder-Imposter type
  20311. */
  20312. static CylinderImpostor: number;
  20313. /**
  20314. * Particle-Imposter type
  20315. */
  20316. static ParticleImpostor: number;
  20317. /**
  20318. * Heightmap-Imposter type
  20319. */
  20320. static HeightmapImpostor: number;
  20321. }
  20322. }
  20323. declare module "babylonjs/Meshes/mesh" {
  20324. import { Observable } from "babylonjs/Misc/observable";
  20325. import { IAnimatable } from "babylonjs/Misc/tools";
  20326. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20327. import { Camera } from "babylonjs/Cameras/camera";
  20328. import { Scene } from "babylonjs/scene";
  20329. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20330. import { Engine } from "babylonjs/Engines/engine";
  20331. import { Node } from "babylonjs/node";
  20332. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20333. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20334. import { Buffer } from "babylonjs/Meshes/buffer";
  20335. import { Geometry } from "babylonjs/Meshes/geometry";
  20336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20337. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20338. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20339. import { Effect } from "babylonjs/Materials/effect";
  20340. import { Material } from "babylonjs/Materials/material";
  20341. import { Skeleton } from "babylonjs/Bones/skeleton";
  20342. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20343. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20344. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20345. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20346. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20347. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20348. /**
  20349. * Class used to represent a specific level of detail of a mesh
  20350. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20351. */
  20352. export class MeshLODLevel {
  20353. /** Defines the distance where this level should star being displayed */
  20354. distance: number;
  20355. /** Defines the mesh to use to render this level */
  20356. mesh: Nullable<Mesh>;
  20357. /**
  20358. * Creates a new LOD level
  20359. * @param distance defines the distance where this level should star being displayed
  20360. * @param mesh defines the mesh to use to render this level
  20361. */
  20362. constructor(
  20363. /** Defines the distance where this level should star being displayed */
  20364. distance: number,
  20365. /** Defines the mesh to use to render this level */
  20366. mesh: Nullable<Mesh>);
  20367. }
  20368. /**
  20369. * @hidden
  20370. **/
  20371. export class _CreationDataStorage {
  20372. closePath?: boolean;
  20373. closeArray?: boolean;
  20374. idx: number[];
  20375. dashSize: number;
  20376. gapSize: number;
  20377. path3D: Path3D;
  20378. pathArray: Vector3[][];
  20379. arc: number;
  20380. radius: number;
  20381. cap: number;
  20382. tessellation: number;
  20383. }
  20384. /**
  20385. * @hidden
  20386. **/
  20387. class _InstanceDataStorage {
  20388. visibleInstances: any;
  20389. renderIdForInstances: number[];
  20390. batchCache: _InstancesBatch;
  20391. instancesBufferSize: number;
  20392. instancesBuffer: Nullable<Buffer>;
  20393. instancesData: Float32Array;
  20394. overridenInstanceCount: number;
  20395. }
  20396. /**
  20397. * @hidden
  20398. **/
  20399. export class _InstancesBatch {
  20400. mustReturn: boolean;
  20401. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20402. renderSelf: boolean[];
  20403. }
  20404. /**
  20405. * Class used to represent renderable models
  20406. */
  20407. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20408. /**
  20409. * Mesh side orientation : usually the external or front surface
  20410. */
  20411. static readonly FRONTSIDE: number;
  20412. /**
  20413. * Mesh side orientation : usually the internal or back surface
  20414. */
  20415. static readonly BACKSIDE: number;
  20416. /**
  20417. * Mesh side orientation : both internal and external or front and back surfaces
  20418. */
  20419. static readonly DOUBLESIDE: number;
  20420. /**
  20421. * Mesh side orientation : by default, `FRONTSIDE`
  20422. */
  20423. static readonly DEFAULTSIDE: number;
  20424. /**
  20425. * Mesh cap setting : no cap
  20426. */
  20427. static readonly NO_CAP: number;
  20428. /**
  20429. * Mesh cap setting : one cap at the beginning of the mesh
  20430. */
  20431. static readonly CAP_START: number;
  20432. /**
  20433. * Mesh cap setting : one cap at the end of the mesh
  20434. */
  20435. static readonly CAP_END: number;
  20436. /**
  20437. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20438. */
  20439. static readonly CAP_ALL: number;
  20440. /**
  20441. * Gets the default side orientation.
  20442. * @param orientation the orientation to value to attempt to get
  20443. * @returns the default orientation
  20444. * @hidden
  20445. */
  20446. static _GetDefaultSideOrientation(orientation?: number): number;
  20447. private _onBeforeRenderObservable;
  20448. private _onBeforeBindObservable;
  20449. private _onAfterRenderObservable;
  20450. private _onBeforeDrawObservable;
  20451. /**
  20452. * An event triggered before rendering the mesh
  20453. */
  20454. readonly onBeforeRenderObservable: Observable<Mesh>;
  20455. /**
  20456. * An event triggered before binding the mesh
  20457. */
  20458. readonly onBeforeBindObservable: Observable<Mesh>;
  20459. /**
  20460. * An event triggered after rendering the mesh
  20461. */
  20462. readonly onAfterRenderObservable: Observable<Mesh>;
  20463. /**
  20464. * An event triggered before drawing the mesh
  20465. */
  20466. readonly onBeforeDrawObservable: Observable<Mesh>;
  20467. private _onBeforeDrawObserver;
  20468. /**
  20469. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20470. */
  20471. onBeforeDraw: () => void;
  20472. /**
  20473. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20474. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20475. */
  20476. delayLoadState: number;
  20477. /**
  20478. * Gets the list of instances created from this mesh
  20479. * it is not supposed to be modified manually.
  20480. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20481. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20482. */
  20483. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20484. /**
  20485. * Gets the file containing delay loading data for this mesh
  20486. */
  20487. delayLoadingFile: string;
  20488. /** @hidden */
  20489. _binaryInfo: any;
  20490. private _LODLevels;
  20491. /**
  20492. * User defined function used to change how LOD level selection is done
  20493. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20494. */
  20495. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20496. private _morphTargetManager;
  20497. /**
  20498. * Gets or sets the morph target manager
  20499. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20500. */
  20501. morphTargetManager: Nullable<MorphTargetManager>;
  20502. /** @hidden */
  20503. _creationDataStorage: Nullable<_CreationDataStorage>;
  20504. /** @hidden */
  20505. _geometry: Nullable<Geometry>;
  20506. /** @hidden */
  20507. _delayInfo: Array<string>;
  20508. /** @hidden */
  20509. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20510. /** @hidden */
  20511. _instanceDataStorage: _InstanceDataStorage;
  20512. private _effectiveMaterial;
  20513. /** @hidden */
  20514. _shouldGenerateFlatShading: boolean;
  20515. private _preActivateId;
  20516. /** @hidden */
  20517. _originalBuilderSideOrientation: number;
  20518. /**
  20519. * Use this property to change the original side orientation defined at construction time
  20520. */
  20521. overrideMaterialSideOrientation: Nullable<number>;
  20522. private _areNormalsFrozen;
  20523. private _sourcePositions;
  20524. private _sourceNormals;
  20525. private _source;
  20526. private meshMap;
  20527. /**
  20528. * Gets the source mesh (the one used to clone this one from)
  20529. */
  20530. readonly source: Nullable<Mesh>;
  20531. /**
  20532. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20533. */
  20534. isUnIndexed: boolean;
  20535. /**
  20536. * @constructor
  20537. * @param name The value used by scene.getMeshByName() to do a lookup.
  20538. * @param scene The scene to add this mesh to.
  20539. * @param parent The parent of this mesh, if it has one
  20540. * @param source An optional Mesh from which geometry is shared, cloned.
  20541. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20542. * When false, achieved by calling a clone(), also passing False.
  20543. * This will make creation of children, recursive.
  20544. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20545. */
  20546. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20547. /**
  20548. * Gets the class name
  20549. * @returns the string "Mesh".
  20550. */
  20551. getClassName(): string;
  20552. /** @hidden */
  20553. readonly _isMesh: boolean;
  20554. /**
  20555. * Returns a description of this mesh
  20556. * @param fullDetails define if full details about this mesh must be used
  20557. * @returns a descriptive string representing this mesh
  20558. */
  20559. toString(fullDetails?: boolean): string;
  20560. /** @hidden */
  20561. _unBindEffect(): void;
  20562. /**
  20563. * Gets a boolean indicating if this mesh has LOD
  20564. */
  20565. readonly hasLODLevels: boolean;
  20566. /**
  20567. * Gets the list of MeshLODLevel associated with the current mesh
  20568. * @returns an array of MeshLODLevel
  20569. */
  20570. getLODLevels(): MeshLODLevel[];
  20571. private _sortLODLevels;
  20572. /**
  20573. * Add a mesh as LOD level triggered at the given distance.
  20574. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20575. * @param distance The distance from the center of the object to show this level
  20576. * @param mesh The mesh to be added as LOD level (can be null)
  20577. * @return This mesh (for chaining)
  20578. */
  20579. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20580. /**
  20581. * Returns the LOD level mesh at the passed distance or null if not found.
  20582. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20583. * @param distance The distance from the center of the object to show this level
  20584. * @returns a Mesh or `null`
  20585. */
  20586. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20587. /**
  20588. * Remove a mesh from the LOD array
  20589. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20590. * @param mesh defines the mesh to be removed
  20591. * @return This mesh (for chaining)
  20592. */
  20593. removeLODLevel(mesh: Mesh): Mesh;
  20594. /**
  20595. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20596. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20597. * @param camera defines the camera to use to compute distance
  20598. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20599. * @return This mesh (for chaining)
  20600. */
  20601. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20602. /**
  20603. * Gets the mesh internal Geometry object
  20604. */
  20605. readonly geometry: Nullable<Geometry>;
  20606. /**
  20607. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20608. * @returns the total number of vertices
  20609. */
  20610. getTotalVertices(): number;
  20611. /**
  20612. * Returns the content of an associated vertex buffer
  20613. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20614. * - VertexBuffer.PositionKind
  20615. * - VertexBuffer.UVKind
  20616. * - VertexBuffer.UV2Kind
  20617. * - VertexBuffer.UV3Kind
  20618. * - VertexBuffer.UV4Kind
  20619. * - VertexBuffer.UV5Kind
  20620. * - VertexBuffer.UV6Kind
  20621. * - VertexBuffer.ColorKind
  20622. * - VertexBuffer.MatricesIndicesKind
  20623. * - VertexBuffer.MatricesIndicesExtraKind
  20624. * - VertexBuffer.MatricesWeightsKind
  20625. * - VertexBuffer.MatricesWeightsExtraKind
  20626. * @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
  20627. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20628. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20629. */
  20630. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20631. /**
  20632. * Returns the mesh VertexBuffer object from the requested `kind`
  20633. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20634. * - VertexBuffer.PositionKind
  20635. * - VertexBuffer.UVKind
  20636. * - VertexBuffer.UV2Kind
  20637. * - VertexBuffer.UV3Kind
  20638. * - VertexBuffer.UV4Kind
  20639. * - VertexBuffer.UV5Kind
  20640. * - VertexBuffer.UV6Kind
  20641. * - VertexBuffer.ColorKind
  20642. * - VertexBuffer.MatricesIndicesKind
  20643. * - VertexBuffer.MatricesIndicesExtraKind
  20644. * - VertexBuffer.MatricesWeightsKind
  20645. * - VertexBuffer.MatricesWeightsExtraKind
  20646. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20647. */
  20648. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20649. /**
  20650. * Tests if a specific vertex buffer is associated with this mesh
  20651. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20652. * - VertexBuffer.PositionKind
  20653. * - VertexBuffer.UVKind
  20654. * - VertexBuffer.UV2Kind
  20655. * - VertexBuffer.UV3Kind
  20656. * - VertexBuffer.UV4Kind
  20657. * - VertexBuffer.UV5Kind
  20658. * - VertexBuffer.UV6Kind
  20659. * - VertexBuffer.ColorKind
  20660. * - VertexBuffer.MatricesIndicesKind
  20661. * - VertexBuffer.MatricesIndicesExtraKind
  20662. * - VertexBuffer.MatricesWeightsKind
  20663. * - VertexBuffer.MatricesWeightsExtraKind
  20664. * @returns a boolean
  20665. */
  20666. isVerticesDataPresent(kind: string): boolean;
  20667. /**
  20668. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20669. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20670. * - VertexBuffer.PositionKind
  20671. * - VertexBuffer.UVKind
  20672. * - VertexBuffer.UV2Kind
  20673. * - VertexBuffer.UV3Kind
  20674. * - VertexBuffer.UV4Kind
  20675. * - VertexBuffer.UV5Kind
  20676. * - VertexBuffer.UV6Kind
  20677. * - VertexBuffer.ColorKind
  20678. * - VertexBuffer.MatricesIndicesKind
  20679. * - VertexBuffer.MatricesIndicesExtraKind
  20680. * - VertexBuffer.MatricesWeightsKind
  20681. * - VertexBuffer.MatricesWeightsExtraKind
  20682. * @returns a boolean
  20683. */
  20684. isVertexBufferUpdatable(kind: string): boolean;
  20685. /**
  20686. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20687. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20688. * - VertexBuffer.PositionKind
  20689. * - VertexBuffer.UVKind
  20690. * - VertexBuffer.UV2Kind
  20691. * - VertexBuffer.UV3Kind
  20692. * - VertexBuffer.UV4Kind
  20693. * - VertexBuffer.UV5Kind
  20694. * - VertexBuffer.UV6Kind
  20695. * - VertexBuffer.ColorKind
  20696. * - VertexBuffer.MatricesIndicesKind
  20697. * - VertexBuffer.MatricesIndicesExtraKind
  20698. * - VertexBuffer.MatricesWeightsKind
  20699. * - VertexBuffer.MatricesWeightsExtraKind
  20700. * @returns an array of strings
  20701. */
  20702. getVerticesDataKinds(): string[];
  20703. /**
  20704. * Returns a positive integer : the total number of indices in this mesh geometry.
  20705. * @returns the numner of indices or zero if the mesh has no geometry.
  20706. */
  20707. getTotalIndices(): number;
  20708. /**
  20709. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20710. * @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.
  20711. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20712. * @returns the indices array or an empty array if the mesh has no geometry
  20713. */
  20714. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20715. readonly isBlocked: boolean;
  20716. /**
  20717. * Determine if the current mesh is ready to be rendered
  20718. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20719. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20720. * @returns true if all associated assets are ready (material, textures, shaders)
  20721. */
  20722. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20723. /**
  20724. * 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.
  20725. */
  20726. readonly areNormalsFrozen: boolean;
  20727. /**
  20728. * 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.
  20729. * @returns the current mesh
  20730. */
  20731. freezeNormals(): Mesh;
  20732. /**
  20733. * 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
  20734. * @returns the current mesh
  20735. */
  20736. unfreezeNormals(): Mesh;
  20737. /**
  20738. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20739. */
  20740. overridenInstanceCount: number;
  20741. /** @hidden */
  20742. _preActivate(): Mesh;
  20743. /** @hidden */
  20744. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20745. /** @hidden */
  20746. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20747. /**
  20748. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20749. * This means the mesh underlying bounding box and sphere are recomputed.
  20750. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20751. * @returns the current mesh
  20752. */
  20753. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20754. /** @hidden */
  20755. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20756. /**
  20757. * This function will subdivide the mesh into multiple submeshes
  20758. * @param count defines the expected number of submeshes
  20759. */
  20760. subdivide(count: number): void;
  20761. /**
  20762. * Copy a FloatArray into a specific associated vertex buffer
  20763. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20764. * - VertexBuffer.PositionKind
  20765. * - VertexBuffer.UVKind
  20766. * - VertexBuffer.UV2Kind
  20767. * - VertexBuffer.UV3Kind
  20768. * - VertexBuffer.UV4Kind
  20769. * - VertexBuffer.UV5Kind
  20770. * - VertexBuffer.UV6Kind
  20771. * - VertexBuffer.ColorKind
  20772. * - VertexBuffer.MatricesIndicesKind
  20773. * - VertexBuffer.MatricesIndicesExtraKind
  20774. * - VertexBuffer.MatricesWeightsKind
  20775. * - VertexBuffer.MatricesWeightsExtraKind
  20776. * @param data defines the data source
  20777. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20778. * @param stride defines the data stride size (can be null)
  20779. * @returns the current mesh
  20780. */
  20781. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20782. /**
  20783. * Flags an associated vertex buffer as updatable
  20784. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20785. * - VertexBuffer.PositionKind
  20786. * - VertexBuffer.UVKind
  20787. * - VertexBuffer.UV2Kind
  20788. * - VertexBuffer.UV3Kind
  20789. * - VertexBuffer.UV4Kind
  20790. * - VertexBuffer.UV5Kind
  20791. * - VertexBuffer.UV6Kind
  20792. * - VertexBuffer.ColorKind
  20793. * - VertexBuffer.MatricesIndicesKind
  20794. * - VertexBuffer.MatricesIndicesExtraKind
  20795. * - VertexBuffer.MatricesWeightsKind
  20796. * - VertexBuffer.MatricesWeightsExtraKind
  20797. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20798. */
  20799. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20800. /**
  20801. * Sets the mesh global Vertex Buffer
  20802. * @param buffer defines the buffer to use
  20803. * @returns the current mesh
  20804. */
  20805. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20806. /**
  20807. * Update a specific associated vertex buffer
  20808. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20809. * - VertexBuffer.PositionKind
  20810. * - VertexBuffer.UVKind
  20811. * - VertexBuffer.UV2Kind
  20812. * - VertexBuffer.UV3Kind
  20813. * - VertexBuffer.UV4Kind
  20814. * - VertexBuffer.UV5Kind
  20815. * - VertexBuffer.UV6Kind
  20816. * - VertexBuffer.ColorKind
  20817. * - VertexBuffer.MatricesIndicesKind
  20818. * - VertexBuffer.MatricesIndicesExtraKind
  20819. * - VertexBuffer.MatricesWeightsKind
  20820. * - VertexBuffer.MatricesWeightsExtraKind
  20821. * @param data defines the data source
  20822. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20823. * @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)
  20824. * @returns the current mesh
  20825. */
  20826. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20827. /**
  20828. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20829. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20830. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20831. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20832. * @returns the current mesh
  20833. */
  20834. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20835. /**
  20836. * Creates a un-shared specific occurence of the geometry for the mesh.
  20837. * @returns the current mesh
  20838. */
  20839. makeGeometryUnique(): Mesh;
  20840. /**
  20841. * Set the index buffer of this mesh
  20842. * @param indices defines the source data
  20843. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20844. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20845. * @returns the current mesh
  20846. */
  20847. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20848. /**
  20849. * Update the current index buffer
  20850. * @param indices defines the source data
  20851. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20852. * @returns the current mesh
  20853. */
  20854. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20855. /**
  20856. * Invert the geometry to move from a right handed system to a left handed one.
  20857. * @returns the current mesh
  20858. */
  20859. toLeftHanded(): Mesh;
  20860. /** @hidden */
  20861. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20862. /** @hidden */
  20863. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20864. /**
  20865. * Registers for this mesh a javascript function called just before the rendering process
  20866. * @param func defines the function to call before rendering this mesh
  20867. * @returns the current mesh
  20868. */
  20869. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20870. /**
  20871. * Disposes a previously registered javascript function called before the rendering
  20872. * @param func defines the function to remove
  20873. * @returns the current mesh
  20874. */
  20875. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20876. /**
  20877. * Registers for this mesh a javascript function called just after the rendering is complete
  20878. * @param func defines the function to call after rendering this mesh
  20879. * @returns the current mesh
  20880. */
  20881. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20882. /**
  20883. * Disposes a previously registered javascript function called after the rendering.
  20884. * @param func defines the function to remove
  20885. * @returns the current mesh
  20886. */
  20887. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20888. /** @hidden */
  20889. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20890. /** @hidden */
  20891. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20892. /** @hidden */
  20893. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20894. /**
  20895. * 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
  20896. * @param subMesh defines the subMesh to render
  20897. * @param enableAlphaMode defines if alpha mode can be changed
  20898. * @returns the current mesh
  20899. */
  20900. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20901. private _onBeforeDraw;
  20902. /**
  20903. * Renormalize the mesh and patch it up if there are no weights
  20904. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20905. * However in the case of zero weights then we set just a single influence to 1.
  20906. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20907. */
  20908. cleanMatrixWeights(): void;
  20909. private normalizeSkinFourWeights;
  20910. private normalizeSkinWeightsAndExtra;
  20911. /**
  20912. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20913. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20914. * the user know there was an issue with importing the mesh
  20915. * @returns a validation object with skinned, valid and report string
  20916. */
  20917. validateSkinning(): {
  20918. skinned: boolean;
  20919. valid: boolean;
  20920. report: string;
  20921. };
  20922. /** @hidden */
  20923. _checkDelayState(): Mesh;
  20924. private _queueLoad;
  20925. /**
  20926. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20927. * A mesh is in the frustum if its bounding box intersects the frustum
  20928. * @param frustumPlanes defines the frustum to test
  20929. * @returns true if the mesh is in the frustum planes
  20930. */
  20931. isInFrustum(frustumPlanes: Plane[]): boolean;
  20932. /**
  20933. * Sets the mesh material by the material or multiMaterial `id` property
  20934. * @param id is a string identifying the material or the multiMaterial
  20935. * @returns the current mesh
  20936. */
  20937. setMaterialByID(id: string): Mesh;
  20938. /**
  20939. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20940. * @returns an array of IAnimatable
  20941. */
  20942. getAnimatables(): IAnimatable[];
  20943. /**
  20944. * Modifies the mesh geometry according to the passed transformation matrix.
  20945. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20946. * The mesh normals are modified using the same transformation.
  20947. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20948. * @param transform defines the transform matrix to use
  20949. * @see http://doc.babylonjs.com/resources/baking_transformations
  20950. * @returns the current mesh
  20951. */
  20952. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20953. /**
  20954. * Modifies the mesh geometry according to its own current World Matrix.
  20955. * The mesh World Matrix is then reset.
  20956. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20957. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20958. * @see http://doc.babylonjs.com/resources/baking_transformations
  20959. * @returns the current mesh
  20960. */
  20961. bakeCurrentTransformIntoVertices(): Mesh;
  20962. /** @hidden */
  20963. readonly _positions: Nullable<Vector3[]>;
  20964. /** @hidden */
  20965. _resetPointsArrayCache(): Mesh;
  20966. /** @hidden */
  20967. _generatePointsArray(): boolean;
  20968. /**
  20969. * Returns a new Mesh object generated from the current mesh properties.
  20970. * This method must not get confused with createInstance()
  20971. * @param name is a string, the name given to the new mesh
  20972. * @param newParent can be any Node object (default `null`)
  20973. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20974. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20975. * @returns a new mesh
  20976. */
  20977. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20978. /**
  20979. * Releases resources associated with this mesh.
  20980. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20981. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20982. */
  20983. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20984. /**
  20985. * Modifies the mesh geometry according to a displacement map.
  20986. * 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.
  20987. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20988. * @param url is a string, the URL from the image file is to be downloaded.
  20989. * @param minHeight is the lower limit of the displacement.
  20990. * @param maxHeight is the upper limit of the displacement.
  20991. * @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.
  20992. * @param uvOffset is an optional vector2 used to offset UV.
  20993. * @param uvScale is an optional vector2 used to scale UV.
  20994. * @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.
  20995. * @returns the Mesh.
  20996. */
  20997. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20998. /**
  20999. * Modifies the mesh geometry according to a displacementMap buffer.
  21000. * 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.
  21001. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21002. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21003. * @param heightMapWidth is the width of the buffer image.
  21004. * @param heightMapHeight is the height of the buffer image.
  21005. * @param minHeight is the lower limit of the displacement.
  21006. * @param maxHeight is the upper limit of the displacement.
  21007. * @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.
  21008. * @param uvOffset is an optional vector2 used to offset UV.
  21009. * @param uvScale is an optional vector2 used to scale UV.
  21010. * @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.
  21011. * @returns the Mesh.
  21012. */
  21013. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21014. /**
  21015. * Modify the mesh to get a flat shading rendering.
  21016. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21017. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21018. * @returns current mesh
  21019. */
  21020. convertToFlatShadedMesh(): Mesh;
  21021. /**
  21022. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21023. * In other words, more vertices, no more indices and a single bigger VBO.
  21024. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21025. * @returns current mesh
  21026. */
  21027. convertToUnIndexedMesh(): Mesh;
  21028. /**
  21029. * Inverses facet orientations.
  21030. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21031. * @param flipNormals will also inverts the normals
  21032. * @returns current mesh
  21033. */
  21034. flipFaces(flipNormals?: boolean): Mesh;
  21035. /** @hidden */
  21036. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21037. /** @hidden */
  21038. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21039. /**
  21040. * Creates a new InstancedMesh object from the mesh model.
  21041. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21042. * @param name defines the name of the new instance
  21043. * @returns a new InstancedMesh
  21044. */
  21045. createInstance(name: string): InstancedMesh;
  21046. /**
  21047. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21048. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21049. * @returns the current mesh
  21050. */
  21051. synchronizeInstances(): Mesh;
  21052. /**
  21053. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21054. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21055. * This should be used together with the simplification to avoid disappearing triangles.
  21056. * @param successCallback an optional success callback to be called after the optimization finished.
  21057. * @returns the current mesh
  21058. */
  21059. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21060. /**
  21061. * Serialize current mesh
  21062. * @param serializationObject defines the object which will receive the serialization data
  21063. */
  21064. serialize(serializationObject: any): void;
  21065. /** @hidden */
  21066. _syncGeometryWithMorphTargetManager(): void;
  21067. /** @hidden */
  21068. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21069. /**
  21070. * Returns a new Mesh object parsed from the source provided.
  21071. * @param parsedMesh is the source
  21072. * @param scene defines the hosting scene
  21073. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21074. * @returns a new Mesh
  21075. */
  21076. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21077. /**
  21078. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21079. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21080. * @param name defines the name of the mesh to create
  21081. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21082. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21083. * @param closePath creates a seam between the first and the last points of each path of the path array
  21084. * @param offset is taken in account only if the `pathArray` is containing a single path
  21085. * @param scene defines the hosting scene
  21086. * @param updatable defines if the mesh must be flagged as updatable
  21087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21088. * @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)
  21089. * @returns a new Mesh
  21090. */
  21091. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21092. /**
  21093. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21094. * @param name defines the name of the mesh to create
  21095. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21096. * @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
  21097. * @param scene defines the hosting scene
  21098. * @param updatable defines if the mesh must be flagged as updatable
  21099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21100. * @returns a new Mesh
  21101. */
  21102. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21103. /**
  21104. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21105. * @param name defines the name of the mesh to create
  21106. * @param size sets the size (float) of each box side (default 1)
  21107. * @param scene defines the hosting scene
  21108. * @param updatable defines if the mesh must be flagged as updatable
  21109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21110. * @returns a new Mesh
  21111. */
  21112. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21113. /**
  21114. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21115. * @param name defines the name of the mesh to create
  21116. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21117. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21118. * @param scene defines the hosting scene
  21119. * @param updatable defines if the mesh must be flagged as updatable
  21120. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21121. * @returns a new Mesh
  21122. */
  21123. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21124. /**
  21125. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21126. * @param name defines the name of the mesh to create
  21127. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21128. * @param diameterTop set the top cap diameter (floats, default 1)
  21129. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21130. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21131. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21132. * @param scene defines the hosting scene
  21133. * @param updatable defines if the mesh must be flagged as updatable
  21134. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21135. * @returns a new Mesh
  21136. */
  21137. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21138. /**
  21139. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21140. * @param name defines the name of the mesh to create
  21141. * @param diameter sets the diameter size (float) of the torus (default 1)
  21142. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21143. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21144. * @param scene defines the hosting scene
  21145. * @param updatable defines if the mesh must be flagged as updatable
  21146. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21147. * @returns a new Mesh
  21148. */
  21149. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21150. /**
  21151. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21152. * @param name defines the name of the mesh to create
  21153. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21154. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21155. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21156. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21157. * @param p the number of windings on X axis (positive integers, default 2)
  21158. * @param q the number of windings on Y axis (positive integers, default 3)
  21159. * @param scene defines the hosting scene
  21160. * @param updatable defines if the mesh must be flagged as updatable
  21161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21162. * @returns a new Mesh
  21163. */
  21164. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21165. /**
  21166. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21167. * @param name defines the name of the mesh to create
  21168. * @param points is an array successive Vector3
  21169. * @param scene defines the hosting scene
  21170. * @param updatable defines if the mesh must be flagged as updatable
  21171. * @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).
  21172. * @returns a new Mesh
  21173. */
  21174. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21175. /**
  21176. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21177. * @param name defines the name of the mesh to create
  21178. * @param points is an array successive Vector3
  21179. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21180. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21181. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21182. * @param scene defines the hosting scene
  21183. * @param updatable defines if the mesh must be flagged as updatable
  21184. * @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)
  21185. * @returns a new Mesh
  21186. */
  21187. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21188. /**
  21189. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21190. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21191. * 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.
  21192. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21193. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21194. * Remember you can only change the shape positions, not their number when updating a polygon.
  21195. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21196. * @param name defines the name of the mesh to create
  21197. * @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
  21198. * @param scene defines the hosting scene
  21199. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21200. * @param updatable defines if the mesh must be flagged as updatable
  21201. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21202. * @param earcutInjection can be used to inject your own earcut reference
  21203. * @returns a new Mesh
  21204. */
  21205. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21206. /**
  21207. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21208. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21209. * @param name defines the name of the mesh to create
  21210. * @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
  21211. * @param depth defines the height of extrusion
  21212. * @param scene defines the hosting scene
  21213. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21214. * @param updatable defines if the mesh must be flagged as updatable
  21215. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21216. * @param earcutInjection can be used to inject your own earcut reference
  21217. * @returns a new Mesh
  21218. */
  21219. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21220. /**
  21221. * Creates an extruded shape mesh.
  21222. * 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
  21223. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21224. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21225. * @param name defines the name of the mesh to create
  21226. * @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
  21227. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21228. * @param scale is the value to scale the shape
  21229. * @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
  21230. * @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
  21231. * @param scene defines the hosting scene
  21232. * @param updatable defines if the mesh must be flagged as updatable
  21233. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21234. * @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)
  21235. * @returns a new Mesh
  21236. */
  21237. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21238. /**
  21239. * Creates an custom extruded shape mesh.
  21240. * The custom extrusion is a parametric shape.
  21241. * It has no predefined shape. Its final shape will depend on the input parameters.
  21242. * Please consider using the same method from the MeshBuilder class instead
  21243. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21244. * @param name defines the name of the mesh to create
  21245. * @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
  21246. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21247. * @param scaleFunction is a custom Javascript function called on each path point
  21248. * @param rotationFunction is a custom Javascript function called on each path point
  21249. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21250. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21251. * @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
  21252. * @param scene defines the hosting scene
  21253. * @param updatable defines if the mesh must be flagged as updatable
  21254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21255. * @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)
  21256. * @returns a new Mesh
  21257. */
  21258. 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;
  21259. /**
  21260. * Creates lathe mesh.
  21261. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21262. * Please consider using the same method from the MeshBuilder class instead
  21263. * @param name defines the name of the mesh to create
  21264. * @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
  21265. * @param radius is the radius value of the lathe
  21266. * @param tessellation is the side number of the lathe.
  21267. * @param scene defines the hosting scene
  21268. * @param updatable defines if the mesh must be flagged as updatable
  21269. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21270. * @returns a new Mesh
  21271. */
  21272. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21273. /**
  21274. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21275. * @param name defines the name of the mesh to create
  21276. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21277. * @param scene defines the hosting scene
  21278. * @param updatable defines if the mesh must be flagged as updatable
  21279. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21280. * @returns a new Mesh
  21281. */
  21282. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21283. /**
  21284. * Creates a ground mesh.
  21285. * Please consider using the same method from the MeshBuilder class instead
  21286. * @param name defines the name of the mesh to create
  21287. * @param width set the width of the ground
  21288. * @param height set the height of the ground
  21289. * @param subdivisions sets the number of subdivisions per side
  21290. * @param scene defines the hosting scene
  21291. * @param updatable defines if the mesh must be flagged as updatable
  21292. * @returns a new Mesh
  21293. */
  21294. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21295. /**
  21296. * Creates a tiled ground mesh.
  21297. * Please consider using the same method from the MeshBuilder class instead
  21298. * @param name defines the name of the mesh to create
  21299. * @param xmin set the ground minimum X coordinate
  21300. * @param zmin set the ground minimum Y coordinate
  21301. * @param xmax set the ground maximum X coordinate
  21302. * @param zmax set the ground maximum Z coordinate
  21303. * @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
  21304. * @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
  21305. * @param scene defines the hosting scene
  21306. * @param updatable defines if the mesh must be flagged as updatable
  21307. * @returns a new Mesh
  21308. */
  21309. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21310. w: number;
  21311. h: number;
  21312. }, precision: {
  21313. w: number;
  21314. h: number;
  21315. }, scene: Scene, updatable?: boolean): Mesh;
  21316. /**
  21317. * Creates a ground mesh from a height map.
  21318. * Please consider using the same method from the MeshBuilder class instead
  21319. * @see http://doc.babylonjs.com/babylon101/height_map
  21320. * @param name defines the name of the mesh to create
  21321. * @param url sets the URL of the height map image resource
  21322. * @param width set the ground width size
  21323. * @param height set the ground height size
  21324. * @param subdivisions sets the number of subdivision per side
  21325. * @param minHeight is the minimum altitude on the ground
  21326. * @param maxHeight is the maximum altitude on the ground
  21327. * @param scene defines the hosting scene
  21328. * @param updatable defines if the mesh must be flagged as updatable
  21329. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21330. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21331. * @returns a new Mesh
  21332. */
  21333. 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;
  21334. /**
  21335. * Creates a tube mesh.
  21336. * The tube is a parametric shape.
  21337. * It has no predefined shape. Its final shape will depend on the input parameters.
  21338. * Please consider using the same method from the MeshBuilder class instead
  21339. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21340. * @param name defines the name of the mesh to create
  21341. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21342. * @param radius sets the tube radius size
  21343. * @param tessellation is the number of sides on the tubular surface
  21344. * @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
  21345. * @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
  21346. * @param scene defines the hosting scene
  21347. * @param updatable defines if the mesh must be flagged as updatable
  21348. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21349. * @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)
  21350. * @returns a new Mesh
  21351. */
  21352. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21353. (i: number, distance: number): number;
  21354. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21355. /**
  21356. * Creates a polyhedron mesh.
  21357. * Please consider using the same method from the MeshBuilder class instead.
  21358. * * 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
  21359. * * The parameter `size` (positive float, default 1) sets the polygon size
  21360. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21361. * * 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`
  21362. * * 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
  21363. * * 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)`)
  21364. * * 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
  21365. * * 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
  21366. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21367. * * If you create a double-sided mesh, you can choose what parts of 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
  21368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21369. * @param name defines the name of the mesh to create
  21370. * @param options defines the options used to create the mesh
  21371. * @param scene defines the hosting scene
  21372. * @returns a new Mesh
  21373. */
  21374. static CreatePolyhedron(name: string, options: {
  21375. type?: number;
  21376. size?: number;
  21377. sizeX?: number;
  21378. sizeY?: number;
  21379. sizeZ?: number;
  21380. custom?: any;
  21381. faceUV?: Vector4[];
  21382. faceColors?: Color4[];
  21383. updatable?: boolean;
  21384. sideOrientation?: number;
  21385. }, scene: Scene): Mesh;
  21386. /**
  21387. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21388. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21389. * * 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`)
  21390. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21391. * * 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
  21392. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21393. * * If you create a double-sided mesh, you can choose what parts of 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
  21394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21395. * @param name defines the name of the mesh
  21396. * @param options defines the options used to create the mesh
  21397. * @param scene defines the hosting scene
  21398. * @returns a new Mesh
  21399. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21400. */
  21401. static CreateIcoSphere(name: string, options: {
  21402. radius?: number;
  21403. flat?: boolean;
  21404. subdivisions?: number;
  21405. sideOrientation?: number;
  21406. updatable?: boolean;
  21407. }, scene: Scene): Mesh;
  21408. /**
  21409. * Creates a decal mesh.
  21410. * Please consider using the same method from the MeshBuilder class instead.
  21411. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21412. * @param name defines the name of the mesh
  21413. * @param sourceMesh defines the mesh receiving the decal
  21414. * @param position sets the position of the decal in world coordinates
  21415. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21416. * @param size sets the decal scaling
  21417. * @param angle sets the angle to rotate the decal
  21418. * @returns a new Mesh
  21419. */
  21420. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21421. /**
  21422. * Prepare internal position array for software CPU skinning
  21423. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21424. */
  21425. setPositionsForCPUSkinning(): Float32Array;
  21426. /**
  21427. * Prepare internal normal array for software CPU skinning
  21428. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21429. */
  21430. setNormalsForCPUSkinning(): Float32Array;
  21431. /**
  21432. * Updates the vertex buffer by applying transformation from the bones
  21433. * @param skeleton defines the skeleton to apply to current mesh
  21434. * @returns the current mesh
  21435. */
  21436. applySkeleton(skeleton: Skeleton): Mesh;
  21437. /**
  21438. * 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
  21439. * @param meshes defines the list of meshes to scan
  21440. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21441. */
  21442. static MinMax(meshes: AbstractMesh[]): {
  21443. min: Vector3;
  21444. max: Vector3;
  21445. };
  21446. /**
  21447. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21448. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21449. * @returns a vector3
  21450. */
  21451. static Center(meshesOrMinMaxVector: {
  21452. min: Vector3;
  21453. max: Vector3;
  21454. } | AbstractMesh[]): Vector3;
  21455. /**
  21456. * Merge the array of meshes into a single mesh for performance reasons.
  21457. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21458. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21459. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21460. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21461. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21462. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21463. * @returns a new mesh
  21464. */
  21465. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21466. /** @hidden */
  21467. addInstance(instance: InstancedMesh): void;
  21468. /** @hidden */
  21469. removeInstance(instance: InstancedMesh): void;
  21470. }
  21471. }
  21472. declare module "babylonjs/Materials/material" {
  21473. import { IAnimatable } from "babylonjs/Misc/tools";
  21474. import { SmartArray } from "babylonjs/Misc/smartArray";
  21475. import { Observable } from "babylonjs/Misc/observable";
  21476. import { Nullable } from "babylonjs/types";
  21477. import { Scene } from "babylonjs/scene";
  21478. import { Matrix } from "babylonjs/Maths/math";
  21479. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21481. import { Mesh } from "babylonjs/Meshes/mesh";
  21482. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21483. import { Effect } from "babylonjs/Materials/effect";
  21484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21485. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21486. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21487. import { Animation } from "babylonjs/Animations/animation";
  21488. /**
  21489. * Base class for the main features of a material in Babylon.js
  21490. */
  21491. export class Material implements IAnimatable {
  21492. /**
  21493. * Returns the triangle fill mode
  21494. */
  21495. static readonly TriangleFillMode: number;
  21496. /**
  21497. * Returns the wireframe mode
  21498. */
  21499. static readonly WireFrameFillMode: number;
  21500. /**
  21501. * Returns the point fill mode
  21502. */
  21503. static readonly PointFillMode: number;
  21504. /**
  21505. * Returns the point list draw mode
  21506. */
  21507. static readonly PointListDrawMode: number;
  21508. /**
  21509. * Returns the line list draw mode
  21510. */
  21511. static readonly LineListDrawMode: number;
  21512. /**
  21513. * Returns the line loop draw mode
  21514. */
  21515. static readonly LineLoopDrawMode: number;
  21516. /**
  21517. * Returns the line strip draw mode
  21518. */
  21519. static readonly LineStripDrawMode: number;
  21520. /**
  21521. * Returns the triangle strip draw mode
  21522. */
  21523. static readonly TriangleStripDrawMode: number;
  21524. /**
  21525. * Returns the triangle fan draw mode
  21526. */
  21527. static readonly TriangleFanDrawMode: number;
  21528. /**
  21529. * Stores the clock-wise side orientation
  21530. */
  21531. static readonly ClockWiseSideOrientation: number;
  21532. /**
  21533. * Stores the counter clock-wise side orientation
  21534. */
  21535. static readonly CounterClockWiseSideOrientation: number;
  21536. /**
  21537. * The dirty texture flag value
  21538. */
  21539. static readonly TextureDirtyFlag: number;
  21540. /**
  21541. * The dirty light flag value
  21542. */
  21543. static readonly LightDirtyFlag: number;
  21544. /**
  21545. * The dirty fresnel flag value
  21546. */
  21547. static readonly FresnelDirtyFlag: number;
  21548. /**
  21549. * The dirty attribute flag value
  21550. */
  21551. static readonly AttributesDirtyFlag: number;
  21552. /**
  21553. * The dirty misc flag value
  21554. */
  21555. static readonly MiscDirtyFlag: number;
  21556. /**
  21557. * The all dirty flag value
  21558. */
  21559. static readonly AllDirtyFlag: number;
  21560. /**
  21561. * The ID of the material
  21562. */
  21563. id: string;
  21564. /**
  21565. * Gets or sets the unique id of the material
  21566. */
  21567. uniqueId: number;
  21568. /**
  21569. * The name of the material
  21570. */
  21571. name: string;
  21572. /**
  21573. * Gets or sets user defined metadata
  21574. */
  21575. metadata: any;
  21576. /**
  21577. * For internal use only. Please do not use.
  21578. */
  21579. reservedDataStore: any;
  21580. /**
  21581. * Specifies if the ready state should be checked on each call
  21582. */
  21583. checkReadyOnEveryCall: boolean;
  21584. /**
  21585. * Specifies if the ready state should be checked once
  21586. */
  21587. checkReadyOnlyOnce: boolean;
  21588. /**
  21589. * The state of the material
  21590. */
  21591. state: string;
  21592. /**
  21593. * The alpha value of the material
  21594. */
  21595. protected _alpha: number;
  21596. /**
  21597. * Sets the alpha value of the material
  21598. */
  21599. /**
  21600. * Gets the alpha value of the material
  21601. */
  21602. alpha: number;
  21603. /**
  21604. * Specifies if back face culling is enabled
  21605. */
  21606. protected _backFaceCulling: boolean;
  21607. /**
  21608. * Sets the back-face culling state
  21609. */
  21610. /**
  21611. * Gets the back-face culling state
  21612. */
  21613. backFaceCulling: boolean;
  21614. /**
  21615. * Stores the value for side orientation
  21616. */
  21617. sideOrientation: number;
  21618. /**
  21619. * Callback triggered when the material is compiled
  21620. */
  21621. onCompiled: (effect: Effect) => void;
  21622. /**
  21623. * Callback triggered when an error occurs
  21624. */
  21625. onError: (effect: Effect, errors: string) => void;
  21626. /**
  21627. * Callback triggered to get the render target textures
  21628. */
  21629. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21630. /**
  21631. * Gets a boolean indicating that current material needs to register RTT
  21632. */
  21633. readonly hasRenderTargetTextures: boolean;
  21634. /**
  21635. * Specifies if the material should be serialized
  21636. */
  21637. doNotSerialize: boolean;
  21638. /**
  21639. * @hidden
  21640. */
  21641. _storeEffectOnSubMeshes: boolean;
  21642. /**
  21643. * Stores the animations for the material
  21644. */
  21645. animations: Array<Animation>;
  21646. /**
  21647. * An event triggered when the material is disposed
  21648. */
  21649. onDisposeObservable: Observable<Material>;
  21650. /**
  21651. * An observer which watches for dispose events
  21652. */
  21653. private _onDisposeObserver;
  21654. private _onUnBindObservable;
  21655. /**
  21656. * Called during a dispose event
  21657. */
  21658. onDispose: () => void;
  21659. private _onBindObservable;
  21660. /**
  21661. * An event triggered when the material is bound
  21662. */
  21663. readonly onBindObservable: Observable<AbstractMesh>;
  21664. /**
  21665. * An observer which watches for bind events
  21666. */
  21667. private _onBindObserver;
  21668. /**
  21669. * Called during a bind event
  21670. */
  21671. onBind: (Mesh: AbstractMesh) => void;
  21672. /**
  21673. * An event triggered when the material is unbound
  21674. */
  21675. readonly onUnBindObservable: Observable<Material>;
  21676. /**
  21677. * Stores the value of the alpha mode
  21678. */
  21679. private _alphaMode;
  21680. /**
  21681. * Sets the value of the alpha mode.
  21682. *
  21683. * | Value | Type | Description |
  21684. * | --- | --- | --- |
  21685. * | 0 | ALPHA_DISABLE | |
  21686. * | 1 | ALPHA_ADD | |
  21687. * | 2 | ALPHA_COMBINE | |
  21688. * | 3 | ALPHA_SUBTRACT | |
  21689. * | 4 | ALPHA_MULTIPLY | |
  21690. * | 5 | ALPHA_MAXIMIZED | |
  21691. * | 6 | ALPHA_ONEONE | |
  21692. * | 7 | ALPHA_PREMULTIPLIED | |
  21693. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21694. * | 9 | ALPHA_INTERPOLATE | |
  21695. * | 10 | ALPHA_SCREENMODE | |
  21696. *
  21697. */
  21698. /**
  21699. * Gets the value of the alpha mode
  21700. */
  21701. alphaMode: number;
  21702. /**
  21703. * Stores the state of the need depth pre-pass value
  21704. */
  21705. private _needDepthPrePass;
  21706. /**
  21707. * Sets the need depth pre-pass value
  21708. */
  21709. /**
  21710. * Gets the depth pre-pass value
  21711. */
  21712. needDepthPrePass: boolean;
  21713. /**
  21714. * Specifies if depth writing should be disabled
  21715. */
  21716. disableDepthWrite: boolean;
  21717. /**
  21718. * Specifies if depth writing should be forced
  21719. */
  21720. forceDepthWrite: boolean;
  21721. /**
  21722. * Specifies if there should be a separate pass for culling
  21723. */
  21724. separateCullingPass: boolean;
  21725. /**
  21726. * Stores the state specifing if fog should be enabled
  21727. */
  21728. private _fogEnabled;
  21729. /**
  21730. * Sets the state for enabling fog
  21731. */
  21732. /**
  21733. * Gets the value of the fog enabled state
  21734. */
  21735. fogEnabled: boolean;
  21736. /**
  21737. * Stores the size of points
  21738. */
  21739. pointSize: number;
  21740. /**
  21741. * Stores the z offset value
  21742. */
  21743. zOffset: number;
  21744. /**
  21745. * Gets a value specifying if wireframe mode is enabled
  21746. */
  21747. /**
  21748. * Sets the state of wireframe mode
  21749. */
  21750. wireframe: boolean;
  21751. /**
  21752. * Gets the value specifying if point clouds are enabled
  21753. */
  21754. /**
  21755. * Sets the state of point cloud mode
  21756. */
  21757. pointsCloud: boolean;
  21758. /**
  21759. * Gets the material fill mode
  21760. */
  21761. /**
  21762. * Sets the material fill mode
  21763. */
  21764. fillMode: number;
  21765. /**
  21766. * @hidden
  21767. * Stores the effects for the material
  21768. */
  21769. _effect: Nullable<Effect>;
  21770. /**
  21771. * @hidden
  21772. * Specifies if the material was previously ready
  21773. */
  21774. _wasPreviouslyReady: boolean;
  21775. /**
  21776. * Specifies if uniform buffers should be used
  21777. */
  21778. private _useUBO;
  21779. /**
  21780. * Stores a reference to the scene
  21781. */
  21782. private _scene;
  21783. /**
  21784. * Stores the fill mode state
  21785. */
  21786. private _fillMode;
  21787. /**
  21788. * Specifies if the depth write state should be cached
  21789. */
  21790. private _cachedDepthWriteState;
  21791. /**
  21792. * Stores the uniform buffer
  21793. */
  21794. protected _uniformBuffer: UniformBuffer;
  21795. /** @hidden */
  21796. _indexInSceneMaterialArray: number;
  21797. /** @hidden */
  21798. meshMap: Nullable<{
  21799. [id: string]: AbstractMesh | undefined;
  21800. }>;
  21801. /**
  21802. * Creates a material instance
  21803. * @param name defines the name of the material
  21804. * @param scene defines the scene to reference
  21805. * @param doNotAdd specifies if the material should be added to the scene
  21806. */
  21807. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21808. /**
  21809. * Returns a string representation of the current material
  21810. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21811. * @returns a string with material information
  21812. */
  21813. toString(fullDetails?: boolean): string;
  21814. /**
  21815. * Gets the class name of the material
  21816. * @returns a string with the class name of the material
  21817. */
  21818. getClassName(): string;
  21819. /**
  21820. * Specifies if updates for the material been locked
  21821. */
  21822. readonly isFrozen: boolean;
  21823. /**
  21824. * Locks updates for the material
  21825. */
  21826. freeze(): void;
  21827. /**
  21828. * Unlocks updates for the material
  21829. */
  21830. unfreeze(): void;
  21831. /**
  21832. * Specifies if the material is ready to be used
  21833. * @param mesh defines the mesh to check
  21834. * @param useInstances specifies if instances should be used
  21835. * @returns a boolean indicating if the material is ready to be used
  21836. */
  21837. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21838. /**
  21839. * Specifies that the submesh is ready to be used
  21840. * @param mesh defines the mesh to check
  21841. * @param subMesh defines which submesh to check
  21842. * @param useInstances specifies that instances should be used
  21843. * @returns a boolean indicating that the submesh is ready or not
  21844. */
  21845. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21846. /**
  21847. * Returns the material effect
  21848. * @returns the effect associated with the material
  21849. */
  21850. getEffect(): Nullable<Effect>;
  21851. /**
  21852. * Returns the current scene
  21853. * @returns a Scene
  21854. */
  21855. getScene(): Scene;
  21856. /**
  21857. * Specifies if the material will require alpha blending
  21858. * @returns a boolean specifying if alpha blending is needed
  21859. */
  21860. needAlphaBlending(): boolean;
  21861. /**
  21862. * Specifies if the mesh will require alpha blending
  21863. * @param mesh defines the mesh to check
  21864. * @returns a boolean specifying if alpha blending is needed for the mesh
  21865. */
  21866. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21867. /**
  21868. * Specifies if this material should be rendered in alpha test mode
  21869. * @returns a boolean specifying if an alpha test is needed.
  21870. */
  21871. needAlphaTesting(): boolean;
  21872. /**
  21873. * Gets the texture used for the alpha test
  21874. * @returns the texture to use for alpha testing
  21875. */
  21876. getAlphaTestTexture(): Nullable<BaseTexture>;
  21877. /**
  21878. * Marks the material to indicate that it needs to be re-calculated
  21879. */
  21880. markDirty(): void;
  21881. /** @hidden */
  21882. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21883. /**
  21884. * Binds the material to the mesh
  21885. * @param world defines the world transformation matrix
  21886. * @param mesh defines the mesh to bind the material to
  21887. */
  21888. bind(world: Matrix, mesh?: Mesh): void;
  21889. /**
  21890. * Binds the submesh to the material
  21891. * @param world defines the world transformation matrix
  21892. * @param mesh defines the mesh containing the submesh
  21893. * @param subMesh defines the submesh to bind the material to
  21894. */
  21895. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21896. /**
  21897. * Binds the world matrix to the material
  21898. * @param world defines the world transformation matrix
  21899. */
  21900. bindOnlyWorldMatrix(world: Matrix): void;
  21901. /**
  21902. * Binds the scene's uniform buffer to the effect.
  21903. * @param effect defines the effect to bind to the scene uniform buffer
  21904. * @param sceneUbo defines the uniform buffer storing scene data
  21905. */
  21906. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21907. /**
  21908. * Binds the view matrix to the effect
  21909. * @param effect defines the effect to bind the view matrix to
  21910. */
  21911. bindView(effect: Effect): void;
  21912. /**
  21913. * Binds the view projection matrix to the effect
  21914. * @param effect defines the effect to bind the view projection matrix to
  21915. */
  21916. bindViewProjection(effect: Effect): void;
  21917. /**
  21918. * Specifies if material alpha testing should be turned on for the mesh
  21919. * @param mesh defines the mesh to check
  21920. */
  21921. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21922. /**
  21923. * Processes to execute after binding the material to a mesh
  21924. * @param mesh defines the rendered mesh
  21925. */
  21926. protected _afterBind(mesh?: Mesh): void;
  21927. /**
  21928. * Unbinds the material from the mesh
  21929. */
  21930. unbind(): void;
  21931. /**
  21932. * Gets the active textures from the material
  21933. * @returns an array of textures
  21934. */
  21935. getActiveTextures(): BaseTexture[];
  21936. /**
  21937. * Specifies if the material uses a texture
  21938. * @param texture defines the texture to check against the material
  21939. * @returns a boolean specifying if the material uses the texture
  21940. */
  21941. hasTexture(texture: BaseTexture): boolean;
  21942. /**
  21943. * Makes a duplicate of the material, and gives it a new name
  21944. * @param name defines the new name for the duplicated material
  21945. * @returns the cloned material
  21946. */
  21947. clone(name: string): Nullable<Material>;
  21948. /**
  21949. * Gets the meshes bound to the material
  21950. * @returns an array of meshes bound to the material
  21951. */
  21952. getBindedMeshes(): AbstractMesh[];
  21953. /**
  21954. * Force shader compilation
  21955. * @param mesh defines the mesh associated with this material
  21956. * @param onCompiled defines a function to execute once the material is compiled
  21957. * @param options defines the options to configure the compilation
  21958. */
  21959. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21960. clipPlane: boolean;
  21961. }>): void;
  21962. /**
  21963. * Force shader compilation
  21964. * @param mesh defines the mesh that will use this material
  21965. * @param options defines additional options for compiling the shaders
  21966. * @returns a promise that resolves when the compilation completes
  21967. */
  21968. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21969. clipPlane: boolean;
  21970. }>): Promise<void>;
  21971. private static readonly _ImageProcessingDirtyCallBack;
  21972. private static readonly _TextureDirtyCallBack;
  21973. private static readonly _FresnelDirtyCallBack;
  21974. private static readonly _MiscDirtyCallBack;
  21975. private static readonly _LightsDirtyCallBack;
  21976. private static readonly _AttributeDirtyCallBack;
  21977. private static _FresnelAndMiscDirtyCallBack;
  21978. private static _TextureAndMiscDirtyCallBack;
  21979. private static readonly _DirtyCallbackArray;
  21980. private static readonly _RunDirtyCallBacks;
  21981. /**
  21982. * Marks a define in the material to indicate that it needs to be re-computed
  21983. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21984. */
  21985. markAsDirty(flag: number): void;
  21986. /**
  21987. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21988. * @param func defines a function which checks material defines against the submeshes
  21989. */
  21990. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21991. /**
  21992. * Indicates that image processing needs to be re-calculated for all submeshes
  21993. */
  21994. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21995. /**
  21996. * Indicates that textures need to be re-calculated for all submeshes
  21997. */
  21998. protected _markAllSubMeshesAsTexturesDirty(): void;
  21999. /**
  22000. * Indicates that fresnel needs to be re-calculated for all submeshes
  22001. */
  22002. protected _markAllSubMeshesAsFresnelDirty(): void;
  22003. /**
  22004. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22005. */
  22006. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22007. /**
  22008. * Indicates that lights need to be re-calculated for all submeshes
  22009. */
  22010. protected _markAllSubMeshesAsLightsDirty(): void;
  22011. /**
  22012. * Indicates that attributes need to be re-calculated for all submeshes
  22013. */
  22014. protected _markAllSubMeshesAsAttributesDirty(): void;
  22015. /**
  22016. * Indicates that misc needs to be re-calculated for all submeshes
  22017. */
  22018. protected _markAllSubMeshesAsMiscDirty(): void;
  22019. /**
  22020. * Indicates that textures and misc need to be re-calculated for all submeshes
  22021. */
  22022. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22023. /**
  22024. * Disposes the material
  22025. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22026. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22027. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22028. */
  22029. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22030. /** @hidden */
  22031. private releaseVertexArrayObject;
  22032. /**
  22033. * Serializes this material
  22034. * @returns the serialized material object
  22035. */
  22036. serialize(): any;
  22037. /**
  22038. * Creates a material from parsed material data
  22039. * @param parsedMaterial defines parsed material data
  22040. * @param scene defines the hosting scene
  22041. * @param rootUrl defines the root URL to use to load textures
  22042. * @returns a new material
  22043. */
  22044. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22045. }
  22046. }
  22047. declare module "babylonjs/Meshes/subMesh" {
  22048. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22049. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22050. import { Engine } from "babylonjs/Engines/engine";
  22051. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22052. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22053. import { Effect } from "babylonjs/Materials/effect";
  22054. import { Collider } from "babylonjs/Collisions/collider";
  22055. import { Material } from "babylonjs/Materials/material";
  22056. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22058. import { Mesh } from "babylonjs/Meshes/mesh";
  22059. import { Ray } from "babylonjs/Culling/ray";
  22060. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22061. /**
  22062. * Base class for submeshes
  22063. */
  22064. export class BaseSubMesh {
  22065. /** @hidden */
  22066. _materialDefines: Nullable<MaterialDefines>;
  22067. /** @hidden */
  22068. _materialEffect: Nullable<Effect>;
  22069. /**
  22070. * Gets associated effect
  22071. */
  22072. readonly effect: Nullable<Effect>;
  22073. /**
  22074. * Sets associated effect (effect used to render this submesh)
  22075. * @param effect defines the effect to associate with
  22076. * @param defines defines the set of defines used to compile this effect
  22077. */
  22078. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22079. }
  22080. /**
  22081. * Defines a subdivision inside a mesh
  22082. */
  22083. export class SubMesh extends BaseSubMesh implements ICullable {
  22084. /** the material index to use */
  22085. materialIndex: number;
  22086. /** vertex index start */
  22087. verticesStart: number;
  22088. /** vertices count */
  22089. verticesCount: number;
  22090. /** index start */
  22091. indexStart: number;
  22092. /** indices count */
  22093. indexCount: number;
  22094. /** @hidden */
  22095. _linesIndexCount: number;
  22096. private _mesh;
  22097. private _renderingMesh;
  22098. private _boundingInfo;
  22099. private _linesIndexBuffer;
  22100. /** @hidden */
  22101. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22102. /** @hidden */
  22103. _trianglePlanes: Plane[];
  22104. /** @hidden */
  22105. _lastColliderTransformMatrix: Matrix;
  22106. /** @hidden */
  22107. _renderId: number;
  22108. /** @hidden */
  22109. _alphaIndex: number;
  22110. /** @hidden */
  22111. _distanceToCamera: number;
  22112. /** @hidden */
  22113. _id: number;
  22114. private _currentMaterial;
  22115. /**
  22116. * Add a new submesh to a mesh
  22117. * @param materialIndex defines the material index to use
  22118. * @param verticesStart defines vertex index start
  22119. * @param verticesCount defines vertices count
  22120. * @param indexStart defines index start
  22121. * @param indexCount defines indices count
  22122. * @param mesh defines the parent mesh
  22123. * @param renderingMesh defines an optional rendering mesh
  22124. * @param createBoundingBox defines if bounding box should be created for this submesh
  22125. * @returns the new submesh
  22126. */
  22127. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22128. /**
  22129. * Creates a new submesh
  22130. * @param materialIndex defines the material index to use
  22131. * @param verticesStart defines vertex index start
  22132. * @param verticesCount defines vertices count
  22133. * @param indexStart defines index start
  22134. * @param indexCount defines indices count
  22135. * @param mesh defines the parent mesh
  22136. * @param renderingMesh defines an optional rendering mesh
  22137. * @param createBoundingBox defines if bounding box should be created for this submesh
  22138. */
  22139. constructor(
  22140. /** the material index to use */
  22141. materialIndex: number,
  22142. /** vertex index start */
  22143. verticesStart: number,
  22144. /** vertices count */
  22145. verticesCount: number,
  22146. /** index start */
  22147. indexStart: number,
  22148. /** indices count */
  22149. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22150. /**
  22151. * Returns true if this submesh covers the entire parent mesh
  22152. * @ignorenaming
  22153. */
  22154. readonly IsGlobal: boolean;
  22155. /**
  22156. * Returns the submesh BoudingInfo object
  22157. * @returns current bounding info (or mesh's one if the submesh is global)
  22158. */
  22159. getBoundingInfo(): BoundingInfo;
  22160. /**
  22161. * Sets the submesh BoundingInfo
  22162. * @param boundingInfo defines the new bounding info to use
  22163. * @returns the SubMesh
  22164. */
  22165. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22166. /**
  22167. * Returns the mesh of the current submesh
  22168. * @return the parent mesh
  22169. */
  22170. getMesh(): AbstractMesh;
  22171. /**
  22172. * Returns the rendering mesh of the submesh
  22173. * @returns the rendering mesh (could be different from parent mesh)
  22174. */
  22175. getRenderingMesh(): Mesh;
  22176. /**
  22177. * Returns the submesh material
  22178. * @returns null or the current material
  22179. */
  22180. getMaterial(): Nullable<Material>;
  22181. /**
  22182. * Sets a new updated BoundingInfo object to the submesh
  22183. * @returns the SubMesh
  22184. */
  22185. refreshBoundingInfo(): SubMesh;
  22186. /** @hidden */
  22187. _checkCollision(collider: Collider): boolean;
  22188. /**
  22189. * Updates the submesh BoundingInfo
  22190. * @param world defines the world matrix to use to update the bounding info
  22191. * @returns the submesh
  22192. */
  22193. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22194. /**
  22195. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22196. * @param frustumPlanes defines the frustum planes
  22197. * @returns true if the submesh is intersecting with the frustum
  22198. */
  22199. isInFrustum(frustumPlanes: Plane[]): boolean;
  22200. /**
  22201. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22202. * @param frustumPlanes defines the frustum planes
  22203. * @returns true if the submesh is inside the frustum
  22204. */
  22205. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22206. /**
  22207. * Renders the submesh
  22208. * @param enableAlphaMode defines if alpha needs to be used
  22209. * @returns the submesh
  22210. */
  22211. render(enableAlphaMode: boolean): SubMesh;
  22212. /**
  22213. * @hidden
  22214. */
  22215. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22216. /**
  22217. * Checks if the submesh intersects with a ray
  22218. * @param ray defines the ray to test
  22219. * @returns true is the passed ray intersects the submesh bounding box
  22220. */
  22221. canIntersects(ray: Ray): boolean;
  22222. /**
  22223. * Intersects current submesh with a ray
  22224. * @param ray defines the ray to test
  22225. * @param positions defines mesh's positions array
  22226. * @param indices defines mesh's indices array
  22227. * @param fastCheck defines if only bounding info should be used
  22228. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22229. * @returns intersection info or null if no intersection
  22230. */
  22231. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22232. /** @hidden */
  22233. private _intersectLines;
  22234. /** @hidden */
  22235. private _intersectTriangles;
  22236. /** @hidden */
  22237. _rebuild(): void;
  22238. /**
  22239. * Creates a new submesh from the passed mesh
  22240. * @param newMesh defines the new hosting mesh
  22241. * @param newRenderingMesh defines an optional rendering mesh
  22242. * @returns the new submesh
  22243. */
  22244. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22245. /**
  22246. * Release associated resources
  22247. */
  22248. dispose(): void;
  22249. /**
  22250. * Gets the class name
  22251. * @returns the string "SubMesh".
  22252. */
  22253. getClassName(): string;
  22254. /**
  22255. * Creates a new submesh from indices data
  22256. * @param materialIndex the index of the main mesh material
  22257. * @param startIndex the index where to start the copy in the mesh indices array
  22258. * @param indexCount the number of indices to copy then from the startIndex
  22259. * @param mesh the main mesh to create the submesh from
  22260. * @param renderingMesh the optional rendering mesh
  22261. * @returns a new submesh
  22262. */
  22263. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22264. }
  22265. }
  22266. declare module "babylonjs/Meshes/geometry" {
  22267. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22268. import { Scene } from "babylonjs/scene";
  22269. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22270. import { Engine } from "babylonjs/Engines/engine";
  22271. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22272. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22273. import { Effect } from "babylonjs/Materials/effect";
  22274. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22275. import { Mesh } from "babylonjs/Meshes/mesh";
  22276. /**
  22277. * Class used to store geometry data (vertex buffers + index buffer)
  22278. */
  22279. export class Geometry implements IGetSetVerticesData {
  22280. /**
  22281. * Gets or sets the ID of the geometry
  22282. */
  22283. id: string;
  22284. /**
  22285. * Gets or sets the unique ID of the geometry
  22286. */
  22287. uniqueId: number;
  22288. /**
  22289. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22290. */
  22291. delayLoadState: number;
  22292. /**
  22293. * Gets the file containing the data to load when running in delay load state
  22294. */
  22295. delayLoadingFile: Nullable<string>;
  22296. /**
  22297. * Callback called when the geometry is updated
  22298. */
  22299. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22300. private _scene;
  22301. private _engine;
  22302. private _meshes;
  22303. private _totalVertices;
  22304. /** @hidden */
  22305. _indices: IndicesArray;
  22306. /** @hidden */
  22307. _vertexBuffers: {
  22308. [key: string]: VertexBuffer;
  22309. };
  22310. private _isDisposed;
  22311. private _extend;
  22312. private _boundingBias;
  22313. /** @hidden */
  22314. _delayInfo: Array<string>;
  22315. private _indexBuffer;
  22316. private _indexBufferIsUpdatable;
  22317. /** @hidden */
  22318. _boundingInfo: Nullable<BoundingInfo>;
  22319. /** @hidden */
  22320. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22321. /** @hidden */
  22322. _softwareSkinningFrameId: number;
  22323. private _vertexArrayObjects;
  22324. private _updatable;
  22325. /** @hidden */
  22326. _positions: Nullable<Vector3[]>;
  22327. /**
  22328. * 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
  22329. */
  22330. /**
  22331. * 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
  22332. */
  22333. boundingBias: Vector2;
  22334. /**
  22335. * Static function used to attach a new empty geometry to a mesh
  22336. * @param mesh defines the mesh to attach the geometry to
  22337. * @returns the new Geometry
  22338. */
  22339. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22340. /**
  22341. * Creates a new geometry
  22342. * @param id defines the unique ID
  22343. * @param scene defines the hosting scene
  22344. * @param vertexData defines the VertexData used to get geometry data
  22345. * @param updatable defines if geometry must be updatable (false by default)
  22346. * @param mesh defines the mesh that will be associated with the geometry
  22347. */
  22348. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22349. /**
  22350. * Gets the current extend of the geometry
  22351. */
  22352. readonly extend: {
  22353. minimum: Vector3;
  22354. maximum: Vector3;
  22355. };
  22356. /**
  22357. * Gets the hosting scene
  22358. * @returns the hosting Scene
  22359. */
  22360. getScene(): Scene;
  22361. /**
  22362. * Gets the hosting engine
  22363. * @returns the hosting Engine
  22364. */
  22365. getEngine(): Engine;
  22366. /**
  22367. * Defines if the geometry is ready to use
  22368. * @returns true if the geometry is ready to be used
  22369. */
  22370. isReady(): boolean;
  22371. /**
  22372. * Gets a value indicating that the geometry should not be serialized
  22373. */
  22374. readonly doNotSerialize: boolean;
  22375. /** @hidden */
  22376. _rebuild(): void;
  22377. /**
  22378. * Affects all geometry data in one call
  22379. * @param vertexData defines the geometry data
  22380. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22381. */
  22382. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22383. /**
  22384. * Set specific vertex data
  22385. * @param kind defines the data kind (Position, normal, etc...)
  22386. * @param data defines the vertex data to use
  22387. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22388. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22389. */
  22390. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22391. /**
  22392. * Removes a specific vertex data
  22393. * @param kind defines the data kind (Position, normal, etc...)
  22394. */
  22395. removeVerticesData(kind: string): void;
  22396. /**
  22397. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22398. * @param buffer defines the vertex buffer to use
  22399. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22400. */
  22401. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22402. /**
  22403. * Update a specific vertex buffer
  22404. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22405. * It will do nothing if the buffer is not updatable
  22406. * @param kind defines the data kind (Position, normal, etc...)
  22407. * @param data defines the data to use
  22408. * @param offset defines the offset in the target buffer where to store the data
  22409. * @param useBytes set to true if the offset is in bytes
  22410. */
  22411. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22412. /**
  22413. * Update a specific vertex buffer
  22414. * This function will create a new buffer if the current one is not updatable
  22415. * @param kind defines the data kind (Position, normal, etc...)
  22416. * @param data defines the data to use
  22417. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22418. */
  22419. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22420. private _updateBoundingInfo;
  22421. /** @hidden */
  22422. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22423. /**
  22424. * Gets total number of vertices
  22425. * @returns the total number of vertices
  22426. */
  22427. getTotalVertices(): number;
  22428. /**
  22429. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22430. * @param kind defines the data kind (Position, normal, etc...)
  22431. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22432. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22433. * @returns a float array containing vertex data
  22434. */
  22435. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22436. /**
  22437. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22438. * @param kind defines the data kind (Position, normal, etc...)
  22439. * @returns true if the vertex buffer with the specified kind is updatable
  22440. */
  22441. isVertexBufferUpdatable(kind: string): boolean;
  22442. /**
  22443. * Gets a specific vertex buffer
  22444. * @param kind defines the data kind (Position, normal, etc...)
  22445. * @returns a VertexBuffer
  22446. */
  22447. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22448. /**
  22449. * Returns all vertex buffers
  22450. * @return an object holding all vertex buffers indexed by kind
  22451. */
  22452. getVertexBuffers(): Nullable<{
  22453. [key: string]: VertexBuffer;
  22454. }>;
  22455. /**
  22456. * Gets a boolean indicating if specific vertex buffer is present
  22457. * @param kind defines the data kind (Position, normal, etc...)
  22458. * @returns true if data is present
  22459. */
  22460. isVerticesDataPresent(kind: string): boolean;
  22461. /**
  22462. * Gets a list of all attached data kinds (Position, normal, etc...)
  22463. * @returns a list of string containing all kinds
  22464. */
  22465. getVerticesDataKinds(): string[];
  22466. /**
  22467. * Update index buffer
  22468. * @param indices defines the indices to store in the index buffer
  22469. * @param offset defines the offset in the target buffer where to store the data
  22470. */
  22471. updateIndices(indices: IndicesArray, offset?: number): void;
  22472. /**
  22473. * Creates a new index buffer
  22474. * @param indices defines the indices to store in the index buffer
  22475. * @param totalVertices defines the total number of vertices (could be null)
  22476. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22477. */
  22478. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22479. /**
  22480. * Return the total number of indices
  22481. * @returns the total number of indices
  22482. */
  22483. getTotalIndices(): number;
  22484. /**
  22485. * Gets the index buffer array
  22486. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22487. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22488. * @returns the index buffer array
  22489. */
  22490. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22491. /**
  22492. * Gets the index buffer
  22493. * @return the index buffer
  22494. */
  22495. getIndexBuffer(): Nullable<WebGLBuffer>;
  22496. /** @hidden */
  22497. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22498. /**
  22499. * Release the associated resources for a specific mesh
  22500. * @param mesh defines the source mesh
  22501. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22502. */
  22503. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22504. /**
  22505. * Apply current geometry to a given mesh
  22506. * @param mesh defines the mesh to apply geometry to
  22507. */
  22508. applyToMesh(mesh: Mesh): void;
  22509. private _updateExtend;
  22510. private _applyToMesh;
  22511. private notifyUpdate;
  22512. /**
  22513. * Load the geometry if it was flagged as delay loaded
  22514. * @param scene defines the hosting scene
  22515. * @param onLoaded defines a callback called when the geometry is loaded
  22516. */
  22517. load(scene: Scene, onLoaded?: () => void): void;
  22518. private _queueLoad;
  22519. /**
  22520. * Invert the geometry to move from a right handed system to a left handed one.
  22521. */
  22522. toLeftHanded(): void;
  22523. /** @hidden */
  22524. _resetPointsArrayCache(): void;
  22525. /** @hidden */
  22526. _generatePointsArray(): boolean;
  22527. /**
  22528. * Gets a value indicating if the geometry is disposed
  22529. * @returns true if the geometry was disposed
  22530. */
  22531. isDisposed(): boolean;
  22532. private _disposeVertexArrayObjects;
  22533. /**
  22534. * Free all associated resources
  22535. */
  22536. dispose(): void;
  22537. /**
  22538. * Clone the current geometry into a new geometry
  22539. * @param id defines the unique ID of the new geometry
  22540. * @returns a new geometry object
  22541. */
  22542. copy(id: string): Geometry;
  22543. /**
  22544. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22545. * @return a JSON representation of the current geometry data (without the vertices data)
  22546. */
  22547. serialize(): any;
  22548. private toNumberArray;
  22549. /**
  22550. * Serialize all vertices data into a JSON oject
  22551. * @returns a JSON representation of the current geometry data
  22552. */
  22553. serializeVerticeData(): any;
  22554. /**
  22555. * Extracts a clone of a mesh geometry
  22556. * @param mesh defines the source mesh
  22557. * @param id defines the unique ID of the new geometry object
  22558. * @returns the new geometry object
  22559. */
  22560. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22561. /**
  22562. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22563. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22564. * Be aware Math.random() could cause collisions, but:
  22565. * "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"
  22566. * @returns a string containing a new GUID
  22567. */
  22568. static RandomId(): string;
  22569. /** @hidden */
  22570. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22571. private static _CleanMatricesWeights;
  22572. /**
  22573. * Create a new geometry from persisted data (Using .babylon file format)
  22574. * @param parsedVertexData defines the persisted data
  22575. * @param scene defines the hosting scene
  22576. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22577. * @returns the new geometry object
  22578. */
  22579. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22580. }
  22581. }
  22582. declare module "babylonjs/Meshes/mesh.vertexData" {
  22583. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22584. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22585. import { Geometry } from "babylonjs/Meshes/geometry";
  22586. import { Mesh } from "babylonjs/Meshes/mesh";
  22587. /**
  22588. * Define an interface for all classes that will get and set the data on vertices
  22589. */
  22590. export interface IGetSetVerticesData {
  22591. /**
  22592. * Gets a boolean indicating if specific vertex data is present
  22593. * @param kind defines the vertex data kind to use
  22594. * @returns true is data kind is present
  22595. */
  22596. isVerticesDataPresent(kind: string): boolean;
  22597. /**
  22598. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22599. * @param kind defines the data kind (Position, normal, etc...)
  22600. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22601. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22602. * @returns a float array containing vertex data
  22603. */
  22604. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22605. /**
  22606. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22607. * @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.
  22608. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22609. * @returns the indices array or an empty array if the mesh has no geometry
  22610. */
  22611. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22612. /**
  22613. * Set specific vertex data
  22614. * @param kind defines the data kind (Position, normal, etc...)
  22615. * @param data defines the vertex data to use
  22616. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22617. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22618. */
  22619. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22620. /**
  22621. * Update a specific associated vertex buffer
  22622. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22623. * - VertexBuffer.PositionKind
  22624. * - VertexBuffer.UVKind
  22625. * - VertexBuffer.UV2Kind
  22626. * - VertexBuffer.UV3Kind
  22627. * - VertexBuffer.UV4Kind
  22628. * - VertexBuffer.UV5Kind
  22629. * - VertexBuffer.UV6Kind
  22630. * - VertexBuffer.ColorKind
  22631. * - VertexBuffer.MatricesIndicesKind
  22632. * - VertexBuffer.MatricesIndicesExtraKind
  22633. * - VertexBuffer.MatricesWeightsKind
  22634. * - VertexBuffer.MatricesWeightsExtraKind
  22635. * @param data defines the data source
  22636. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22637. * @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)
  22638. */
  22639. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22640. /**
  22641. * Creates a new index buffer
  22642. * @param indices defines the indices to store in the index buffer
  22643. * @param totalVertices defines the total number of vertices (could be null)
  22644. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22645. */
  22646. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22647. }
  22648. /**
  22649. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22650. */
  22651. export class VertexData {
  22652. /**
  22653. * Mesh side orientation : usually the external or front surface
  22654. */
  22655. static readonly FRONTSIDE: number;
  22656. /**
  22657. * Mesh side orientation : usually the internal or back surface
  22658. */
  22659. static readonly BACKSIDE: number;
  22660. /**
  22661. * Mesh side orientation : both internal and external or front and back surfaces
  22662. */
  22663. static readonly DOUBLESIDE: number;
  22664. /**
  22665. * Mesh side orientation : by default, `FRONTSIDE`
  22666. */
  22667. static readonly DEFAULTSIDE: number;
  22668. /**
  22669. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22670. */
  22671. positions: Nullable<FloatArray>;
  22672. /**
  22673. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22674. */
  22675. normals: Nullable<FloatArray>;
  22676. /**
  22677. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22678. */
  22679. tangents: Nullable<FloatArray>;
  22680. /**
  22681. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22682. */
  22683. uvs: Nullable<FloatArray>;
  22684. /**
  22685. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22686. */
  22687. uvs2: Nullable<FloatArray>;
  22688. /**
  22689. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22690. */
  22691. uvs3: Nullable<FloatArray>;
  22692. /**
  22693. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22694. */
  22695. uvs4: Nullable<FloatArray>;
  22696. /**
  22697. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22698. */
  22699. uvs5: Nullable<FloatArray>;
  22700. /**
  22701. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22702. */
  22703. uvs6: Nullable<FloatArray>;
  22704. /**
  22705. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22706. */
  22707. colors: Nullable<FloatArray>;
  22708. /**
  22709. * 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).
  22710. */
  22711. matricesIndices: Nullable<FloatArray>;
  22712. /**
  22713. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22714. */
  22715. matricesWeights: Nullable<FloatArray>;
  22716. /**
  22717. * An array extending the number of possible indices
  22718. */
  22719. matricesIndicesExtra: Nullable<FloatArray>;
  22720. /**
  22721. * An array extending the number of possible weights when the number of indices is extended
  22722. */
  22723. matricesWeightsExtra: Nullable<FloatArray>;
  22724. /**
  22725. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22726. */
  22727. indices: Nullable<IndicesArray>;
  22728. /**
  22729. * Uses the passed data array to set the set the values for the specified kind of data
  22730. * @param data a linear array of floating numbers
  22731. * @param kind the type of data that is being set, eg positions, colors etc
  22732. */
  22733. set(data: FloatArray, kind: string): void;
  22734. /**
  22735. * Associates the vertexData to the passed Mesh.
  22736. * Sets it as updatable or not (default `false`)
  22737. * @param mesh the mesh the vertexData is applied to
  22738. * @param updatable when used and having the value true allows new data to update the vertexData
  22739. * @returns the VertexData
  22740. */
  22741. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22742. /**
  22743. * Associates the vertexData to the passed Geometry.
  22744. * Sets it as updatable or not (default `false`)
  22745. * @param geometry the geometry the vertexData is applied to
  22746. * @param updatable when used and having the value true allows new data to update the vertexData
  22747. * @returns VertexData
  22748. */
  22749. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22750. /**
  22751. * Updates the associated mesh
  22752. * @param mesh the mesh to be updated
  22753. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22754. * @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
  22755. * @returns VertexData
  22756. */
  22757. updateMesh(mesh: Mesh): VertexData;
  22758. /**
  22759. * Updates the associated geometry
  22760. * @param geometry the geometry to be updated
  22761. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22762. * @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
  22763. * @returns VertexData.
  22764. */
  22765. updateGeometry(geometry: Geometry): VertexData;
  22766. private _applyTo;
  22767. private _update;
  22768. /**
  22769. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22770. * @param matrix the transforming matrix
  22771. * @returns the VertexData
  22772. */
  22773. transform(matrix: Matrix): VertexData;
  22774. /**
  22775. * Merges the passed VertexData into the current one
  22776. * @param other the VertexData to be merged into the current one
  22777. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22778. * @returns the modified VertexData
  22779. */
  22780. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22781. private _mergeElement;
  22782. private _validate;
  22783. /**
  22784. * Serializes the VertexData
  22785. * @returns a serialized object
  22786. */
  22787. serialize(): any;
  22788. /**
  22789. * Extracts the vertexData from a mesh
  22790. * @param mesh the mesh from which to extract the VertexData
  22791. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22792. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22793. * @returns the object VertexData associated to the passed mesh
  22794. */
  22795. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22796. /**
  22797. * Extracts the vertexData from the geometry
  22798. * @param geometry the geometry from which to extract the VertexData
  22799. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22800. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22801. * @returns the object VertexData associated to the passed mesh
  22802. */
  22803. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22804. private static _ExtractFrom;
  22805. /**
  22806. * Creates the VertexData for a Ribbon
  22807. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22808. * * pathArray array of paths, each of which an array of successive Vector3
  22809. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22810. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22811. * * 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
  22812. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22813. * * 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)
  22814. * * 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)
  22815. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22816. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22817. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22818. * @returns the VertexData of the ribbon
  22819. */
  22820. static CreateRibbon(options: {
  22821. pathArray: Vector3[][];
  22822. closeArray?: boolean;
  22823. closePath?: boolean;
  22824. offset?: number;
  22825. sideOrientation?: number;
  22826. frontUVs?: Vector4;
  22827. backUVs?: Vector4;
  22828. invertUV?: boolean;
  22829. uvs?: Vector2[];
  22830. colors?: Color4[];
  22831. }): VertexData;
  22832. /**
  22833. * Creates the VertexData for a box
  22834. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22835. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22836. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22837. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22838. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22839. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22840. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22841. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22842. * * 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)
  22843. * * 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)
  22844. * @returns the VertexData of the box
  22845. */
  22846. static CreateBox(options: {
  22847. size?: number;
  22848. width?: number;
  22849. height?: number;
  22850. depth?: number;
  22851. faceUV?: Vector4[];
  22852. faceColors?: Color4[];
  22853. sideOrientation?: number;
  22854. frontUVs?: Vector4;
  22855. backUVs?: Vector4;
  22856. }): VertexData;
  22857. /**
  22858. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22859. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22860. * * segments sets the number of horizontal strips optional, default 32
  22861. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22862. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22863. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22864. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22865. * * 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
  22866. * * 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
  22867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22868. * * 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)
  22869. * * 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)
  22870. * @returns the VertexData of the ellipsoid
  22871. */
  22872. static CreateSphere(options: {
  22873. segments?: number;
  22874. diameter?: number;
  22875. diameterX?: number;
  22876. diameterY?: number;
  22877. diameterZ?: number;
  22878. arc?: number;
  22879. slice?: number;
  22880. sideOrientation?: number;
  22881. frontUVs?: Vector4;
  22882. backUVs?: Vector4;
  22883. }): VertexData;
  22884. /**
  22885. * Creates the VertexData for a cylinder, cone or prism
  22886. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22887. * * height sets the height (y direction) of the cylinder, optional, default 2
  22888. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22889. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22890. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22891. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22892. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22893. * * 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
  22894. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22895. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22896. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22897. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22898. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22899. * * 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)
  22900. * * 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)
  22901. * @returns the VertexData of the cylinder, cone or prism
  22902. */
  22903. static CreateCylinder(options: {
  22904. height?: number;
  22905. diameterTop?: number;
  22906. diameterBottom?: number;
  22907. diameter?: number;
  22908. tessellation?: number;
  22909. subdivisions?: number;
  22910. arc?: number;
  22911. faceColors?: Color4[];
  22912. faceUV?: Vector4[];
  22913. hasRings?: boolean;
  22914. enclose?: boolean;
  22915. sideOrientation?: number;
  22916. frontUVs?: Vector4;
  22917. backUVs?: Vector4;
  22918. }): VertexData;
  22919. /**
  22920. * Creates the VertexData for a torus
  22921. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22922. * * diameter the diameter of the torus, optional default 1
  22923. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22924. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22926. * * 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)
  22927. * * 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)
  22928. * @returns the VertexData of the torus
  22929. */
  22930. static CreateTorus(options: {
  22931. diameter?: number;
  22932. thickness?: number;
  22933. tessellation?: number;
  22934. sideOrientation?: number;
  22935. frontUVs?: Vector4;
  22936. backUVs?: Vector4;
  22937. }): VertexData;
  22938. /**
  22939. * Creates the VertexData of the LineSystem
  22940. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22941. * - lines an array of lines, each line being an array of successive Vector3
  22942. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22943. * @returns the VertexData of the LineSystem
  22944. */
  22945. static CreateLineSystem(options: {
  22946. lines: Vector3[][];
  22947. colors?: Nullable<Color4[][]>;
  22948. }): VertexData;
  22949. /**
  22950. * Create the VertexData for a DashedLines
  22951. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22952. * - points an array successive Vector3
  22953. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22954. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22955. * - dashNb the intended total number of dashes, optional, default 200
  22956. * @returns the VertexData for the DashedLines
  22957. */
  22958. static CreateDashedLines(options: {
  22959. points: Vector3[];
  22960. dashSize?: number;
  22961. gapSize?: number;
  22962. dashNb?: number;
  22963. }): VertexData;
  22964. /**
  22965. * Creates the VertexData for a Ground
  22966. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22967. * - width the width (x direction) of the ground, optional, default 1
  22968. * - height the height (z direction) of the ground, optional, default 1
  22969. * - subdivisions the number of subdivisions per side, optional, default 1
  22970. * @returns the VertexData of the Ground
  22971. */
  22972. static CreateGround(options: {
  22973. width?: number;
  22974. height?: number;
  22975. subdivisions?: number;
  22976. subdivisionsX?: number;
  22977. subdivisionsY?: number;
  22978. }): VertexData;
  22979. /**
  22980. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22981. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22982. * * xmin the ground minimum X coordinate, optional, default -1
  22983. * * zmin the ground minimum Z coordinate, optional, default -1
  22984. * * xmax the ground maximum X coordinate, optional, default 1
  22985. * * zmax the ground maximum Z coordinate, optional, default 1
  22986. * * 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}
  22987. * * 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}
  22988. * @returns the VertexData of the TiledGround
  22989. */
  22990. static CreateTiledGround(options: {
  22991. xmin: number;
  22992. zmin: number;
  22993. xmax: number;
  22994. zmax: number;
  22995. subdivisions?: {
  22996. w: number;
  22997. h: number;
  22998. };
  22999. precision?: {
  23000. w: number;
  23001. h: number;
  23002. };
  23003. }): VertexData;
  23004. /**
  23005. * Creates the VertexData of the Ground designed from a heightmap
  23006. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23007. * * width the width (x direction) of the ground
  23008. * * height the height (z direction) of the ground
  23009. * * subdivisions the number of subdivisions per side
  23010. * * minHeight the minimum altitude on the ground, optional, default 0
  23011. * * maxHeight the maximum altitude on the ground, optional default 1
  23012. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23013. * * buffer the array holding the image color data
  23014. * * bufferWidth the width of image
  23015. * * bufferHeight the height of image
  23016. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23017. * @returns the VertexData of the Ground designed from a heightmap
  23018. */
  23019. static CreateGroundFromHeightMap(options: {
  23020. width: number;
  23021. height: number;
  23022. subdivisions: number;
  23023. minHeight: number;
  23024. maxHeight: number;
  23025. colorFilter: Color3;
  23026. buffer: Uint8Array;
  23027. bufferWidth: number;
  23028. bufferHeight: number;
  23029. alphaFilter: number;
  23030. }): VertexData;
  23031. /**
  23032. * Creates the VertexData for a Plane
  23033. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23034. * * size sets the width and height of the plane to the value of size, optional default 1
  23035. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23036. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23038. * * 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)
  23039. * * 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)
  23040. * @returns the VertexData of the box
  23041. */
  23042. static CreatePlane(options: {
  23043. size?: number;
  23044. width?: number;
  23045. height?: number;
  23046. sideOrientation?: number;
  23047. frontUVs?: Vector4;
  23048. backUVs?: Vector4;
  23049. }): VertexData;
  23050. /**
  23051. * Creates the VertexData of the Disc or regular Polygon
  23052. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23053. * * radius the radius of the disc, optional default 0.5
  23054. * * tessellation the number of polygon sides, optional, default 64
  23055. * * 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
  23056. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23057. * * 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)
  23058. * * 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)
  23059. * @returns the VertexData of the box
  23060. */
  23061. static CreateDisc(options: {
  23062. radius?: number;
  23063. tessellation?: number;
  23064. arc?: number;
  23065. sideOrientation?: number;
  23066. frontUVs?: Vector4;
  23067. backUVs?: Vector4;
  23068. }): VertexData;
  23069. /**
  23070. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23071. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23072. * @param polygon a mesh built from polygonTriangulation.build()
  23073. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23074. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23075. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23076. * @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)
  23077. * @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)
  23078. * @returns the VertexData of the Polygon
  23079. */
  23080. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23081. /**
  23082. * Creates the VertexData of the IcoSphere
  23083. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23084. * * radius the radius of the IcoSphere, optional default 1
  23085. * * radiusX allows stretching in the x direction, optional, default radius
  23086. * * radiusY allows stretching in the y direction, optional, default radius
  23087. * * radiusZ allows stretching in the z direction, optional, default radius
  23088. * * flat when true creates a flat shaded mesh, optional, default true
  23089. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23090. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23091. * * 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)
  23092. * * 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)
  23093. * @returns the VertexData of the IcoSphere
  23094. */
  23095. static CreateIcoSphere(options: {
  23096. radius?: number;
  23097. radiusX?: number;
  23098. radiusY?: number;
  23099. radiusZ?: number;
  23100. flat?: boolean;
  23101. subdivisions?: number;
  23102. sideOrientation?: number;
  23103. frontUVs?: Vector4;
  23104. backUVs?: Vector4;
  23105. }): VertexData;
  23106. /**
  23107. * Creates the VertexData for a Polyhedron
  23108. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23109. * * type provided types are:
  23110. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23111. * * 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)
  23112. * * size the size of the IcoSphere, optional default 1
  23113. * * sizeX allows stretching in the x direction, optional, default size
  23114. * * sizeY allows stretching in the y direction, optional, default size
  23115. * * sizeZ allows stretching in the z direction, optional, default size
  23116. * * 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
  23117. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23118. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23119. * * flat when true creates a flat shaded mesh, optional, default true
  23120. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23122. * * 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)
  23123. * * 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)
  23124. * @returns the VertexData of the Polyhedron
  23125. */
  23126. static CreatePolyhedron(options: {
  23127. type?: number;
  23128. size?: number;
  23129. sizeX?: number;
  23130. sizeY?: number;
  23131. sizeZ?: number;
  23132. custom?: any;
  23133. faceUV?: Vector4[];
  23134. faceColors?: Color4[];
  23135. flat?: boolean;
  23136. sideOrientation?: number;
  23137. frontUVs?: Vector4;
  23138. backUVs?: Vector4;
  23139. }): VertexData;
  23140. /**
  23141. * Creates the VertexData for a TorusKnot
  23142. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23143. * * radius the radius of the torus knot, optional, default 2
  23144. * * tube the thickness of the tube, optional, default 0.5
  23145. * * radialSegments the number of sides on each tube segments, optional, default 32
  23146. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23147. * * p the number of windings around the z axis, optional, default 2
  23148. * * q the number of windings around the x axis, optional, default 3
  23149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23150. * * 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)
  23151. * * 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)
  23152. * @returns the VertexData of the Torus Knot
  23153. */
  23154. static CreateTorusKnot(options: {
  23155. radius?: number;
  23156. tube?: number;
  23157. radialSegments?: number;
  23158. tubularSegments?: number;
  23159. p?: number;
  23160. q?: number;
  23161. sideOrientation?: number;
  23162. frontUVs?: Vector4;
  23163. backUVs?: Vector4;
  23164. }): VertexData;
  23165. /**
  23166. * Compute normals for given positions and indices
  23167. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23168. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23169. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23170. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23171. * * facetNormals : optional array of facet normals (vector3)
  23172. * * facetPositions : optional array of facet positions (vector3)
  23173. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23174. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23175. * * bInfo : optional bounding info, required for facetPartitioning computation
  23176. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23177. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23178. * * useRightHandedSystem: optional boolean to for right handed system computation
  23179. * * depthSort : optional boolean to enable the facet depth sort computation
  23180. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23181. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23182. */
  23183. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23184. facetNormals?: any;
  23185. facetPositions?: any;
  23186. facetPartitioning?: any;
  23187. ratio?: number;
  23188. bInfo?: any;
  23189. bbSize?: Vector3;
  23190. subDiv?: any;
  23191. useRightHandedSystem?: boolean;
  23192. depthSort?: boolean;
  23193. distanceTo?: Vector3;
  23194. depthSortedFacets?: any;
  23195. }): void;
  23196. /** @hidden */
  23197. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23198. /**
  23199. * Applies VertexData created from the imported parameters to the geometry
  23200. * @param parsedVertexData the parsed data from an imported file
  23201. * @param geometry the geometry to apply the VertexData to
  23202. */
  23203. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23204. }
  23205. }
  23206. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23207. import { Nullable } from "babylonjs/types";
  23208. import { Scene } from "babylonjs/scene";
  23209. import { Vector4 } from "babylonjs/Maths/math";
  23210. import { Mesh } from "babylonjs/Meshes/mesh";
  23211. /**
  23212. * Class containing static functions to help procedurally build meshes
  23213. */
  23214. export class DiscBuilder {
  23215. /**
  23216. * Creates a plane polygonal mesh. By default, this is a disc
  23217. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23218. * * 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
  23219. * * 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
  23220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23221. * * If you create a double-sided mesh, you can choose what parts of 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
  23222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23223. * @param name defines the name of the mesh
  23224. * @param options defines the options used to create the mesh
  23225. * @param scene defines the hosting scene
  23226. * @returns the plane polygonal mesh
  23227. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23228. */
  23229. static CreateDisc(name: string, options: {
  23230. radius?: number;
  23231. tessellation?: number;
  23232. arc?: number;
  23233. updatable?: boolean;
  23234. sideOrientation?: number;
  23235. frontUVs?: Vector4;
  23236. backUVs?: Vector4;
  23237. }, scene?: Nullable<Scene>): Mesh;
  23238. }
  23239. }
  23240. declare module "babylonjs/Particles/solidParticleSystem" {
  23241. import { Vector3 } from "babylonjs/Maths/math";
  23242. import { Mesh } from "babylonjs/Meshes/mesh";
  23243. import { Scene, IDisposable } from "babylonjs/scene";
  23244. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23245. /**
  23246. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23247. *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.
  23248. * The SPS is also a particle system. It provides some methods to manage the particles.
  23249. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23250. *
  23251. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23252. */
  23253. export class SolidParticleSystem implements IDisposable {
  23254. /**
  23255. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23256. * Example : var p = SPS.particles[i];
  23257. */
  23258. particles: SolidParticle[];
  23259. /**
  23260. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23261. */
  23262. nbParticles: number;
  23263. /**
  23264. * If the particles must ever face the camera (default false). Useful for planar particles.
  23265. */
  23266. billboard: boolean;
  23267. /**
  23268. * Recompute normals when adding a shape
  23269. */
  23270. recomputeNormals: boolean;
  23271. /**
  23272. * This a counter ofr your own usage. It's not set by any SPS functions.
  23273. */
  23274. counter: number;
  23275. /**
  23276. * The SPS name. This name is also given to the underlying mesh.
  23277. */
  23278. name: string;
  23279. /**
  23280. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23281. */
  23282. mesh: Mesh;
  23283. /**
  23284. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23285. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23286. */
  23287. vars: any;
  23288. /**
  23289. * This array is populated when the SPS is set as 'pickable'.
  23290. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23291. * Each element of this array is an object `{idx: int, faceId: int}`.
  23292. * `idx` is the picked particle index in the `SPS.particles` array
  23293. * `faceId` is the picked face index counted within this particle.
  23294. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23295. */
  23296. pickedParticles: {
  23297. idx: number;
  23298. faceId: number;
  23299. }[];
  23300. /**
  23301. * This array is populated when `enableDepthSort` is set to true.
  23302. * Each element of this array is an instance of the class DepthSortedParticle.
  23303. */
  23304. depthSortedParticles: DepthSortedParticle[];
  23305. /**
  23306. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23307. * @hidden
  23308. */
  23309. _bSphereOnly: boolean;
  23310. /**
  23311. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23312. * @hidden
  23313. */
  23314. _bSphereRadiusFactor: number;
  23315. private _scene;
  23316. private _positions;
  23317. private _indices;
  23318. private _normals;
  23319. private _colors;
  23320. private _uvs;
  23321. private _indices32;
  23322. private _positions32;
  23323. private _normals32;
  23324. private _fixedNormal32;
  23325. private _colors32;
  23326. private _uvs32;
  23327. private _index;
  23328. private _updatable;
  23329. private _pickable;
  23330. private _isVisibilityBoxLocked;
  23331. private _alwaysVisible;
  23332. private _depthSort;
  23333. private _shapeCounter;
  23334. private _copy;
  23335. private _color;
  23336. private _computeParticleColor;
  23337. private _computeParticleTexture;
  23338. private _computeParticleRotation;
  23339. private _computeParticleVertex;
  23340. private _computeBoundingBox;
  23341. private _depthSortParticles;
  23342. private _camera;
  23343. private _mustUnrotateFixedNormals;
  23344. private _particlesIntersect;
  23345. private _needs32Bits;
  23346. /**
  23347. * Creates a SPS (Solid Particle System) object.
  23348. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23349. * @param scene (Scene) is the scene in which the SPS is added.
  23350. * @param options defines the options of the sps e.g.
  23351. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23352. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23353. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23354. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23355. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23356. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23357. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23358. */
  23359. constructor(name: string, scene: Scene, options?: {
  23360. updatable?: boolean;
  23361. isPickable?: boolean;
  23362. enableDepthSort?: boolean;
  23363. particleIntersection?: boolean;
  23364. boundingSphereOnly?: boolean;
  23365. bSphereRadiusFactor?: number;
  23366. });
  23367. /**
  23368. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23369. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23370. * @returns the created mesh
  23371. */
  23372. buildMesh(): Mesh;
  23373. /**
  23374. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23375. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23376. * Thus the particles generated from `digest()` have their property `position` set yet.
  23377. * @param mesh ( Mesh ) is the mesh to be digested
  23378. * @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
  23379. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23380. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23381. * @returns the current SPS
  23382. */
  23383. digest(mesh: Mesh, options?: {
  23384. facetNb?: number;
  23385. number?: number;
  23386. delta?: number;
  23387. }): SolidParticleSystem;
  23388. private _unrotateFixedNormals;
  23389. private _resetCopy;
  23390. private _meshBuilder;
  23391. private _posToShape;
  23392. private _uvsToShapeUV;
  23393. private _addParticle;
  23394. /**
  23395. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23396. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23397. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23398. * @param nb (positive integer) the number of particles to be created from this model
  23399. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23400. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23401. * @returns the number of shapes in the system
  23402. */
  23403. addShape(mesh: Mesh, nb: number, options?: {
  23404. positionFunction?: any;
  23405. vertexFunction?: any;
  23406. }): number;
  23407. private _rebuildParticle;
  23408. /**
  23409. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23410. * @returns the SPS.
  23411. */
  23412. rebuildMesh(): SolidParticleSystem;
  23413. /**
  23414. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23415. * This method calls `updateParticle()` for each particle of the SPS.
  23416. * For an animated SPS, it is usually called within the render loop.
  23417. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23418. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23419. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23420. * @returns the SPS.
  23421. */
  23422. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23423. /**
  23424. * Disposes the SPS.
  23425. */
  23426. dispose(): void;
  23427. /**
  23428. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23429. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23430. * @returns the SPS.
  23431. */
  23432. refreshVisibleSize(): SolidParticleSystem;
  23433. /**
  23434. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23435. * @param size the size (float) of the visibility box
  23436. * note : this doesn't lock the SPS mesh bounding box.
  23437. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23438. */
  23439. setVisibilityBox(size: number): void;
  23440. /**
  23441. * Gets whether the SPS as always visible or not
  23442. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23443. */
  23444. /**
  23445. * Sets the SPS as always visible or not
  23446. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23447. */
  23448. isAlwaysVisible: boolean;
  23449. /**
  23450. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23451. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23452. */
  23453. /**
  23454. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23455. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23456. */
  23457. isVisibilityBoxLocked: boolean;
  23458. /**
  23459. * Tells to `setParticles()` to compute the particle rotations or not.
  23460. * Default value : true. The SPS is faster when it's set to false.
  23461. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23462. */
  23463. /**
  23464. * Gets if `setParticles()` computes the particle rotations or not.
  23465. * Default value : true. The SPS is faster when it's set to false.
  23466. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23467. */
  23468. computeParticleRotation: boolean;
  23469. /**
  23470. * Tells to `setParticles()` to compute the particle colors or not.
  23471. * Default value : true. The SPS is faster when it's set to false.
  23472. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23473. */
  23474. /**
  23475. * Gets if `setParticles()` computes the particle colors or not.
  23476. * Default value : true. The SPS is faster when it's set to false.
  23477. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23478. */
  23479. computeParticleColor: boolean;
  23480. /**
  23481. * Gets if `setParticles()` computes the particle textures or not.
  23482. * Default value : true. The SPS is faster when it's set to false.
  23483. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23484. */
  23485. computeParticleTexture: boolean;
  23486. /**
  23487. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23488. * Default value : false. The SPS is faster when it's set to false.
  23489. * Note : the particle custom vertex positions aren't stored values.
  23490. */
  23491. /**
  23492. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23493. * Default value : false. The SPS is faster when it's set to false.
  23494. * Note : the particle custom vertex positions aren't stored values.
  23495. */
  23496. computeParticleVertex: boolean;
  23497. /**
  23498. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23499. */
  23500. /**
  23501. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23502. */
  23503. computeBoundingBox: boolean;
  23504. /**
  23505. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23506. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23507. * Default : `true`
  23508. */
  23509. /**
  23510. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23511. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23512. * Default : `true`
  23513. */
  23514. depthSortParticles: boolean;
  23515. /**
  23516. * This function does nothing. It may be overwritten to set all the particle first values.
  23517. * The SPS doesn't call this function, you may have to call it by your own.
  23518. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23519. */
  23520. initParticles(): void;
  23521. /**
  23522. * This function does nothing. It may be overwritten to recycle a particle.
  23523. * The SPS doesn't call this function, you may have to call it by your own.
  23524. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23525. * @param particle The particle to recycle
  23526. * @returns the recycled particle
  23527. */
  23528. recycleParticle(particle: SolidParticle): SolidParticle;
  23529. /**
  23530. * Updates a particle : this function should be overwritten by the user.
  23531. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23532. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23533. * @example : just set a particle position or velocity and recycle conditions
  23534. * @param particle The particle to update
  23535. * @returns the updated particle
  23536. */
  23537. updateParticle(particle: SolidParticle): SolidParticle;
  23538. /**
  23539. * Updates a vertex of a particle : it can be overwritten by the user.
  23540. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23541. * @param particle the current particle
  23542. * @param vertex the current index of the current particle
  23543. * @param pt the index of the current vertex in the particle shape
  23544. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23545. * @example : just set a vertex particle position
  23546. * @returns the updated vertex
  23547. */
  23548. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23549. /**
  23550. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23551. * This does nothing and may be overwritten by the user.
  23552. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23553. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23554. * @param update the boolean update value actually passed to setParticles()
  23555. */
  23556. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23557. /**
  23558. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23559. * This will be passed three parameters.
  23560. * This does nothing and may be overwritten by the user.
  23561. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23562. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23563. * @param update the boolean update value actually passed to setParticles()
  23564. */
  23565. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23566. }
  23567. }
  23568. declare module "babylonjs/Particles/solidParticle" {
  23569. import { Nullable } from "babylonjs/types";
  23570. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23571. import { Mesh } from "babylonjs/Meshes/mesh";
  23572. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23573. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23574. /**
  23575. * Represents one particle of a solid particle system.
  23576. */
  23577. export class SolidParticle {
  23578. /**
  23579. * particle global index
  23580. */
  23581. idx: number;
  23582. /**
  23583. * The color of the particle
  23584. */
  23585. color: Nullable<Color4>;
  23586. /**
  23587. * The world space position of the particle.
  23588. */
  23589. position: Vector3;
  23590. /**
  23591. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23592. */
  23593. rotation: Vector3;
  23594. /**
  23595. * The world space rotation quaternion of the particle.
  23596. */
  23597. rotationQuaternion: Nullable<Quaternion>;
  23598. /**
  23599. * The scaling of the particle.
  23600. */
  23601. scaling: Vector3;
  23602. /**
  23603. * The uvs of the particle.
  23604. */
  23605. uvs: Vector4;
  23606. /**
  23607. * The current speed of the particle.
  23608. */
  23609. velocity: Vector3;
  23610. /**
  23611. * The pivot point in the particle local space.
  23612. */
  23613. pivot: Vector3;
  23614. /**
  23615. * Must the particle be translated from its pivot point in its local space ?
  23616. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23617. * Default : false
  23618. */
  23619. translateFromPivot: boolean;
  23620. /**
  23621. * Is the particle active or not ?
  23622. */
  23623. alive: boolean;
  23624. /**
  23625. * Is the particle visible or not ?
  23626. */
  23627. isVisible: boolean;
  23628. /**
  23629. * Index of this particle in the global "positions" array (Internal use)
  23630. * @hidden
  23631. */
  23632. _pos: number;
  23633. /**
  23634. * @hidden Index of this particle in the global "indices" array (Internal use)
  23635. */
  23636. _ind: number;
  23637. /**
  23638. * @hidden ModelShape of this particle (Internal use)
  23639. */
  23640. _model: ModelShape;
  23641. /**
  23642. * ModelShape id of this particle
  23643. */
  23644. shapeId: number;
  23645. /**
  23646. * Index of the particle in its shape id (Internal use)
  23647. */
  23648. idxInShape: number;
  23649. /**
  23650. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23651. */
  23652. _modelBoundingInfo: BoundingInfo;
  23653. /**
  23654. * @hidden Particle BoundingInfo object (Internal use)
  23655. */
  23656. _boundingInfo: BoundingInfo;
  23657. /**
  23658. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23659. */
  23660. _sps: SolidParticleSystem;
  23661. /**
  23662. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23663. */
  23664. _stillInvisible: boolean;
  23665. /**
  23666. * @hidden Last computed particle rotation matrix
  23667. */
  23668. _rotationMatrix: number[];
  23669. /**
  23670. * Parent particle Id, if any.
  23671. * Default null.
  23672. */
  23673. parentId: Nullable<number>;
  23674. /**
  23675. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23676. * The possible values are :
  23677. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23678. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23679. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23680. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23681. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23682. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23683. * */
  23684. cullingStrategy: number;
  23685. /**
  23686. * @hidden Internal global position in the SPS.
  23687. */
  23688. _globalPosition: Vector3;
  23689. /**
  23690. * Creates a Solid Particle object.
  23691. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23692. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23693. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23694. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23695. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23696. * @param shapeId (integer) is the model shape identifier in the SPS.
  23697. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23698. * @param sps defines the sps it is associated to
  23699. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23700. */
  23701. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23702. /**
  23703. * Legacy support, changed scale to scaling
  23704. */
  23705. /**
  23706. * Legacy support, changed scale to scaling
  23707. */
  23708. scale: Vector3;
  23709. /**
  23710. * Legacy support, changed quaternion to rotationQuaternion
  23711. */
  23712. /**
  23713. * Legacy support, changed quaternion to rotationQuaternion
  23714. */
  23715. quaternion: Nullable<Quaternion>;
  23716. /**
  23717. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23718. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23719. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23720. * @returns true if it intersects
  23721. */
  23722. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23723. /**
  23724. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23725. * A particle is in the frustum if its bounding box intersects the frustum
  23726. * @param frustumPlanes defines the frustum to test
  23727. * @returns true if the particle is in the frustum planes
  23728. */
  23729. isInFrustum(frustumPlanes: Plane[]): boolean;
  23730. /**
  23731. * get the rotation matrix of the particle
  23732. * @hidden
  23733. */
  23734. getRotationMatrix(m: Matrix): void;
  23735. }
  23736. /**
  23737. * Represents the shape of the model used by one particle of a solid particle system.
  23738. * SPS internal tool, don't use it manually.
  23739. */
  23740. export class ModelShape {
  23741. /**
  23742. * The shape id
  23743. * @hidden
  23744. */
  23745. shapeID: number;
  23746. /**
  23747. * flat array of model positions (internal use)
  23748. * @hidden
  23749. */
  23750. _shape: Vector3[];
  23751. /**
  23752. * flat array of model UVs (internal use)
  23753. * @hidden
  23754. */
  23755. _shapeUV: number[];
  23756. /**
  23757. * length of the shape in the model indices array (internal use)
  23758. * @hidden
  23759. */
  23760. _indicesLength: number;
  23761. /**
  23762. * Custom position function (internal use)
  23763. * @hidden
  23764. */
  23765. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23766. /**
  23767. * Custom vertex function (internal use)
  23768. * @hidden
  23769. */
  23770. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23771. /**
  23772. * 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.
  23773. * SPS internal tool, don't use it manually.
  23774. * @hidden
  23775. */
  23776. 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>);
  23777. }
  23778. /**
  23779. * Represents a Depth Sorted Particle in the solid particle system.
  23780. */
  23781. export class DepthSortedParticle {
  23782. /**
  23783. * Index of the particle in the "indices" array
  23784. */
  23785. ind: number;
  23786. /**
  23787. * Length of the particle shape in the "indices" array
  23788. */
  23789. indicesLength: number;
  23790. /**
  23791. * Squared distance from the particle to the camera
  23792. */
  23793. sqDistance: number;
  23794. }
  23795. }
  23796. declare module "babylonjs/Meshes/abstractMesh" {
  23797. import { Observable } from "babylonjs/Misc/observable";
  23798. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23799. import { Camera } from "babylonjs/Cameras/camera";
  23800. import { Scene, IDisposable } from "babylonjs/scene";
  23801. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23802. import { Node } from "babylonjs/node";
  23803. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23804. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23805. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23806. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23807. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23808. import { Material } from "babylonjs/Materials/material";
  23809. import { Light } from "babylonjs/Lights/light";
  23810. import { Skeleton } from "babylonjs/Bones/skeleton";
  23811. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23812. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23813. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23814. import { Ray } from "babylonjs/Culling/ray";
  23815. import { Collider } from "babylonjs/Collisions/collider";
  23816. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23817. /**
  23818. * Class used to store all common mesh properties
  23819. */
  23820. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23821. /** No occlusion */
  23822. static OCCLUSION_TYPE_NONE: number;
  23823. /** Occlusion set to optimisitic */
  23824. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23825. /** Occlusion set to strict */
  23826. static OCCLUSION_TYPE_STRICT: number;
  23827. /** Use an accurante occlusion algorithm */
  23828. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23829. /** Use a conservative occlusion algorithm */
  23830. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23831. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23832. * Test order :
  23833. * Is the bounding sphere outside the frustum ?
  23834. * If not, are the bounding box vertices outside the frustum ?
  23835. * It not, then the cullable object is in the frustum.
  23836. */
  23837. static readonly CULLINGSTRATEGY_STANDARD: number;
  23838. /** Culling strategy : Bounding Sphere Only.
  23839. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23840. * It's also less accurate than the standard because some not visible objects can still be selected.
  23841. * Test : is the bounding sphere outside the frustum ?
  23842. * If not, then the cullable object is in the frustum.
  23843. */
  23844. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23845. /** Culling strategy : Optimistic Inclusion.
  23846. * This in an inclusion test first, then the standard exclusion test.
  23847. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23848. * 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.
  23849. * Anyway, it's as accurate as the standard strategy.
  23850. * Test :
  23851. * Is the cullable object bounding sphere center in the frustum ?
  23852. * If not, apply the default culling strategy.
  23853. */
  23854. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23855. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23856. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23857. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23858. * 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.
  23859. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23860. * Test :
  23861. * Is the cullable object bounding sphere center in the frustum ?
  23862. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23863. */
  23864. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23865. /**
  23866. * No billboard
  23867. */
  23868. static readonly BILLBOARDMODE_NONE: number;
  23869. /** Billboard on X axis */
  23870. static readonly BILLBOARDMODE_X: number;
  23871. /** Billboard on Y axis */
  23872. static readonly BILLBOARDMODE_Y: number;
  23873. /** Billboard on Z axis */
  23874. static readonly BILLBOARDMODE_Z: number;
  23875. /** Billboard on all axes */
  23876. static readonly BILLBOARDMODE_ALL: number;
  23877. private _facetData;
  23878. /**
  23879. * The culling strategy to use to check whether the mesh must be rendered or not.
  23880. * This value can be changed at any time and will be used on the next render mesh selection.
  23881. * The possible values are :
  23882. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23883. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23884. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23885. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23886. * Please read each static variable documentation to get details about the culling process.
  23887. * */
  23888. cullingStrategy: number;
  23889. /**
  23890. * Gets the number of facets in the mesh
  23891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23892. */
  23893. readonly facetNb: number;
  23894. /**
  23895. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23896. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23897. */
  23898. partitioningSubdivisions: number;
  23899. /**
  23900. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23901. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23903. */
  23904. partitioningBBoxRatio: number;
  23905. /**
  23906. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23907. * Works only for updatable meshes.
  23908. * Doesn't work with multi-materials
  23909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23910. */
  23911. mustDepthSortFacets: boolean;
  23912. /**
  23913. * The location (Vector3) where the facet depth sort must be computed from.
  23914. * By default, the active camera position.
  23915. * Used only when facet depth sort is enabled
  23916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23917. */
  23918. facetDepthSortFrom: Vector3;
  23919. /**
  23920. * gets a boolean indicating if facetData is enabled
  23921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23922. */
  23923. readonly isFacetDataEnabled: boolean;
  23924. /** @hidden */
  23925. _updateNonUniformScalingState(value: boolean): boolean;
  23926. /**
  23927. * An event triggered when this mesh collides with another one
  23928. */
  23929. onCollideObservable: Observable<AbstractMesh>;
  23930. private _onCollideObserver;
  23931. /** Set a function to call when this mesh collides with another one */
  23932. onCollide: () => void;
  23933. /**
  23934. * An event triggered when the collision's position changes
  23935. */
  23936. onCollisionPositionChangeObservable: Observable<Vector3>;
  23937. private _onCollisionPositionChangeObserver;
  23938. /** Set a function to call when the collision's position changes */
  23939. onCollisionPositionChange: () => void;
  23940. /**
  23941. * An event triggered when material is changed
  23942. */
  23943. onMaterialChangedObservable: Observable<AbstractMesh>;
  23944. /**
  23945. * Gets or sets the orientation for POV movement & rotation
  23946. */
  23947. definedFacingForward: boolean;
  23948. /** @hidden */
  23949. _occlusionQuery: Nullable<WebGLQuery>;
  23950. private _visibility;
  23951. /**
  23952. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23953. */
  23954. /**
  23955. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23956. */
  23957. visibility: number;
  23958. /** Gets or sets the alpha index used to sort transparent meshes
  23959. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23960. */
  23961. alphaIndex: number;
  23962. /**
  23963. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23964. */
  23965. isVisible: boolean;
  23966. /**
  23967. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23968. */
  23969. isPickable: boolean;
  23970. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23971. showSubMeshesBoundingBox: boolean;
  23972. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23973. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23974. */
  23975. isBlocker: boolean;
  23976. /**
  23977. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23978. */
  23979. enablePointerMoveEvents: boolean;
  23980. /**
  23981. * Specifies the rendering group id for this mesh (0 by default)
  23982. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23983. */
  23984. renderingGroupId: number;
  23985. private _material;
  23986. /** Gets or sets current material */
  23987. material: Nullable<Material>;
  23988. private _receiveShadows;
  23989. /**
  23990. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23991. * @see http://doc.babylonjs.com/babylon101/shadows
  23992. */
  23993. receiveShadows: boolean;
  23994. /** Defines color to use when rendering outline */
  23995. outlineColor: Color3;
  23996. /** Define width to use when rendering outline */
  23997. outlineWidth: number;
  23998. /** Defines color to use when rendering overlay */
  23999. overlayColor: Color3;
  24000. /** Defines alpha to use when rendering overlay */
  24001. overlayAlpha: number;
  24002. private _hasVertexAlpha;
  24003. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24004. hasVertexAlpha: boolean;
  24005. private _useVertexColors;
  24006. /** 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) */
  24007. useVertexColors: boolean;
  24008. private _computeBonesUsingShaders;
  24009. /**
  24010. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24011. */
  24012. computeBonesUsingShaders: boolean;
  24013. private _numBoneInfluencers;
  24014. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24015. numBoneInfluencers: number;
  24016. private _applyFog;
  24017. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24018. applyFog: boolean;
  24019. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24020. useOctreeForRenderingSelection: boolean;
  24021. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24022. useOctreeForPicking: boolean;
  24023. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24024. useOctreeForCollisions: boolean;
  24025. private _layerMask;
  24026. /**
  24027. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24028. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24029. */
  24030. layerMask: number;
  24031. /**
  24032. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24033. */
  24034. alwaysSelectAsActiveMesh: boolean;
  24035. /**
  24036. * Gets or sets the current action manager
  24037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24038. */
  24039. actionManager: Nullable<AbstractActionManager>;
  24040. private _checkCollisions;
  24041. private _collisionMask;
  24042. private _collisionGroup;
  24043. /**
  24044. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24045. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24046. */
  24047. ellipsoid: Vector3;
  24048. /**
  24049. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24050. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24051. */
  24052. ellipsoidOffset: Vector3;
  24053. private _collider;
  24054. private _oldPositionForCollisions;
  24055. private _diffPositionForCollisions;
  24056. /**
  24057. * Gets or sets a collision mask used to mask collisions (default is -1).
  24058. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24059. */
  24060. collisionMask: number;
  24061. /**
  24062. * Gets or sets the current collision group mask (-1 by default).
  24063. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24064. */
  24065. collisionGroup: number;
  24066. /**
  24067. * Defines edge width used when edgesRenderer is enabled
  24068. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24069. */
  24070. edgesWidth: number;
  24071. /**
  24072. * Defines edge color used when edgesRenderer is enabled
  24073. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24074. */
  24075. edgesColor: Color4;
  24076. /** @hidden */
  24077. _edgesRenderer: Nullable<IEdgesRenderer>;
  24078. /** @hidden */
  24079. _masterMesh: Nullable<AbstractMesh>;
  24080. /** @hidden */
  24081. _boundingInfo: Nullable<BoundingInfo>;
  24082. /** @hidden */
  24083. _renderId: number;
  24084. /**
  24085. * Gets or sets the list of subMeshes
  24086. * @see http://doc.babylonjs.com/how_to/multi_materials
  24087. */
  24088. subMeshes: SubMesh[];
  24089. /** @hidden */
  24090. _intersectionsInProgress: AbstractMesh[];
  24091. /** @hidden */
  24092. _unIndexed: boolean;
  24093. /** @hidden */
  24094. _lightSources: Light[];
  24095. /** @hidden */
  24096. readonly _positions: Nullable<Vector3[]>;
  24097. /** @hidden */
  24098. _waitingActions: any;
  24099. /** @hidden */
  24100. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24101. private _skeleton;
  24102. /** @hidden */
  24103. _bonesTransformMatrices: Nullable<Float32Array>;
  24104. /**
  24105. * Gets or sets a skeleton to apply skining transformations
  24106. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24107. */
  24108. skeleton: Nullable<Skeleton>;
  24109. /**
  24110. * An event triggered when the mesh is rebuilt.
  24111. */
  24112. onRebuildObservable: Observable<AbstractMesh>;
  24113. /**
  24114. * Creates a new AbstractMesh
  24115. * @param name defines the name of the mesh
  24116. * @param scene defines the hosting scene
  24117. */
  24118. constructor(name: string, scene?: Nullable<Scene>);
  24119. /**
  24120. * Returns the string "AbstractMesh"
  24121. * @returns "AbstractMesh"
  24122. */
  24123. getClassName(): string;
  24124. /**
  24125. * Gets a string representation of the current mesh
  24126. * @param fullDetails defines a boolean indicating if full details must be included
  24127. * @returns a string representation of the current mesh
  24128. */
  24129. toString(fullDetails?: boolean): string;
  24130. /** @hidden */
  24131. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24132. /** @hidden */
  24133. _rebuild(): void;
  24134. /** @hidden */
  24135. _resyncLightSources(): void;
  24136. /** @hidden */
  24137. _resyncLighSource(light: Light): void;
  24138. /** @hidden */
  24139. _unBindEffect(): void;
  24140. /** @hidden */
  24141. _removeLightSource(light: Light): void;
  24142. private _markSubMeshesAsDirty;
  24143. /** @hidden */
  24144. _markSubMeshesAsLightDirty(): void;
  24145. /** @hidden */
  24146. _markSubMeshesAsAttributesDirty(): void;
  24147. /** @hidden */
  24148. _markSubMeshesAsMiscDirty(): void;
  24149. /**
  24150. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24151. */
  24152. scaling: Vector3;
  24153. /**
  24154. * Returns true if the mesh is blocked. Implemented by child classes
  24155. */
  24156. readonly isBlocked: boolean;
  24157. /**
  24158. * Returns the mesh itself by default. Implemented by child classes
  24159. * @param camera defines the camera to use to pick the right LOD level
  24160. * @returns the currentAbstractMesh
  24161. */
  24162. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24163. /**
  24164. * Returns 0 by default. Implemented by child classes
  24165. * @returns an integer
  24166. */
  24167. getTotalVertices(): number;
  24168. /**
  24169. * Returns a positive integer : the total number of indices in this mesh geometry.
  24170. * @returns the numner of indices or zero if the mesh has no geometry.
  24171. */
  24172. getTotalIndices(): number;
  24173. /**
  24174. * Returns null by default. Implemented by child classes
  24175. * @returns null
  24176. */
  24177. getIndices(): Nullable<IndicesArray>;
  24178. /**
  24179. * Returns the array of the requested vertex data kind. Implemented by child classes
  24180. * @param kind defines the vertex data kind to use
  24181. * @returns null
  24182. */
  24183. getVerticesData(kind: string): Nullable<FloatArray>;
  24184. /**
  24185. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24186. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24187. * Note that a new underlying VertexBuffer object is created each call.
  24188. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24189. * @param kind defines vertex data kind:
  24190. * * VertexBuffer.PositionKind
  24191. * * VertexBuffer.UVKind
  24192. * * VertexBuffer.UV2Kind
  24193. * * VertexBuffer.UV3Kind
  24194. * * VertexBuffer.UV4Kind
  24195. * * VertexBuffer.UV5Kind
  24196. * * VertexBuffer.UV6Kind
  24197. * * VertexBuffer.ColorKind
  24198. * * VertexBuffer.MatricesIndicesKind
  24199. * * VertexBuffer.MatricesIndicesExtraKind
  24200. * * VertexBuffer.MatricesWeightsKind
  24201. * * VertexBuffer.MatricesWeightsExtraKind
  24202. * @param data defines the data source
  24203. * @param updatable defines if the data must be flagged as updatable (or static)
  24204. * @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
  24205. * @returns the current mesh
  24206. */
  24207. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24208. /**
  24209. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24210. * If the mesh has no geometry, it is simply returned as it is.
  24211. * @param kind defines vertex data kind:
  24212. * * VertexBuffer.PositionKind
  24213. * * VertexBuffer.UVKind
  24214. * * VertexBuffer.UV2Kind
  24215. * * VertexBuffer.UV3Kind
  24216. * * VertexBuffer.UV4Kind
  24217. * * VertexBuffer.UV5Kind
  24218. * * VertexBuffer.UV6Kind
  24219. * * VertexBuffer.ColorKind
  24220. * * VertexBuffer.MatricesIndicesKind
  24221. * * VertexBuffer.MatricesIndicesExtraKind
  24222. * * VertexBuffer.MatricesWeightsKind
  24223. * * VertexBuffer.MatricesWeightsExtraKind
  24224. * @param data defines the data source
  24225. * @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
  24226. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24227. * @returns the current mesh
  24228. */
  24229. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24230. /**
  24231. * Sets the mesh indices,
  24232. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24233. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24234. * @param totalVertices Defines the total number of vertices
  24235. * @returns the current mesh
  24236. */
  24237. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24238. /**
  24239. * Gets a boolean indicating if specific vertex data is present
  24240. * @param kind defines the vertex data kind to use
  24241. * @returns true is data kind is present
  24242. */
  24243. isVerticesDataPresent(kind: string): boolean;
  24244. /**
  24245. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24246. * @returns a BoundingInfo
  24247. */
  24248. getBoundingInfo(): BoundingInfo;
  24249. /**
  24250. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24251. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24252. * @returns the current mesh
  24253. */
  24254. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24255. /**
  24256. * Overwrite the current bounding info
  24257. * @param boundingInfo defines the new bounding info
  24258. * @returns the current mesh
  24259. */
  24260. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24261. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24262. readonly useBones: boolean;
  24263. /** @hidden */
  24264. _preActivate(): void;
  24265. /** @hidden */
  24266. _preActivateForIntermediateRendering(renderId: number): void;
  24267. /** @hidden */
  24268. _activate(renderId: number): void;
  24269. /**
  24270. * Gets the current world matrix
  24271. * @returns a Matrix
  24272. */
  24273. getWorldMatrix(): Matrix;
  24274. /** @hidden */
  24275. _getWorldMatrixDeterminant(): number;
  24276. /**
  24277. * Perform relative position change from the point of view of behind the front of the mesh.
  24278. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24279. * Supports definition of mesh facing forward or backward
  24280. * @param amountRight defines the distance on the right axis
  24281. * @param amountUp defines the distance on the up axis
  24282. * @param amountForward defines the distance on the forward axis
  24283. * @returns the current mesh
  24284. */
  24285. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24286. /**
  24287. * Calculate relative position change from the point of view of behind the front of the mesh.
  24288. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24289. * Supports definition of mesh facing forward or backward
  24290. * @param amountRight defines the distance on the right axis
  24291. * @param amountUp defines the distance on the up axis
  24292. * @param amountForward defines the distance on the forward axis
  24293. * @returns the new displacement vector
  24294. */
  24295. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24296. /**
  24297. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24298. * Supports definition of mesh facing forward or backward
  24299. * @param flipBack defines the flip
  24300. * @param twirlClockwise defines the twirl
  24301. * @param tiltRight defines the tilt
  24302. * @returns the current mesh
  24303. */
  24304. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24305. /**
  24306. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24307. * Supports definition of mesh facing forward or backward.
  24308. * @param flipBack defines the flip
  24309. * @param twirlClockwise defines the twirl
  24310. * @param tiltRight defines the tilt
  24311. * @returns the new rotation vector
  24312. */
  24313. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24314. /**
  24315. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24316. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24317. * @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
  24318. * @returns the new bounding vectors
  24319. */
  24320. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24321. min: Vector3;
  24322. max: Vector3;
  24323. };
  24324. /**
  24325. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24326. * This means the mesh underlying bounding box and sphere are recomputed.
  24327. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24328. * @returns the current mesh
  24329. */
  24330. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24331. /** @hidden */
  24332. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24333. /** @hidden */
  24334. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24335. /** @hidden */
  24336. _updateBoundingInfo(): AbstractMesh;
  24337. /** @hidden */
  24338. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24339. /** @hidden */
  24340. protected _afterComputeWorldMatrix(): void;
  24341. /**
  24342. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24343. * A mesh is in the frustum if its bounding box intersects the frustum
  24344. * @param frustumPlanes defines the frustum to test
  24345. * @returns true if the mesh is in the frustum planes
  24346. */
  24347. isInFrustum(frustumPlanes: Plane[]): boolean;
  24348. /**
  24349. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24350. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24351. * @param frustumPlanes defines the frustum to test
  24352. * @returns true if the mesh is completely in the frustum planes
  24353. */
  24354. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24355. /**
  24356. * True if the mesh intersects another mesh or a SolidParticle object
  24357. * @param mesh defines a target mesh or SolidParticle to test
  24358. * @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)
  24359. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24360. * @returns true if there is an intersection
  24361. */
  24362. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24363. /**
  24364. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24365. * @param point defines the point to test
  24366. * @returns true if there is an intersection
  24367. */
  24368. intersectsPoint(point: Vector3): boolean;
  24369. /**
  24370. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24371. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24372. */
  24373. checkCollisions: boolean;
  24374. /**
  24375. * Gets Collider object used to compute collisions (not physics)
  24376. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24377. */
  24378. readonly collider: Collider;
  24379. /**
  24380. * Move the mesh using collision engine
  24381. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24382. * @param displacement defines the requested displacement vector
  24383. * @returns the current mesh
  24384. */
  24385. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24386. private _onCollisionPositionChange;
  24387. /** @hidden */
  24388. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24389. /** @hidden */
  24390. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24391. /** @hidden */
  24392. _checkCollision(collider: Collider): AbstractMesh;
  24393. /** @hidden */
  24394. _generatePointsArray(): boolean;
  24395. /**
  24396. * Checks if the passed Ray intersects with the mesh
  24397. * @param ray defines the ray to use
  24398. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24399. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24400. * @returns the picking info
  24401. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24402. */
  24403. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24404. /**
  24405. * Clones the current mesh
  24406. * @param name defines the mesh name
  24407. * @param newParent defines the new mesh parent
  24408. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24409. * @returns the new mesh
  24410. */
  24411. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24412. /**
  24413. * Disposes all the submeshes of the current meshnp
  24414. * @returns the current mesh
  24415. */
  24416. releaseSubMeshes(): AbstractMesh;
  24417. /**
  24418. * Releases resources associated with this abstract mesh.
  24419. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24420. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24421. */
  24422. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24423. /**
  24424. * Adds the passed mesh as a child to the current mesh
  24425. * @param mesh defines the child mesh
  24426. * @returns the current mesh
  24427. */
  24428. addChild(mesh: AbstractMesh): AbstractMesh;
  24429. /**
  24430. * Removes the passed mesh from the current mesh children list
  24431. * @param mesh defines the child mesh
  24432. * @returns the current mesh
  24433. */
  24434. removeChild(mesh: AbstractMesh): AbstractMesh;
  24435. /** @hidden */
  24436. private _initFacetData;
  24437. /**
  24438. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24439. * This method can be called within the render loop.
  24440. * 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
  24441. * @returns the current mesh
  24442. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24443. */
  24444. updateFacetData(): AbstractMesh;
  24445. /**
  24446. * Returns the facetLocalNormals array.
  24447. * The normals are expressed in the mesh local spac
  24448. * @returns an array of Vector3
  24449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24450. */
  24451. getFacetLocalNormals(): Vector3[];
  24452. /**
  24453. * Returns the facetLocalPositions array.
  24454. * The facet positions are expressed in the mesh local space
  24455. * @returns an array of Vector3
  24456. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24457. */
  24458. getFacetLocalPositions(): Vector3[];
  24459. /**
  24460. * Returns the facetLocalPartioning array
  24461. * @returns an array of array of numbers
  24462. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24463. */
  24464. getFacetLocalPartitioning(): number[][];
  24465. /**
  24466. * Returns the i-th facet position in the world system.
  24467. * This method allocates a new Vector3 per call
  24468. * @param i defines the facet index
  24469. * @returns a new Vector3
  24470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24471. */
  24472. getFacetPosition(i: number): Vector3;
  24473. /**
  24474. * Sets the reference Vector3 with the i-th facet position in the world system
  24475. * @param i defines the facet index
  24476. * @param ref defines the target vector
  24477. * @returns the current mesh
  24478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24479. */
  24480. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24481. /**
  24482. * Returns the i-th facet normal in the world system.
  24483. * This method allocates a new Vector3 per call
  24484. * @param i defines the facet index
  24485. * @returns a new Vector3
  24486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24487. */
  24488. getFacetNormal(i: number): Vector3;
  24489. /**
  24490. * Sets the reference Vector3 with the i-th facet normal in the world system
  24491. * @param i defines the facet index
  24492. * @param ref defines the target vector
  24493. * @returns the current mesh
  24494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24495. */
  24496. getFacetNormalToRef(i: number, ref: Vector3): this;
  24497. /**
  24498. * 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)
  24499. * @param x defines x coordinate
  24500. * @param y defines y coordinate
  24501. * @param z defines z coordinate
  24502. * @returns the array of facet indexes
  24503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24504. */
  24505. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24506. /**
  24507. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24508. * @param projected sets as the (x,y,z) world projection on the facet
  24509. * @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
  24510. * @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
  24511. * @param x defines x coordinate
  24512. * @param y defines y coordinate
  24513. * @param z defines z coordinate
  24514. * @returns the face index if found (or null instead)
  24515. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24516. */
  24517. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24518. /**
  24519. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24520. * @param projected sets as the (x,y,z) local projection on the facet
  24521. * @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
  24522. * @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
  24523. * @param x defines x coordinate
  24524. * @param y defines y coordinate
  24525. * @param z defines z coordinate
  24526. * @returns the face index if found (or null instead)
  24527. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24528. */
  24529. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24530. /**
  24531. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24532. * @returns the parameters
  24533. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24534. */
  24535. getFacetDataParameters(): any;
  24536. /**
  24537. * Disables the feature FacetData and frees the related memory
  24538. * @returns the current mesh
  24539. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24540. */
  24541. disableFacetData(): AbstractMesh;
  24542. /**
  24543. * Updates the AbstractMesh indices array
  24544. * @param indices defines the data source
  24545. * @returns the current mesh
  24546. */
  24547. updateIndices(indices: IndicesArray): AbstractMesh;
  24548. /**
  24549. * Creates new normals data for the mesh
  24550. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24551. * @returns the current mesh
  24552. */
  24553. createNormals(updatable: boolean): AbstractMesh;
  24554. /**
  24555. * Align the mesh with a normal
  24556. * @param normal defines the normal to use
  24557. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24558. * @returns the current mesh
  24559. */
  24560. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24561. /** @hidden */
  24562. _checkOcclusionQuery(): boolean;
  24563. }
  24564. }
  24565. declare module "babylonjs/Actions/actionEvent" {
  24566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24567. import { Nullable } from "babylonjs/types";
  24568. import { Sprite } from "babylonjs/Sprites/sprite";
  24569. import { Scene } from "babylonjs/scene";
  24570. import { Vector2 } from "babylonjs/Maths/math";
  24571. /**
  24572. * Interface used to define ActionEvent
  24573. */
  24574. export interface IActionEvent {
  24575. /** The mesh or sprite that triggered the action */
  24576. source: any;
  24577. /** The X mouse cursor position at the time of the event */
  24578. pointerX: number;
  24579. /** The Y mouse cursor position at the time of the event */
  24580. pointerY: number;
  24581. /** The mesh that is currently pointed at (can be null) */
  24582. meshUnderPointer: Nullable<AbstractMesh>;
  24583. /** the original (browser) event that triggered the ActionEvent */
  24584. sourceEvent?: any;
  24585. /** additional data for the event */
  24586. additionalData?: any;
  24587. }
  24588. /**
  24589. * ActionEvent is the event being sent when an action is triggered.
  24590. */
  24591. export class ActionEvent implements IActionEvent {
  24592. /** The mesh or sprite that triggered the action */
  24593. source: any;
  24594. /** The X mouse cursor position at the time of the event */
  24595. pointerX: number;
  24596. /** The Y mouse cursor position at the time of the event */
  24597. pointerY: number;
  24598. /** The mesh that is currently pointed at (can be null) */
  24599. meshUnderPointer: Nullable<AbstractMesh>;
  24600. /** the original (browser) event that triggered the ActionEvent */
  24601. sourceEvent?: any;
  24602. /** additional data for the event */
  24603. additionalData?: any;
  24604. /**
  24605. * Creates a new ActionEvent
  24606. * @param source The mesh or sprite that triggered the action
  24607. * @param pointerX The X mouse cursor position at the time of the event
  24608. * @param pointerY The Y mouse cursor position at the time of the event
  24609. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24610. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24611. * @param additionalData additional data for the event
  24612. */
  24613. constructor(
  24614. /** The mesh or sprite that triggered the action */
  24615. source: any,
  24616. /** The X mouse cursor position at the time of the event */
  24617. pointerX: number,
  24618. /** The Y mouse cursor position at the time of the event */
  24619. pointerY: number,
  24620. /** The mesh that is currently pointed at (can be null) */
  24621. meshUnderPointer: Nullable<AbstractMesh>,
  24622. /** the original (browser) event that triggered the ActionEvent */
  24623. sourceEvent?: any,
  24624. /** additional data for the event */
  24625. additionalData?: any);
  24626. /**
  24627. * Helper function to auto-create an ActionEvent from a source mesh.
  24628. * @param source The source mesh that triggered the event
  24629. * @param evt The original (browser) event
  24630. * @param additionalData additional data for the event
  24631. * @returns the new ActionEvent
  24632. */
  24633. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24634. /**
  24635. * Helper function to auto-create an ActionEvent from a source sprite
  24636. * @param source The source sprite that triggered the event
  24637. * @param scene Scene associated with the sprite
  24638. * @param evt The original (browser) event
  24639. * @param additionalData additional data for the event
  24640. * @returns the new ActionEvent
  24641. */
  24642. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24643. /**
  24644. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24645. * @param scene the scene where the event occurred
  24646. * @param evt The original (browser) event
  24647. * @returns the new ActionEvent
  24648. */
  24649. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24650. /**
  24651. * Helper function to auto-create an ActionEvent from a primitive
  24652. * @param prim defines the target primitive
  24653. * @param pointerPos defines the pointer position
  24654. * @param evt The original (browser) event
  24655. * @param additionalData additional data for the event
  24656. * @returns the new ActionEvent
  24657. */
  24658. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24659. }
  24660. }
  24661. declare module "babylonjs/Actions/abstractActionManager" {
  24662. import { IDisposable } from "babylonjs/scene";
  24663. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24664. import { IAction } from "babylonjs/Actions/action";
  24665. /**
  24666. * Abstract class used to decouple action Manager from scene and meshes.
  24667. * Do not instantiate.
  24668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24669. */
  24670. export abstract class AbstractActionManager implements IDisposable {
  24671. /** Gets the list of active triggers */
  24672. static Triggers: {
  24673. [key: string]: number;
  24674. };
  24675. /** Gets the cursor to use when hovering items */
  24676. hoverCursor: string;
  24677. /** Gets the list of actions */
  24678. actions: IAction[];
  24679. /**
  24680. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24681. */
  24682. isRecursive: boolean;
  24683. /**
  24684. * Releases all associated resources
  24685. */
  24686. abstract dispose(): void;
  24687. /**
  24688. * Does this action manager has pointer triggers
  24689. */
  24690. abstract readonly hasPointerTriggers: boolean;
  24691. /**
  24692. * Does this action manager has pick triggers
  24693. */
  24694. abstract readonly hasPickTriggers: boolean;
  24695. /**
  24696. * Process a specific trigger
  24697. * @param trigger defines the trigger to process
  24698. * @param evt defines the event details to be processed
  24699. */
  24700. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24701. /**
  24702. * Does this action manager handles actions of any of the given triggers
  24703. * @param triggers defines the triggers to be tested
  24704. * @return a boolean indicating whether one (or more) of the triggers is handled
  24705. */
  24706. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24707. /**
  24708. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24709. * speed.
  24710. * @param triggerA defines the trigger to be tested
  24711. * @param triggerB defines the trigger to be tested
  24712. * @return a boolean indicating whether one (or more) of the triggers is handled
  24713. */
  24714. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24715. /**
  24716. * Does this action manager handles actions of a given trigger
  24717. * @param trigger defines the trigger to be tested
  24718. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24719. * @return whether the trigger is handled
  24720. */
  24721. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24722. /**
  24723. * Serialize this manager to a JSON object
  24724. * @param name defines the property name to store this manager
  24725. * @returns a JSON representation of this manager
  24726. */
  24727. abstract serialize(name: string): any;
  24728. /**
  24729. * Does exist one action manager with at least one trigger
  24730. **/
  24731. static readonly HasTriggers: boolean;
  24732. /**
  24733. * Does exist one action manager with at least one pick trigger
  24734. **/
  24735. static readonly HasPickTriggers: boolean;
  24736. /**
  24737. * Does exist one action manager that handles actions of a given trigger
  24738. * @param trigger defines the trigger to be tested
  24739. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24740. **/
  24741. static HasSpecificTrigger(trigger: number): boolean;
  24742. }
  24743. }
  24744. declare module "babylonjs/node" {
  24745. import { Scene } from "babylonjs/scene";
  24746. import { Nullable } from "babylonjs/types";
  24747. import { Matrix } from "babylonjs/Maths/math";
  24748. import { Engine } from "babylonjs/Engines/engine";
  24749. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24750. import { Observable } from "babylonjs/Misc/observable";
  24751. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24752. import { Animatable } from "babylonjs/Animations/animatable";
  24753. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24754. import { Animation } from "babylonjs/Animations/animation";
  24755. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24757. /**
  24758. * Defines how a node can be built from a string name.
  24759. */
  24760. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24761. /**
  24762. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24763. */
  24764. export class Node implements IBehaviorAware<Node> {
  24765. /** @hidden */
  24766. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24767. private static _NodeConstructors;
  24768. /**
  24769. * Add a new node constructor
  24770. * @param type defines the type name of the node to construct
  24771. * @param constructorFunc defines the constructor function
  24772. */
  24773. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24774. /**
  24775. * Returns a node constructor based on type name
  24776. * @param type defines the type name
  24777. * @param name defines the new node name
  24778. * @param scene defines the hosting scene
  24779. * @param options defines optional options to transmit to constructors
  24780. * @returns the new constructor or null
  24781. */
  24782. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24783. /**
  24784. * Gets or sets the name of the node
  24785. */
  24786. name: string;
  24787. /**
  24788. * Gets or sets the id of the node
  24789. */
  24790. id: string;
  24791. /**
  24792. * Gets or sets the unique id of the node
  24793. */
  24794. uniqueId: number;
  24795. /**
  24796. * Gets or sets a string used to store user defined state for the node
  24797. */
  24798. state: string;
  24799. /**
  24800. * Gets or sets an object used to store user defined information for the node
  24801. */
  24802. metadata: any;
  24803. /**
  24804. * For internal use only. Please do not use.
  24805. */
  24806. reservedDataStore: any;
  24807. /**
  24808. * Gets or sets a boolean used to define if the node must be serialized
  24809. */
  24810. doNotSerialize: boolean;
  24811. /** @hidden */
  24812. _isDisposed: boolean;
  24813. /**
  24814. * Gets a list of Animations associated with the node
  24815. */
  24816. animations: import("babylonjs/Animations/animation").Animation[];
  24817. protected _ranges: {
  24818. [name: string]: Nullable<AnimationRange>;
  24819. };
  24820. /**
  24821. * Callback raised when the node is ready to be used
  24822. */
  24823. onReady: (node: Node) => void;
  24824. private _isEnabled;
  24825. private _isParentEnabled;
  24826. private _isReady;
  24827. /** @hidden */
  24828. _currentRenderId: number;
  24829. private _parentRenderId;
  24830. protected _childRenderId: number;
  24831. /** @hidden */
  24832. _waitingParentId: Nullable<string>;
  24833. /** @hidden */
  24834. _scene: Scene;
  24835. /** @hidden */
  24836. _cache: any;
  24837. private _parentNode;
  24838. private _children;
  24839. /** @hidden */
  24840. _worldMatrix: Matrix;
  24841. /** @hidden */
  24842. _worldMatrixDeterminant: number;
  24843. /** @hidden */
  24844. private _sceneRootNodesIndex;
  24845. /**
  24846. * Gets a boolean indicating if the node has been disposed
  24847. * @returns true if the node was disposed
  24848. */
  24849. isDisposed(): boolean;
  24850. /**
  24851. * Gets or sets the parent of the node
  24852. */
  24853. parent: Nullable<Node>;
  24854. private addToSceneRootNodes;
  24855. private removeFromSceneRootNodes;
  24856. private _animationPropertiesOverride;
  24857. /**
  24858. * Gets or sets the animation properties override
  24859. */
  24860. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24861. /**
  24862. * Gets a string idenfifying the name of the class
  24863. * @returns "Node" string
  24864. */
  24865. getClassName(): string;
  24866. /** @hidden */
  24867. readonly _isNode: boolean;
  24868. /**
  24869. * An event triggered when the mesh is disposed
  24870. */
  24871. onDisposeObservable: Observable<Node>;
  24872. private _onDisposeObserver;
  24873. /**
  24874. * Sets a callback that will be raised when the node will be disposed
  24875. */
  24876. onDispose: () => void;
  24877. /**
  24878. * Creates a new Node
  24879. * @param name the name and id to be given to this node
  24880. * @param scene the scene this node will be added to
  24881. * @param addToRootNodes the node will be added to scene.rootNodes
  24882. */
  24883. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24884. /**
  24885. * Gets the scene of the node
  24886. * @returns a scene
  24887. */
  24888. getScene(): Scene;
  24889. /**
  24890. * Gets the engine of the node
  24891. * @returns a Engine
  24892. */
  24893. getEngine(): Engine;
  24894. private _behaviors;
  24895. /**
  24896. * Attach a behavior to the node
  24897. * @see http://doc.babylonjs.com/features/behaviour
  24898. * @param behavior defines the behavior to attach
  24899. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24900. * @returns the current Node
  24901. */
  24902. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24903. /**
  24904. * Remove an attached behavior
  24905. * @see http://doc.babylonjs.com/features/behaviour
  24906. * @param behavior defines the behavior to attach
  24907. * @returns the current Node
  24908. */
  24909. removeBehavior(behavior: Behavior<Node>): Node;
  24910. /**
  24911. * Gets the list of attached behaviors
  24912. * @see http://doc.babylonjs.com/features/behaviour
  24913. */
  24914. readonly behaviors: Behavior<Node>[];
  24915. /**
  24916. * Gets an attached behavior by name
  24917. * @param name defines the name of the behavior to look for
  24918. * @see http://doc.babylonjs.com/features/behaviour
  24919. * @returns null if behavior was not found else the requested behavior
  24920. */
  24921. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24922. /**
  24923. * Returns the latest update of the World matrix
  24924. * @returns a Matrix
  24925. */
  24926. getWorldMatrix(): Matrix;
  24927. /** @hidden */
  24928. _getWorldMatrixDeterminant(): number;
  24929. /**
  24930. * Returns directly the latest state of the mesh World matrix.
  24931. * A Matrix is returned.
  24932. */
  24933. readonly worldMatrixFromCache: Matrix;
  24934. /** @hidden */
  24935. _initCache(): void;
  24936. /** @hidden */
  24937. updateCache(force?: boolean): void;
  24938. /** @hidden */
  24939. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24940. /** @hidden */
  24941. _updateCache(ignoreParentClass?: boolean): void;
  24942. /** @hidden */
  24943. _isSynchronized(): boolean;
  24944. /** @hidden */
  24945. _markSyncedWithParent(): void;
  24946. /** @hidden */
  24947. isSynchronizedWithParent(): boolean;
  24948. /** @hidden */
  24949. isSynchronized(): boolean;
  24950. /**
  24951. * Is this node ready to be used/rendered
  24952. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24953. * @return true if the node is ready
  24954. */
  24955. isReady(completeCheck?: boolean): boolean;
  24956. /**
  24957. * Is this node enabled?
  24958. * 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
  24959. * @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
  24960. * @return whether this node (and its parent) is enabled
  24961. */
  24962. isEnabled(checkAncestors?: boolean): boolean;
  24963. /** @hidden */
  24964. protected _syncParentEnabledState(): void;
  24965. /**
  24966. * Set the enabled state of this node
  24967. * @param value defines the new enabled state
  24968. */
  24969. setEnabled(value: boolean): void;
  24970. /**
  24971. * Is this node a descendant of the given node?
  24972. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24973. * @param ancestor defines the parent node to inspect
  24974. * @returns a boolean indicating if this node is a descendant of the given node
  24975. */
  24976. isDescendantOf(ancestor: Node): boolean;
  24977. /** @hidden */
  24978. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24979. /**
  24980. * Will return all nodes that have this node as ascendant
  24981. * @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
  24982. * @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
  24983. * @return all children nodes of all types
  24984. */
  24985. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24986. /**
  24987. * Get all child-meshes of this node
  24988. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  24989. * @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
  24990. * @returns an array of AbstractMesh
  24991. */
  24992. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24993. /**
  24994. * Get all direct children of this node
  24995. * @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
  24996. * @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)
  24997. * @returns an array of Node
  24998. */
  24999. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25000. /** @hidden */
  25001. _setReady(state: boolean): void;
  25002. /**
  25003. * Get an animation by name
  25004. * @param name defines the name of the animation to look for
  25005. * @returns null if not found else the requested animation
  25006. */
  25007. getAnimationByName(name: string): Nullable<Animation>;
  25008. /**
  25009. * Creates an animation range for this node
  25010. * @param name defines the name of the range
  25011. * @param from defines the starting key
  25012. * @param to defines the end key
  25013. */
  25014. createAnimationRange(name: string, from: number, to: number): void;
  25015. /**
  25016. * Delete a specific animation range
  25017. * @param name defines the name of the range to delete
  25018. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25019. */
  25020. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25021. /**
  25022. * Get an animation range by name
  25023. * @param name defines the name of the animation range to look for
  25024. * @returns null if not found else the requested animation range
  25025. */
  25026. getAnimationRange(name: string): Nullable<AnimationRange>;
  25027. /**
  25028. * Gets the list of all animation ranges defined on this node
  25029. * @returns an array
  25030. */
  25031. getAnimationRanges(): Nullable<AnimationRange>[];
  25032. /**
  25033. * Will start the animation sequence
  25034. * @param name defines the range frames for animation sequence
  25035. * @param loop defines if the animation should loop (false by default)
  25036. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25037. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25038. * @returns the object created for this animation. If range does not exist, it will return null
  25039. */
  25040. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25041. /**
  25042. * Serialize animation ranges into a JSON compatible object
  25043. * @returns serialization object
  25044. */
  25045. serializeAnimationRanges(): any;
  25046. /**
  25047. * Computes the world matrix of the node
  25048. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25049. * @returns the world matrix
  25050. */
  25051. computeWorldMatrix(force?: boolean): Matrix;
  25052. /**
  25053. * Releases resources associated with this node.
  25054. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25055. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25056. */
  25057. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25058. /**
  25059. * Parse animation range data from a serialization object and store them into a given node
  25060. * @param node defines where to store the animation ranges
  25061. * @param parsedNode defines the serialization object to read data from
  25062. * @param scene defines the hosting scene
  25063. */
  25064. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25065. }
  25066. }
  25067. declare module "babylonjs/Animations/animation" {
  25068. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25069. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25070. import { Nullable } from "babylonjs/types";
  25071. import { Scene } from "babylonjs/scene";
  25072. import { IAnimatable } from "babylonjs/Misc/tools";
  25073. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25074. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25075. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25076. import { Node } from "babylonjs/node";
  25077. import { Animatable } from "babylonjs/Animations/animatable";
  25078. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25079. /**
  25080. * Class used to store any kind of animation
  25081. */
  25082. export class Animation {
  25083. /**Name of the animation */
  25084. name: string;
  25085. /**Property to animate */
  25086. targetProperty: string;
  25087. /**The frames per second of the animation */
  25088. framePerSecond: number;
  25089. /**The data type of the animation */
  25090. dataType: number;
  25091. /**The loop mode of the animation */
  25092. loopMode?: number | undefined;
  25093. /**Specifies if blending should be enabled */
  25094. enableBlending?: boolean | undefined;
  25095. /**
  25096. * Use matrix interpolation instead of using direct key value when animating matrices
  25097. */
  25098. static AllowMatricesInterpolation: boolean;
  25099. /**
  25100. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25101. */
  25102. static AllowMatrixDecomposeForInterpolation: boolean;
  25103. /**
  25104. * Stores the key frames of the animation
  25105. */
  25106. private _keys;
  25107. /**
  25108. * Stores the easing function of the animation
  25109. */
  25110. private _easingFunction;
  25111. /**
  25112. * @hidden Internal use only
  25113. */
  25114. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25115. /**
  25116. * The set of event that will be linked to this animation
  25117. */
  25118. private _events;
  25119. /**
  25120. * Stores an array of target property paths
  25121. */
  25122. targetPropertyPath: string[];
  25123. /**
  25124. * Stores the blending speed of the animation
  25125. */
  25126. blendingSpeed: number;
  25127. /**
  25128. * Stores the animation ranges for the animation
  25129. */
  25130. private _ranges;
  25131. /**
  25132. * @hidden Internal use
  25133. */
  25134. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25135. /**
  25136. * Sets up an animation
  25137. * @param property The property to animate
  25138. * @param animationType The animation type to apply
  25139. * @param framePerSecond The frames per second of the animation
  25140. * @param easingFunction The easing function used in the animation
  25141. * @returns The created animation
  25142. */
  25143. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25144. /**
  25145. * Create and start an animation on a node
  25146. * @param name defines the name of the global animation that will be run on all nodes
  25147. * @param node defines the root node where the animation will take place
  25148. * @param targetProperty defines property to animate
  25149. * @param framePerSecond defines the number of frame per second yo use
  25150. * @param totalFrame defines the number of frames in total
  25151. * @param from defines the initial value
  25152. * @param to defines the final value
  25153. * @param loopMode defines which loop mode you want to use (off by default)
  25154. * @param easingFunction defines the easing function to use (linear by default)
  25155. * @param onAnimationEnd defines the callback to call when animation end
  25156. * @returns the animatable created for this animation
  25157. */
  25158. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25159. /**
  25160. * Create and start an animation on a node and its descendants
  25161. * @param name defines the name of the global animation that will be run on all nodes
  25162. * @param node defines the root node where the animation will take place
  25163. * @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
  25164. * @param targetProperty defines property to animate
  25165. * @param framePerSecond defines the number of frame per second to use
  25166. * @param totalFrame defines the number of frames in total
  25167. * @param from defines the initial value
  25168. * @param to defines the final value
  25169. * @param loopMode defines which loop mode you want to use (off by default)
  25170. * @param easingFunction defines the easing function to use (linear by default)
  25171. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25172. * @returns the list of animatables created for all nodes
  25173. * @example https://www.babylonjs-playground.com/#MH0VLI
  25174. */
  25175. 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[]>;
  25176. /**
  25177. * Creates a new animation, merges it with the existing animations and starts it
  25178. * @param name Name of the animation
  25179. * @param node Node which contains the scene that begins the animations
  25180. * @param targetProperty Specifies which property to animate
  25181. * @param framePerSecond The frames per second of the animation
  25182. * @param totalFrame The total number of frames
  25183. * @param from The frame at the beginning of the animation
  25184. * @param to The frame at the end of the animation
  25185. * @param loopMode Specifies the loop mode of the animation
  25186. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25187. * @param onAnimationEnd Callback to run once the animation is complete
  25188. * @returns Nullable animation
  25189. */
  25190. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25191. /**
  25192. * Transition property of an host to the target Value
  25193. * @param property The property to transition
  25194. * @param targetValue The target Value of the property
  25195. * @param host The object where the property to animate belongs
  25196. * @param scene Scene used to run the animation
  25197. * @param frameRate Framerate (in frame/s) to use
  25198. * @param transition The transition type we want to use
  25199. * @param duration The duration of the animation, in milliseconds
  25200. * @param onAnimationEnd Callback trigger at the end of the animation
  25201. * @returns Nullable animation
  25202. */
  25203. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25204. /**
  25205. * Return the array of runtime animations currently using this animation
  25206. */
  25207. readonly runtimeAnimations: RuntimeAnimation[];
  25208. /**
  25209. * Specifies if any of the runtime animations are currently running
  25210. */
  25211. readonly hasRunningRuntimeAnimations: boolean;
  25212. /**
  25213. * Initializes the animation
  25214. * @param name Name of the animation
  25215. * @param targetProperty Property to animate
  25216. * @param framePerSecond The frames per second of the animation
  25217. * @param dataType The data type of the animation
  25218. * @param loopMode The loop mode of the animation
  25219. * @param enableBlending Specifies if blending should be enabled
  25220. */
  25221. constructor(
  25222. /**Name of the animation */
  25223. name: string,
  25224. /**Property to animate */
  25225. targetProperty: string,
  25226. /**The frames per second of the animation */
  25227. framePerSecond: number,
  25228. /**The data type of the animation */
  25229. dataType: number,
  25230. /**The loop mode of the animation */
  25231. loopMode?: number | undefined,
  25232. /**Specifies if blending should be enabled */
  25233. enableBlending?: boolean | undefined);
  25234. /**
  25235. * Converts the animation to a string
  25236. * @param fullDetails support for multiple levels of logging within scene loading
  25237. * @returns String form of the animation
  25238. */
  25239. toString(fullDetails?: boolean): string;
  25240. /**
  25241. * Add an event to this animation
  25242. * @param event Event to add
  25243. */
  25244. addEvent(event: AnimationEvent): void;
  25245. /**
  25246. * Remove all events found at the given frame
  25247. * @param frame The frame to remove events from
  25248. */
  25249. removeEvents(frame: number): void;
  25250. /**
  25251. * Retrieves all the events from the animation
  25252. * @returns Events from the animation
  25253. */
  25254. getEvents(): AnimationEvent[];
  25255. /**
  25256. * Creates an animation range
  25257. * @param name Name of the animation range
  25258. * @param from Starting frame of the animation range
  25259. * @param to Ending frame of the animation
  25260. */
  25261. createRange(name: string, from: number, to: number): void;
  25262. /**
  25263. * Deletes an animation range by name
  25264. * @param name Name of the animation range to delete
  25265. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25266. */
  25267. deleteRange(name: string, deleteFrames?: boolean): void;
  25268. /**
  25269. * Gets the animation range by name, or null if not defined
  25270. * @param name Name of the animation range
  25271. * @returns Nullable animation range
  25272. */
  25273. getRange(name: string): Nullable<AnimationRange>;
  25274. /**
  25275. * Gets the key frames from the animation
  25276. * @returns The key frames of the animation
  25277. */
  25278. getKeys(): Array<IAnimationKey>;
  25279. /**
  25280. * Gets the highest frame rate of the animation
  25281. * @returns Highest frame rate of the animation
  25282. */
  25283. getHighestFrame(): number;
  25284. /**
  25285. * Gets the easing function of the animation
  25286. * @returns Easing function of the animation
  25287. */
  25288. getEasingFunction(): IEasingFunction;
  25289. /**
  25290. * Sets the easing function of the animation
  25291. * @param easingFunction A custom mathematical formula for animation
  25292. */
  25293. setEasingFunction(easingFunction: EasingFunction): void;
  25294. /**
  25295. * Interpolates a scalar linearly
  25296. * @param startValue Start value of the animation curve
  25297. * @param endValue End value of the animation curve
  25298. * @param gradient Scalar amount to interpolate
  25299. * @returns Interpolated scalar value
  25300. */
  25301. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25302. /**
  25303. * Interpolates a scalar cubically
  25304. * @param startValue Start value of the animation curve
  25305. * @param outTangent End tangent of the animation
  25306. * @param endValue End value of the animation curve
  25307. * @param inTangent Start tangent of the animation curve
  25308. * @param gradient Scalar amount to interpolate
  25309. * @returns Interpolated scalar value
  25310. */
  25311. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25312. /**
  25313. * Interpolates a quaternion using a spherical linear interpolation
  25314. * @param startValue Start value of the animation curve
  25315. * @param endValue End value of the animation curve
  25316. * @param gradient Scalar amount to interpolate
  25317. * @returns Interpolated quaternion value
  25318. */
  25319. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25320. /**
  25321. * Interpolates a quaternion cubically
  25322. * @param startValue Start value of the animation curve
  25323. * @param outTangent End tangent of the animation curve
  25324. * @param endValue End value of the animation curve
  25325. * @param inTangent Start tangent of the animation curve
  25326. * @param gradient Scalar amount to interpolate
  25327. * @returns Interpolated quaternion value
  25328. */
  25329. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25330. /**
  25331. * Interpolates a Vector3 linearl
  25332. * @param startValue Start value of the animation curve
  25333. * @param endValue End value of the animation curve
  25334. * @param gradient Scalar amount to interpolate
  25335. * @returns Interpolated scalar value
  25336. */
  25337. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25338. /**
  25339. * Interpolates a Vector3 cubically
  25340. * @param startValue Start value of the animation curve
  25341. * @param outTangent End tangent of the animation
  25342. * @param endValue End value of the animation curve
  25343. * @param inTangent Start tangent of the animation curve
  25344. * @param gradient Scalar amount to interpolate
  25345. * @returns InterpolatedVector3 value
  25346. */
  25347. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25348. /**
  25349. * Interpolates a Vector2 linearly
  25350. * @param startValue Start value of the animation curve
  25351. * @param endValue End value of the animation curve
  25352. * @param gradient Scalar amount to interpolate
  25353. * @returns Interpolated Vector2 value
  25354. */
  25355. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25356. /**
  25357. * Interpolates a Vector2 cubically
  25358. * @param startValue Start value of the animation curve
  25359. * @param outTangent End tangent of the animation
  25360. * @param endValue End value of the animation curve
  25361. * @param inTangent Start tangent of the animation curve
  25362. * @param gradient Scalar amount to interpolate
  25363. * @returns Interpolated Vector2 value
  25364. */
  25365. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25366. /**
  25367. * Interpolates a size linearly
  25368. * @param startValue Start value of the animation curve
  25369. * @param endValue End value of the animation curve
  25370. * @param gradient Scalar amount to interpolate
  25371. * @returns Interpolated Size value
  25372. */
  25373. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25374. /**
  25375. * Interpolates a Color3 linearly
  25376. * @param startValue Start value of the animation curve
  25377. * @param endValue End value of the animation curve
  25378. * @param gradient Scalar amount to interpolate
  25379. * @returns Interpolated Color3 value
  25380. */
  25381. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25382. /**
  25383. * @hidden Internal use only
  25384. */
  25385. _getKeyValue(value: any): any;
  25386. /**
  25387. * @hidden Internal use only
  25388. */
  25389. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25390. /**
  25391. * Defines the function to use to interpolate matrices
  25392. * @param startValue defines the start matrix
  25393. * @param endValue defines the end matrix
  25394. * @param gradient defines the gradient between both matrices
  25395. * @param result defines an optional target matrix where to store the interpolation
  25396. * @returns the interpolated matrix
  25397. */
  25398. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25399. /**
  25400. * Makes a copy of the animation
  25401. * @returns Cloned animation
  25402. */
  25403. clone(): Animation;
  25404. /**
  25405. * Sets the key frames of the animation
  25406. * @param values The animation key frames to set
  25407. */
  25408. setKeys(values: Array<IAnimationKey>): void;
  25409. /**
  25410. * Serializes the animation to an object
  25411. * @returns Serialized object
  25412. */
  25413. serialize(): any;
  25414. /**
  25415. * Float animation type
  25416. */
  25417. private static _ANIMATIONTYPE_FLOAT;
  25418. /**
  25419. * Vector3 animation type
  25420. */
  25421. private static _ANIMATIONTYPE_VECTOR3;
  25422. /**
  25423. * Quaternion animation type
  25424. */
  25425. private static _ANIMATIONTYPE_QUATERNION;
  25426. /**
  25427. * Matrix animation type
  25428. */
  25429. private static _ANIMATIONTYPE_MATRIX;
  25430. /**
  25431. * Color3 animation type
  25432. */
  25433. private static _ANIMATIONTYPE_COLOR3;
  25434. /**
  25435. * Vector2 animation type
  25436. */
  25437. private static _ANIMATIONTYPE_VECTOR2;
  25438. /**
  25439. * Size animation type
  25440. */
  25441. private static _ANIMATIONTYPE_SIZE;
  25442. /**
  25443. * Relative Loop Mode
  25444. */
  25445. private static _ANIMATIONLOOPMODE_RELATIVE;
  25446. /**
  25447. * Cycle Loop Mode
  25448. */
  25449. private static _ANIMATIONLOOPMODE_CYCLE;
  25450. /**
  25451. * Constant Loop Mode
  25452. */
  25453. private static _ANIMATIONLOOPMODE_CONSTANT;
  25454. /**
  25455. * Get the float animation type
  25456. */
  25457. static readonly ANIMATIONTYPE_FLOAT: number;
  25458. /**
  25459. * Get the Vector3 animation type
  25460. */
  25461. static readonly ANIMATIONTYPE_VECTOR3: number;
  25462. /**
  25463. * Get the Vector2 animation type
  25464. */
  25465. static readonly ANIMATIONTYPE_VECTOR2: number;
  25466. /**
  25467. * Get the Size animation type
  25468. */
  25469. static readonly ANIMATIONTYPE_SIZE: number;
  25470. /**
  25471. * Get the Quaternion animation type
  25472. */
  25473. static readonly ANIMATIONTYPE_QUATERNION: number;
  25474. /**
  25475. * Get the Matrix animation type
  25476. */
  25477. static readonly ANIMATIONTYPE_MATRIX: number;
  25478. /**
  25479. * Get the Color3 animation type
  25480. */
  25481. static readonly ANIMATIONTYPE_COLOR3: number;
  25482. /**
  25483. * Get the Relative Loop Mode
  25484. */
  25485. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25486. /**
  25487. * Get the Cycle Loop Mode
  25488. */
  25489. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25490. /**
  25491. * Get the Constant Loop Mode
  25492. */
  25493. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25494. /** @hidden */
  25495. static _UniversalLerp(left: any, right: any, amount: number): any;
  25496. /**
  25497. * Parses an animation object and creates an animation
  25498. * @param parsedAnimation Parsed animation object
  25499. * @returns Animation object
  25500. */
  25501. static Parse(parsedAnimation: any): Animation;
  25502. /**
  25503. * Appends the serialized animations from the source animations
  25504. * @param source Source containing the animations
  25505. * @param destination Target to store the animations
  25506. */
  25507. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25508. }
  25509. }
  25510. declare module "babylonjs/Materials/Textures/baseTexture" {
  25511. import { Observable } from "babylonjs/Misc/observable";
  25512. import { IAnimatable } from "babylonjs/Misc/tools";
  25513. import { Nullable } from "babylonjs/types";
  25514. import { Scene } from "babylonjs/scene";
  25515. import { Matrix, ISize } from "babylonjs/Maths/math";
  25516. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25517. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25518. /**
  25519. * Base class of all the textures in babylon.
  25520. * It groups all the common properties the materials, post process, lights... might need
  25521. * in order to make a correct use of the texture.
  25522. */
  25523. export class BaseTexture implements IAnimatable {
  25524. /**
  25525. * Default anisotropic filtering level for the application.
  25526. * It is set to 4 as a good tradeoff between perf and quality.
  25527. */
  25528. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25529. /**
  25530. * Gets or sets the unique id of the texture
  25531. */
  25532. uniqueId: number;
  25533. /**
  25534. * Define the name of the texture.
  25535. */
  25536. name: string;
  25537. /**
  25538. * Gets or sets an object used to store user defined information.
  25539. */
  25540. metadata: any;
  25541. /**
  25542. * For internal use only. Please do not use.
  25543. */
  25544. reservedDataStore: any;
  25545. private _hasAlpha;
  25546. /**
  25547. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25548. */
  25549. hasAlpha: boolean;
  25550. /**
  25551. * Defines if the alpha value should be determined via the rgb values.
  25552. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25553. */
  25554. getAlphaFromRGB: boolean;
  25555. /**
  25556. * Intensity or strength of the texture.
  25557. * It is commonly used by materials to fine tune the intensity of the texture
  25558. */
  25559. level: number;
  25560. /**
  25561. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25562. * This is part of the texture as textures usually maps to one uv set.
  25563. */
  25564. coordinatesIndex: number;
  25565. private _coordinatesMode;
  25566. /**
  25567. * How a texture is mapped.
  25568. *
  25569. * | Value | Type | Description |
  25570. * | ----- | ----------------------------------- | ----------- |
  25571. * | 0 | EXPLICIT_MODE | |
  25572. * | 1 | SPHERICAL_MODE | |
  25573. * | 2 | PLANAR_MODE | |
  25574. * | 3 | CUBIC_MODE | |
  25575. * | 4 | PROJECTION_MODE | |
  25576. * | 5 | SKYBOX_MODE | |
  25577. * | 6 | INVCUBIC_MODE | |
  25578. * | 7 | EQUIRECTANGULAR_MODE | |
  25579. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25580. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25581. */
  25582. coordinatesMode: number;
  25583. /**
  25584. * | Value | Type | Description |
  25585. * | ----- | ------------------ | ----------- |
  25586. * | 0 | CLAMP_ADDRESSMODE | |
  25587. * | 1 | WRAP_ADDRESSMODE | |
  25588. * | 2 | MIRROR_ADDRESSMODE | |
  25589. */
  25590. wrapU: number;
  25591. /**
  25592. * | Value | Type | Description |
  25593. * | ----- | ------------------ | ----------- |
  25594. * | 0 | CLAMP_ADDRESSMODE | |
  25595. * | 1 | WRAP_ADDRESSMODE | |
  25596. * | 2 | MIRROR_ADDRESSMODE | |
  25597. */
  25598. wrapV: number;
  25599. /**
  25600. * | Value | Type | Description |
  25601. * | ----- | ------------------ | ----------- |
  25602. * | 0 | CLAMP_ADDRESSMODE | |
  25603. * | 1 | WRAP_ADDRESSMODE | |
  25604. * | 2 | MIRROR_ADDRESSMODE | |
  25605. */
  25606. wrapR: number;
  25607. /**
  25608. * With compliant hardware and browser (supporting anisotropic filtering)
  25609. * this defines the level of anisotropic filtering in the texture.
  25610. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25611. */
  25612. anisotropicFilteringLevel: number;
  25613. /**
  25614. * Define if the texture is a cube texture or if false a 2d texture.
  25615. */
  25616. isCube: boolean;
  25617. /**
  25618. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25619. */
  25620. is3D: boolean;
  25621. /**
  25622. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25623. * HDR texture are usually stored in linear space.
  25624. * This only impacts the PBR and Background materials
  25625. */
  25626. gammaSpace: boolean;
  25627. /**
  25628. * Gets whether or not the texture contains RGBD data.
  25629. */
  25630. readonly isRGBD: boolean;
  25631. /**
  25632. * Is Z inverted in the texture (useful in a cube texture).
  25633. */
  25634. invertZ: boolean;
  25635. /**
  25636. * Are mip maps generated for this texture or not.
  25637. */
  25638. readonly noMipmap: boolean;
  25639. /**
  25640. * @hidden
  25641. */
  25642. lodLevelInAlpha: boolean;
  25643. /**
  25644. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25645. */
  25646. lodGenerationOffset: number;
  25647. /**
  25648. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25649. */
  25650. lodGenerationScale: number;
  25651. /**
  25652. * Define if the texture is a render target.
  25653. */
  25654. isRenderTarget: boolean;
  25655. /**
  25656. * Define the unique id of the texture in the scene.
  25657. */
  25658. readonly uid: string;
  25659. /**
  25660. * Return a string representation of the texture.
  25661. * @returns the texture as a string
  25662. */
  25663. toString(): string;
  25664. /**
  25665. * Get the class name of the texture.
  25666. * @returns "BaseTexture"
  25667. */
  25668. getClassName(): string;
  25669. /**
  25670. * Define the list of animation attached to the texture.
  25671. */
  25672. animations: import("babylonjs/Animations/animation").Animation[];
  25673. /**
  25674. * An event triggered when the texture is disposed.
  25675. */
  25676. onDisposeObservable: Observable<BaseTexture>;
  25677. private _onDisposeObserver;
  25678. /**
  25679. * Callback triggered when the texture has been disposed.
  25680. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25681. */
  25682. onDispose: () => void;
  25683. /**
  25684. * Define the current state of the loading sequence when in delayed load mode.
  25685. */
  25686. delayLoadState: number;
  25687. private _scene;
  25688. /** @hidden */
  25689. _texture: Nullable<InternalTexture>;
  25690. private _uid;
  25691. /**
  25692. * Define if the texture is preventinga material to render or not.
  25693. * If not and the texture is not ready, the engine will use a default black texture instead.
  25694. */
  25695. readonly isBlocking: boolean;
  25696. /**
  25697. * Instantiates a new BaseTexture.
  25698. * Base class of all the textures in babylon.
  25699. * It groups all the common properties the materials, post process, lights... might need
  25700. * in order to make a correct use of the texture.
  25701. * @param scene Define the scene the texture blongs to
  25702. */
  25703. constructor(scene: Nullable<Scene>);
  25704. /**
  25705. * Get the scene the texture belongs to.
  25706. * @returns the scene or null if undefined
  25707. */
  25708. getScene(): Nullable<Scene>;
  25709. /**
  25710. * Get the texture transform matrix used to offset tile the texture for istance.
  25711. * @returns the transformation matrix
  25712. */
  25713. getTextureMatrix(): Matrix;
  25714. /**
  25715. * Get the texture reflection matrix used to rotate/transform the reflection.
  25716. * @returns the reflection matrix
  25717. */
  25718. getReflectionTextureMatrix(): Matrix;
  25719. /**
  25720. * Get the underlying lower level texture from Babylon.
  25721. * @returns the insternal texture
  25722. */
  25723. getInternalTexture(): Nullable<InternalTexture>;
  25724. /**
  25725. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25726. * @returns true if ready or not blocking
  25727. */
  25728. isReadyOrNotBlocking(): boolean;
  25729. /**
  25730. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25731. * @returns true if fully ready
  25732. */
  25733. isReady(): boolean;
  25734. private _cachedSize;
  25735. /**
  25736. * Get the size of the texture.
  25737. * @returns the texture size.
  25738. */
  25739. getSize(): ISize;
  25740. /**
  25741. * Get the base size of the texture.
  25742. * It can be different from the size if the texture has been resized for POT for instance
  25743. * @returns the base size
  25744. */
  25745. getBaseSize(): ISize;
  25746. /**
  25747. * Update the sampling mode of the texture.
  25748. * Default is Trilinear mode.
  25749. *
  25750. * | Value | Type | Description |
  25751. * | ----- | ------------------ | ----------- |
  25752. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25753. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25754. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25755. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25756. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25757. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25758. * | 7 | NEAREST_LINEAR | |
  25759. * | 8 | NEAREST_NEAREST | |
  25760. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25761. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25762. * | 11 | LINEAR_LINEAR | |
  25763. * | 12 | LINEAR_NEAREST | |
  25764. *
  25765. * > _mag_: magnification filter (close to the viewer)
  25766. * > _min_: minification filter (far from the viewer)
  25767. * > _mip_: filter used between mip map levels
  25768. *@param samplingMode Define the new sampling mode of the texture
  25769. */
  25770. updateSamplingMode(samplingMode: number): void;
  25771. /**
  25772. * Scales the texture if is `canRescale()`
  25773. * @param ratio the resize factor we want to use to rescale
  25774. */
  25775. scale(ratio: number): void;
  25776. /**
  25777. * Get if the texture can rescale.
  25778. */
  25779. readonly canRescale: boolean;
  25780. /** @hidden */
  25781. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25782. /** @hidden */
  25783. _rebuild(): void;
  25784. /**
  25785. * Triggers the load sequence in delayed load mode.
  25786. */
  25787. delayLoad(): void;
  25788. /**
  25789. * Clones the texture.
  25790. * @returns the cloned texture
  25791. */
  25792. clone(): Nullable<BaseTexture>;
  25793. /**
  25794. * Get the texture underlying type (INT, FLOAT...)
  25795. */
  25796. readonly textureType: number;
  25797. /**
  25798. * Get the texture underlying format (RGB, RGBA...)
  25799. */
  25800. readonly textureFormat: number;
  25801. /**
  25802. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25803. * This will returns an RGBA array buffer containing either in values (0-255) or
  25804. * float values (0-1) depending of the underlying buffer type.
  25805. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25806. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25807. * @param buffer defines a user defined buffer to fill with data (can be null)
  25808. * @returns The Array buffer containing the pixels data.
  25809. */
  25810. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25811. /**
  25812. * Release and destroy the underlying lower level texture aka internalTexture.
  25813. */
  25814. releaseInternalTexture(): void;
  25815. /**
  25816. * Get the polynomial representation of the texture data.
  25817. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25818. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25819. */
  25820. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25821. /** @hidden */
  25822. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25823. /** @hidden */
  25824. readonly _lodTextureMid: Nullable<BaseTexture>;
  25825. /** @hidden */
  25826. readonly _lodTextureLow: Nullable<BaseTexture>;
  25827. /**
  25828. * Dispose the texture and release its associated resources.
  25829. */
  25830. dispose(): void;
  25831. /**
  25832. * Serialize the texture into a JSON representation that can be parsed later on.
  25833. * @returns the JSON representation of the texture
  25834. */
  25835. serialize(): any;
  25836. /**
  25837. * Helper function to be called back once a list of texture contains only ready textures.
  25838. * @param textures Define the list of textures to wait for
  25839. * @param callback Define the callback triggered once the entire list will be ready
  25840. */
  25841. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25842. }
  25843. }
  25844. declare module "babylonjs/Materials/uniformBuffer" {
  25845. import { Nullable, FloatArray } from "babylonjs/types";
  25846. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25847. import { Engine } from "babylonjs/Engines/engine";
  25848. import { Effect } from "babylonjs/Materials/effect";
  25849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25850. /**
  25851. * Uniform buffer objects.
  25852. *
  25853. * Handles blocks of uniform on the GPU.
  25854. *
  25855. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25856. *
  25857. * For more information, please refer to :
  25858. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25859. */
  25860. export class UniformBuffer {
  25861. private _engine;
  25862. private _buffer;
  25863. private _data;
  25864. private _bufferData;
  25865. private _dynamic?;
  25866. private _uniformLocations;
  25867. private _uniformSizes;
  25868. private _uniformLocationPointer;
  25869. private _needSync;
  25870. private _noUBO;
  25871. private _currentEffect;
  25872. private static _MAX_UNIFORM_SIZE;
  25873. private static _tempBuffer;
  25874. /**
  25875. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25876. * This is dynamic to allow compat with webgl 1 and 2.
  25877. * You will need to pass the name of the uniform as well as the value.
  25878. */
  25879. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25880. /**
  25881. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25882. * This is dynamic to allow compat with webgl 1 and 2.
  25883. * You will need to pass the name of the uniform as well as the value.
  25884. */
  25885. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25886. /**
  25887. * Lambda to Update a single float in a uniform buffer.
  25888. * This is dynamic to allow compat with webgl 1 and 2.
  25889. * You will need to pass the name of the uniform as well as the value.
  25890. */
  25891. updateFloat: (name: string, x: number) => void;
  25892. /**
  25893. * Lambda to Update a vec2 of float in a uniform buffer.
  25894. * This is dynamic to allow compat with webgl 1 and 2.
  25895. * You will need to pass the name of the uniform as well as the value.
  25896. */
  25897. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25898. /**
  25899. * Lambda to Update a vec3 of float in a uniform buffer.
  25900. * This is dynamic to allow compat with webgl 1 and 2.
  25901. * You will need to pass the name of the uniform as well as the value.
  25902. */
  25903. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25904. /**
  25905. * Lambda to Update a vec4 of float in a uniform buffer.
  25906. * This is dynamic to allow compat with webgl 1 and 2.
  25907. * You will need to pass the name of the uniform as well as the value.
  25908. */
  25909. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25910. /**
  25911. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25912. * This is dynamic to allow compat with webgl 1 and 2.
  25913. * You will need to pass the name of the uniform as well as the value.
  25914. */
  25915. updateMatrix: (name: string, mat: Matrix) => void;
  25916. /**
  25917. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25918. * This is dynamic to allow compat with webgl 1 and 2.
  25919. * You will need to pass the name of the uniform as well as the value.
  25920. */
  25921. updateVector3: (name: string, vector: Vector3) => void;
  25922. /**
  25923. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25924. * This is dynamic to allow compat with webgl 1 and 2.
  25925. * You will need to pass the name of the uniform as well as the value.
  25926. */
  25927. updateVector4: (name: string, vector: Vector4) => void;
  25928. /**
  25929. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25930. * This is dynamic to allow compat with webgl 1 and 2.
  25931. * You will need to pass the name of the uniform as well as the value.
  25932. */
  25933. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25934. /**
  25935. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25936. * This is dynamic to allow compat with webgl 1 and 2.
  25937. * You will need to pass the name of the uniform as well as the value.
  25938. */
  25939. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25940. /**
  25941. * Instantiates a new Uniform buffer objects.
  25942. *
  25943. * Handles blocks of uniform on the GPU.
  25944. *
  25945. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25946. *
  25947. * For more information, please refer to :
  25948. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25949. * @param engine Define the engine the buffer is associated with
  25950. * @param data Define the data contained in the buffer
  25951. * @param dynamic Define if the buffer is updatable
  25952. */
  25953. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25954. /**
  25955. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25956. * or just falling back on setUniformXXX calls.
  25957. */
  25958. readonly useUbo: boolean;
  25959. /**
  25960. * Indicates if the WebGL underlying uniform buffer is in sync
  25961. * with the javascript cache data.
  25962. */
  25963. readonly isSync: boolean;
  25964. /**
  25965. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25966. * Also, a dynamic UniformBuffer will disable cache verification and always
  25967. * update the underlying WebGL uniform buffer to the GPU.
  25968. * @returns if Dynamic, otherwise false
  25969. */
  25970. isDynamic(): boolean;
  25971. /**
  25972. * The data cache on JS side.
  25973. * @returns the underlying data as a float array
  25974. */
  25975. getData(): Float32Array;
  25976. /**
  25977. * The underlying WebGL Uniform buffer.
  25978. * @returns the webgl buffer
  25979. */
  25980. getBuffer(): Nullable<WebGLBuffer>;
  25981. /**
  25982. * std140 layout specifies how to align data within an UBO structure.
  25983. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25984. * for specs.
  25985. */
  25986. private _fillAlignment;
  25987. /**
  25988. * Adds an uniform in the buffer.
  25989. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25990. * for the layout to be correct !
  25991. * @param name Name of the uniform, as used in the uniform block in the shader.
  25992. * @param size Data size, or data directly.
  25993. */
  25994. addUniform(name: string, size: number | number[]): void;
  25995. /**
  25996. * Adds a Matrix 4x4 to the uniform buffer.
  25997. * @param name Name of the uniform, as used in the uniform block in the shader.
  25998. * @param mat A 4x4 matrix.
  25999. */
  26000. addMatrix(name: string, mat: Matrix): void;
  26001. /**
  26002. * Adds a vec2 to the uniform buffer.
  26003. * @param name Name of the uniform, as used in the uniform block in the shader.
  26004. * @param x Define the x component value of the vec2
  26005. * @param y Define the y component value of the vec2
  26006. */
  26007. addFloat2(name: string, x: number, y: number): void;
  26008. /**
  26009. * Adds a vec3 to the uniform buffer.
  26010. * @param name Name of the uniform, as used in the uniform block in the shader.
  26011. * @param x Define the x component value of the vec3
  26012. * @param y Define the y component value of the vec3
  26013. * @param z Define the z component value of the vec3
  26014. */
  26015. addFloat3(name: string, x: number, y: number, z: number): void;
  26016. /**
  26017. * Adds a vec3 to the uniform buffer.
  26018. * @param name Name of the uniform, as used in the uniform block in the shader.
  26019. * @param color Define the vec3 from a Color
  26020. */
  26021. addColor3(name: string, color: Color3): void;
  26022. /**
  26023. * Adds a vec4 to the uniform buffer.
  26024. * @param name Name of the uniform, as used in the uniform block in the shader.
  26025. * @param color Define the rgb components from a Color
  26026. * @param alpha Define the a component of the vec4
  26027. */
  26028. addColor4(name: string, color: Color3, alpha: number): void;
  26029. /**
  26030. * Adds a vec3 to the uniform buffer.
  26031. * @param name Name of the uniform, as used in the uniform block in the shader.
  26032. * @param vector Define the vec3 components from a Vector
  26033. */
  26034. addVector3(name: string, vector: Vector3): void;
  26035. /**
  26036. * Adds a Matrix 3x3 to the uniform buffer.
  26037. * @param name Name of the uniform, as used in the uniform block in the shader.
  26038. */
  26039. addMatrix3x3(name: string): void;
  26040. /**
  26041. * Adds a Matrix 2x2 to the uniform buffer.
  26042. * @param name Name of the uniform, as used in the uniform block in the shader.
  26043. */
  26044. addMatrix2x2(name: string): void;
  26045. /**
  26046. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26047. */
  26048. create(): void;
  26049. /** @hidden */
  26050. _rebuild(): void;
  26051. /**
  26052. * Updates the WebGL Uniform Buffer on the GPU.
  26053. * If the `dynamic` flag is set to true, no cache comparison is done.
  26054. * Otherwise, the buffer will be updated only if the cache differs.
  26055. */
  26056. update(): void;
  26057. /**
  26058. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26059. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26060. * @param data Define the flattened data
  26061. * @param size Define the size of the data.
  26062. */
  26063. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26064. private _updateMatrix3x3ForUniform;
  26065. private _updateMatrix3x3ForEffect;
  26066. private _updateMatrix2x2ForEffect;
  26067. private _updateMatrix2x2ForUniform;
  26068. private _updateFloatForEffect;
  26069. private _updateFloatForUniform;
  26070. private _updateFloat2ForEffect;
  26071. private _updateFloat2ForUniform;
  26072. private _updateFloat3ForEffect;
  26073. private _updateFloat3ForUniform;
  26074. private _updateFloat4ForEffect;
  26075. private _updateFloat4ForUniform;
  26076. private _updateMatrixForEffect;
  26077. private _updateMatrixForUniform;
  26078. private _updateVector3ForEffect;
  26079. private _updateVector3ForUniform;
  26080. private _updateVector4ForEffect;
  26081. private _updateVector4ForUniform;
  26082. private _updateColor3ForEffect;
  26083. private _updateColor3ForUniform;
  26084. private _updateColor4ForEffect;
  26085. private _updateColor4ForUniform;
  26086. /**
  26087. * Sets a sampler uniform on the effect.
  26088. * @param name Define the name of the sampler.
  26089. * @param texture Define the texture to set in the sampler
  26090. */
  26091. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26092. /**
  26093. * Directly updates the value of the uniform in the cache AND on the GPU.
  26094. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26095. * @param data Define the flattened data
  26096. */
  26097. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26098. /**
  26099. * Binds this uniform buffer to an effect.
  26100. * @param effect Define the effect to bind the buffer to
  26101. * @param name Name of the uniform block in the shader.
  26102. */
  26103. bindToEffect(effect: Effect, name: string): void;
  26104. /**
  26105. * Disposes the uniform buffer.
  26106. */
  26107. dispose(): void;
  26108. }
  26109. }
  26110. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26111. import { Nullable } from "babylonjs/types";
  26112. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26113. /**
  26114. * This represents the required contract to create a new type of texture loader.
  26115. */
  26116. export interface IInternalTextureLoader {
  26117. /**
  26118. * Defines wether the loader supports cascade loading the different faces.
  26119. */
  26120. supportCascades: boolean;
  26121. /**
  26122. * This returns if the loader support the current file information.
  26123. * @param extension defines the file extension of the file being loaded
  26124. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26125. * @param fallback defines the fallback internal texture if any
  26126. * @param isBase64 defines whether the texture is encoded as a base64
  26127. * @param isBuffer defines whether the texture data are stored as a buffer
  26128. * @returns true if the loader can load the specified file
  26129. */
  26130. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26131. /**
  26132. * Transform the url before loading if required.
  26133. * @param rootUrl the url of the texture
  26134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26135. * @returns the transformed texture
  26136. */
  26137. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26138. /**
  26139. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26140. * @param rootUrl the url of the texture
  26141. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26142. * @returns the fallback texture
  26143. */
  26144. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26145. /**
  26146. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26147. * @param data contains the texture data
  26148. * @param texture defines the BabylonJS internal texture
  26149. * @param createPolynomials will be true if polynomials have been requested
  26150. * @param onLoad defines the callback to trigger once the texture is ready
  26151. * @param onError defines the callback to trigger in case of error
  26152. */
  26153. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26154. /**
  26155. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26156. * @param data contains the texture data
  26157. * @param texture defines the BabylonJS internal texture
  26158. * @param callback defines the method to call once ready to upload
  26159. */
  26160. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26161. }
  26162. }
  26163. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26164. import { Scene } from "babylonjs/scene";
  26165. import { Engine } from "babylonjs/Engines/engine";
  26166. import { Texture } from "babylonjs/Materials/Textures/texture";
  26167. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26168. /**
  26169. * Creation options of the multi render target texture.
  26170. */
  26171. export interface IMultiRenderTargetOptions {
  26172. /**
  26173. * Define if the texture needs to create mip maps after render.
  26174. */
  26175. generateMipMaps?: boolean;
  26176. /**
  26177. * Define the types of all the draw buffers we want to create
  26178. */
  26179. types?: number[];
  26180. /**
  26181. * Define the sampling modes of all the draw buffers we want to create
  26182. */
  26183. samplingModes?: number[];
  26184. /**
  26185. * Define if a depth buffer is required
  26186. */
  26187. generateDepthBuffer?: boolean;
  26188. /**
  26189. * Define if a stencil buffer is required
  26190. */
  26191. generateStencilBuffer?: boolean;
  26192. /**
  26193. * Define if a depth texture is required instead of a depth buffer
  26194. */
  26195. generateDepthTexture?: boolean;
  26196. /**
  26197. * Define the number of desired draw buffers
  26198. */
  26199. textureCount?: number;
  26200. /**
  26201. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26202. */
  26203. doNotChangeAspectRatio?: boolean;
  26204. /**
  26205. * Define the default type of the buffers we are creating
  26206. */
  26207. defaultType?: number;
  26208. }
  26209. /**
  26210. * A multi render target, like a render target provides the ability to render to a texture.
  26211. * Unlike the render target, it can render to several draw buffers in one draw.
  26212. * This is specially interesting in deferred rendering or for any effects requiring more than
  26213. * just one color from a single pass.
  26214. */
  26215. export class MultiRenderTarget extends RenderTargetTexture {
  26216. private _internalTextures;
  26217. private _textures;
  26218. private _multiRenderTargetOptions;
  26219. /**
  26220. * Get if draw buffers are currently supported by the used hardware and browser.
  26221. */
  26222. readonly isSupported: boolean;
  26223. /**
  26224. * Get the list of textures generated by the multi render target.
  26225. */
  26226. readonly textures: Texture[];
  26227. /**
  26228. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26229. */
  26230. readonly depthTexture: Texture;
  26231. /**
  26232. * Set the wrapping mode on U of all the textures we are rendering to.
  26233. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26234. */
  26235. wrapU: number;
  26236. /**
  26237. * Set the wrapping mode on V of all the textures we are rendering to.
  26238. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26239. */
  26240. wrapV: number;
  26241. /**
  26242. * Instantiate a new multi render target texture.
  26243. * A multi render target, like a render target provides the ability to render to a texture.
  26244. * Unlike the render target, it can render to several draw buffers in one draw.
  26245. * This is specially interesting in deferred rendering or for any effects requiring more than
  26246. * just one color from a single pass.
  26247. * @param name Define the name of the texture
  26248. * @param size Define the size of the buffers to render to
  26249. * @param count Define the number of target we are rendering into
  26250. * @param scene Define the scene the texture belongs to
  26251. * @param options Define the options used to create the multi render target
  26252. */
  26253. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26254. /** @hidden */
  26255. _rebuild(): void;
  26256. private _createInternalTextures;
  26257. private _createTextures;
  26258. /**
  26259. * Define the number of samples used if MSAA is enabled.
  26260. */
  26261. samples: number;
  26262. /**
  26263. * Resize all the textures in the multi render target.
  26264. * Be carrefull as it will recreate all the data in the new texture.
  26265. * @param size Define the new size
  26266. */
  26267. resize(size: any): void;
  26268. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26269. /**
  26270. * Dispose the render targets and their associated resources
  26271. */
  26272. dispose(): void;
  26273. /**
  26274. * Release all the underlying texture used as draw buffers.
  26275. */
  26276. releaseInternalTextures(): void;
  26277. }
  26278. }
  26279. declare module "babylonjs/Audio/analyser" {
  26280. import { Scene } from "babylonjs/scene";
  26281. /**
  26282. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26284. */
  26285. export class Analyser {
  26286. /**
  26287. * Gets or sets the smoothing
  26288. * @ignorenaming
  26289. */
  26290. SMOOTHING: number;
  26291. /**
  26292. * Gets or sets the FFT table size
  26293. * @ignorenaming
  26294. */
  26295. FFT_SIZE: number;
  26296. /**
  26297. * Gets or sets the bar graph amplitude
  26298. * @ignorenaming
  26299. */
  26300. BARGRAPHAMPLITUDE: number;
  26301. /**
  26302. * Gets or sets the position of the debug canvas
  26303. * @ignorenaming
  26304. */
  26305. DEBUGCANVASPOS: {
  26306. x: number;
  26307. y: number;
  26308. };
  26309. /**
  26310. * Gets or sets the debug canvas size
  26311. * @ignorenaming
  26312. */
  26313. DEBUGCANVASSIZE: {
  26314. width: number;
  26315. height: number;
  26316. };
  26317. private _byteFreqs;
  26318. private _byteTime;
  26319. private _floatFreqs;
  26320. private _webAudioAnalyser;
  26321. private _debugCanvas;
  26322. private _debugCanvasContext;
  26323. private _scene;
  26324. private _registerFunc;
  26325. private _audioEngine;
  26326. /**
  26327. * Creates a new analyser
  26328. * @param scene defines hosting scene
  26329. */
  26330. constructor(scene: Scene);
  26331. /**
  26332. * Get the number of data values you will have to play with for the visualization
  26333. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26334. * @returns a number
  26335. */
  26336. getFrequencyBinCount(): number;
  26337. /**
  26338. * Gets the current frequency data as a byte array
  26339. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26340. * @returns a Uint8Array
  26341. */
  26342. getByteFrequencyData(): Uint8Array;
  26343. /**
  26344. * Gets the current waveform as a byte array
  26345. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26346. * @returns a Uint8Array
  26347. */
  26348. getByteTimeDomainData(): Uint8Array;
  26349. /**
  26350. * Gets the current frequency data as a float array
  26351. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26352. * @returns a Float32Array
  26353. */
  26354. getFloatFrequencyData(): Float32Array;
  26355. /**
  26356. * Renders the debug canvas
  26357. */
  26358. drawDebugCanvas(): void;
  26359. /**
  26360. * Stops rendering the debug canvas and removes it
  26361. */
  26362. stopDebugCanvas(): void;
  26363. /**
  26364. * Connects two audio nodes
  26365. * @param inputAudioNode defines first node to connect
  26366. * @param outputAudioNode defines second node to connect
  26367. */
  26368. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26369. /**
  26370. * Releases all associated resources
  26371. */
  26372. dispose(): void;
  26373. }
  26374. }
  26375. declare module "babylonjs/Audio/audioEngine" {
  26376. import { IDisposable } from "babylonjs/scene";
  26377. import { Analyser } from "babylonjs/Audio/analyser";
  26378. import { Nullable } from "babylonjs/types";
  26379. import { Observable } from "babylonjs/Misc/observable";
  26380. /**
  26381. * This represents an audio engine and it is responsible
  26382. * to play, synchronize and analyse sounds throughout the application.
  26383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26384. */
  26385. export interface IAudioEngine extends IDisposable {
  26386. /**
  26387. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26388. */
  26389. readonly canUseWebAudio: boolean;
  26390. /**
  26391. * Gets the current AudioContext if available.
  26392. */
  26393. readonly audioContext: Nullable<AudioContext>;
  26394. /**
  26395. * The master gain node defines the global audio volume of your audio engine.
  26396. */
  26397. readonly masterGain: GainNode;
  26398. /**
  26399. * Gets whether or not mp3 are supported by your browser.
  26400. */
  26401. readonly isMP3supported: boolean;
  26402. /**
  26403. * Gets whether or not ogg are supported by your browser.
  26404. */
  26405. readonly isOGGsupported: boolean;
  26406. /**
  26407. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26408. * @ignoreNaming
  26409. */
  26410. WarnedWebAudioUnsupported: boolean;
  26411. /**
  26412. * Defines if the audio engine relies on a custom unlocked button.
  26413. * In this case, the embedded button will not be displayed.
  26414. */
  26415. useCustomUnlockedButton: boolean;
  26416. /**
  26417. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26418. */
  26419. readonly unlocked: boolean;
  26420. /**
  26421. * Event raised when audio has been unlocked on the browser.
  26422. */
  26423. onAudioUnlockedObservable: Observable<AudioEngine>;
  26424. /**
  26425. * Event raised when audio has been locked on the browser.
  26426. */
  26427. onAudioLockedObservable: Observable<AudioEngine>;
  26428. /**
  26429. * Flags the audio engine in Locked state.
  26430. * This happens due to new browser policies preventing audio to autoplay.
  26431. */
  26432. lock(): void;
  26433. /**
  26434. * Unlocks the audio engine once a user action has been done on the dom.
  26435. * This is helpful to resume play once browser policies have been satisfied.
  26436. */
  26437. unlock(): void;
  26438. }
  26439. /**
  26440. * This represents the default audio engine used in babylon.
  26441. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26443. */
  26444. export class AudioEngine implements IAudioEngine {
  26445. private _audioContext;
  26446. private _audioContextInitialized;
  26447. private _muteButton;
  26448. private _hostElement;
  26449. /**
  26450. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26451. */
  26452. canUseWebAudio: boolean;
  26453. /**
  26454. * The master gain node defines the global audio volume of your audio engine.
  26455. */
  26456. masterGain: GainNode;
  26457. /**
  26458. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26459. * @ignoreNaming
  26460. */
  26461. WarnedWebAudioUnsupported: boolean;
  26462. /**
  26463. * Gets whether or not mp3 are supported by your browser.
  26464. */
  26465. isMP3supported: boolean;
  26466. /**
  26467. * Gets whether or not ogg are supported by your browser.
  26468. */
  26469. isOGGsupported: boolean;
  26470. /**
  26471. * Gets whether audio has been unlocked on the device.
  26472. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26473. * a user interaction has happened.
  26474. */
  26475. unlocked: boolean;
  26476. /**
  26477. * Defines if the audio engine relies on a custom unlocked button.
  26478. * In this case, the embedded button will not be displayed.
  26479. */
  26480. useCustomUnlockedButton: boolean;
  26481. /**
  26482. * Event raised when audio has been unlocked on the browser.
  26483. */
  26484. onAudioUnlockedObservable: Observable<AudioEngine>;
  26485. /**
  26486. * Event raised when audio has been locked on the browser.
  26487. */
  26488. onAudioLockedObservable: Observable<AudioEngine>;
  26489. /**
  26490. * Gets the current AudioContext if available.
  26491. */
  26492. readonly audioContext: Nullable<AudioContext>;
  26493. private _connectedAnalyser;
  26494. /**
  26495. * Instantiates a new audio engine.
  26496. *
  26497. * There should be only one per page as some browsers restrict the number
  26498. * of audio contexts you can create.
  26499. * @param hostElement defines the host element where to display the mute icon if necessary
  26500. */
  26501. constructor(hostElement?: Nullable<HTMLElement>);
  26502. /**
  26503. * Flags the audio engine in Locked state.
  26504. * This happens due to new browser policies preventing audio to autoplay.
  26505. */
  26506. lock(): void;
  26507. /**
  26508. * Unlocks the audio engine once a user action has been done on the dom.
  26509. * This is helpful to resume play once browser policies have been satisfied.
  26510. */
  26511. unlock(): void;
  26512. private _resumeAudioContext;
  26513. private _initializeAudioContext;
  26514. private _tryToRun;
  26515. private _triggerRunningState;
  26516. private _triggerSuspendedState;
  26517. private _displayMuteButton;
  26518. private _moveButtonToTopLeft;
  26519. private _onResize;
  26520. private _hideMuteButton;
  26521. /**
  26522. * Destroy and release the resources associated with the audio ccontext.
  26523. */
  26524. dispose(): void;
  26525. /**
  26526. * Gets the global volume sets on the master gain.
  26527. * @returns the global volume if set or -1 otherwise
  26528. */
  26529. getGlobalVolume(): number;
  26530. /**
  26531. * Sets the global volume of your experience (sets on the master gain).
  26532. * @param newVolume Defines the new global volume of the application
  26533. */
  26534. setGlobalVolume(newVolume: number): void;
  26535. /**
  26536. * Connect the audio engine to an audio analyser allowing some amazing
  26537. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26539. * @param analyser The analyser to connect to the engine
  26540. */
  26541. connectToAnalyser(analyser: Analyser): void;
  26542. }
  26543. }
  26544. declare module "babylonjs/Loading/loadingScreen" {
  26545. /**
  26546. * Interface used to present a loading screen while loading a scene
  26547. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26548. */
  26549. export interface ILoadingScreen {
  26550. /**
  26551. * Function called to display the loading screen
  26552. */
  26553. displayLoadingUI: () => void;
  26554. /**
  26555. * Function called to hide the loading screen
  26556. */
  26557. hideLoadingUI: () => void;
  26558. /**
  26559. * Gets or sets the color to use for the background
  26560. */
  26561. loadingUIBackgroundColor: string;
  26562. /**
  26563. * Gets or sets the text to display while loading
  26564. */
  26565. loadingUIText: string;
  26566. }
  26567. /**
  26568. * Class used for the default loading screen
  26569. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26570. */
  26571. export class DefaultLoadingScreen implements ILoadingScreen {
  26572. private _renderingCanvas;
  26573. private _loadingText;
  26574. private _loadingDivBackgroundColor;
  26575. private _loadingDiv;
  26576. private _loadingTextDiv;
  26577. /**
  26578. * Creates a new default loading screen
  26579. * @param _renderingCanvas defines the canvas used to render the scene
  26580. * @param _loadingText defines the default text to display
  26581. * @param _loadingDivBackgroundColor defines the default background color
  26582. */
  26583. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26584. /**
  26585. * Function called to display the loading screen
  26586. */
  26587. displayLoadingUI(): void;
  26588. /**
  26589. * Function called to hide the loading screen
  26590. */
  26591. hideLoadingUI(): void;
  26592. /**
  26593. * Gets or sets the text to display while loading
  26594. */
  26595. loadingUIText: string;
  26596. /**
  26597. * Gets or sets the color to use for the background
  26598. */
  26599. loadingUIBackgroundColor: string;
  26600. private _resizeLoadingUI;
  26601. }
  26602. }
  26603. declare module "babylonjs/Materials/Textures/videoTexture" {
  26604. import { Observable } from "babylonjs/Misc/observable";
  26605. import { Nullable } from "babylonjs/types";
  26606. import { Scene } from "babylonjs/scene";
  26607. import { Texture } from "babylonjs/Materials/Textures/texture";
  26608. /**
  26609. * Settings for finer control over video usage
  26610. */
  26611. export interface VideoTextureSettings {
  26612. /**
  26613. * Applies `autoplay` to video, if specified
  26614. */
  26615. autoPlay?: boolean;
  26616. /**
  26617. * Applies `loop` to video, if specified
  26618. */
  26619. loop?: boolean;
  26620. /**
  26621. * Automatically updates internal texture from video at every frame in the render loop
  26622. */
  26623. autoUpdateTexture: boolean;
  26624. /**
  26625. * Image src displayed during the video loading or until the user interacts with the video.
  26626. */
  26627. poster?: string;
  26628. }
  26629. /**
  26630. * If you want to display a video in your scene, this is the special texture for that.
  26631. * This special texture works similar to other textures, with the exception of a few parameters.
  26632. * @see https://doc.babylonjs.com/how_to/video_texture
  26633. */
  26634. export class VideoTexture extends Texture {
  26635. /**
  26636. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26637. */
  26638. readonly autoUpdateTexture: boolean;
  26639. /**
  26640. * The video instance used by the texture internally
  26641. */
  26642. readonly video: HTMLVideoElement;
  26643. private _onUserActionRequestedObservable;
  26644. /**
  26645. * Event triggerd when a dom action is required by the user to play the video.
  26646. * This happens due to recent changes in browser policies preventing video to auto start.
  26647. */
  26648. readonly onUserActionRequestedObservable: Observable<Texture>;
  26649. private _generateMipMaps;
  26650. private _engine;
  26651. private _stillImageCaptured;
  26652. private _displayingPosterTexture;
  26653. private _settings;
  26654. private _createInternalTextureOnEvent;
  26655. /**
  26656. * Creates a video texture.
  26657. * If you want to display a video in your scene, this is the special texture for that.
  26658. * This special texture works similar to other textures, with the exception of a few parameters.
  26659. * @see https://doc.babylonjs.com/how_to/video_texture
  26660. * @param name optional name, will detect from video source, if not defined
  26661. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26662. * @param scene is obviously the current scene.
  26663. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26664. * @param invertY is false by default but can be used to invert video on Y axis
  26665. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26666. * @param settings allows finer control over video usage
  26667. */
  26668. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26669. private _getName;
  26670. private _getVideo;
  26671. private _createInternalTexture;
  26672. private reset;
  26673. /**
  26674. * @hidden Internal method to initiate `update`.
  26675. */
  26676. _rebuild(): void;
  26677. /**
  26678. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26679. */
  26680. update(): void;
  26681. /**
  26682. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26683. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26684. */
  26685. updateTexture(isVisible: boolean): void;
  26686. protected _updateInternalTexture: () => void;
  26687. /**
  26688. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26689. * @param url New url.
  26690. */
  26691. updateURL(url: string): void;
  26692. /**
  26693. * Dispose the texture and release its associated resources.
  26694. */
  26695. dispose(): void;
  26696. /**
  26697. * Creates a video texture straight from a stream.
  26698. * @param scene Define the scene the texture should be created in
  26699. * @param stream Define the stream the texture should be created from
  26700. * @returns The created video texture as a promise
  26701. */
  26702. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26703. /**
  26704. * Creates a video texture straight from your WebCam video feed.
  26705. * @param scene Define the scene the texture should be created in
  26706. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26707. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26708. * @returns The created video texture as a promise
  26709. */
  26710. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26711. minWidth: number;
  26712. maxWidth: number;
  26713. minHeight: number;
  26714. maxHeight: number;
  26715. deviceId: string;
  26716. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26717. /**
  26718. * Creates a video texture straight from your WebCam video feed.
  26719. * @param scene Define the scene the texture should be created in
  26720. * @param onReady Define a callback to triggered once the texture will be ready
  26721. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26722. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26723. */
  26724. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26725. minWidth: number;
  26726. maxWidth: number;
  26727. minHeight: number;
  26728. maxHeight: number;
  26729. deviceId: string;
  26730. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26731. }
  26732. }
  26733. declare module "babylonjs/Engines/engine" {
  26734. import { Observable } from "babylonjs/Misc/observable";
  26735. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26736. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26737. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26738. import { Camera } from "babylonjs/Cameras/camera";
  26739. import { Scene } from "babylonjs/scene";
  26740. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26741. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26742. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26743. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26744. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26745. import { Material } from "babylonjs/Materials/material";
  26746. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26749. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26750. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26751. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26752. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26753. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26754. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26755. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26756. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26757. /**
  26758. * Interface for attribute information associated with buffer instanciation
  26759. */
  26760. export class InstancingAttributeInfo {
  26761. /**
  26762. * Index/offset of the attribute in the vertex shader
  26763. */
  26764. index: number;
  26765. /**
  26766. * size of the attribute, 1, 2, 3 or 4
  26767. */
  26768. attributeSize: number;
  26769. /**
  26770. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26771. * default is FLOAT
  26772. */
  26773. attribyteType: number;
  26774. /**
  26775. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26776. */
  26777. normalized: boolean;
  26778. /**
  26779. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26780. */
  26781. offset: number;
  26782. /**
  26783. * Name of the GLSL attribute, for debugging purpose only
  26784. */
  26785. attributeName: string;
  26786. }
  26787. /**
  26788. * Define options used to create a depth texture
  26789. */
  26790. export class DepthTextureCreationOptions {
  26791. /** Specifies whether or not a stencil should be allocated in the texture */
  26792. generateStencil?: boolean;
  26793. /** Specifies whether or not bilinear filtering is enable on the texture */
  26794. bilinearFiltering?: boolean;
  26795. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26796. comparisonFunction?: number;
  26797. /** Specifies if the created texture is a cube texture */
  26798. isCube?: boolean;
  26799. }
  26800. /**
  26801. * Class used to describe the capabilities of the engine relatively to the current browser
  26802. */
  26803. export class EngineCapabilities {
  26804. /** Maximum textures units per fragment shader */
  26805. maxTexturesImageUnits: number;
  26806. /** Maximum texture units per vertex shader */
  26807. maxVertexTextureImageUnits: number;
  26808. /** Maximum textures units in the entire pipeline */
  26809. maxCombinedTexturesImageUnits: number;
  26810. /** Maximum texture size */
  26811. maxTextureSize: number;
  26812. /** Maximum cube texture size */
  26813. maxCubemapTextureSize: number;
  26814. /** Maximum render texture size */
  26815. maxRenderTextureSize: number;
  26816. /** Maximum number of vertex attributes */
  26817. maxVertexAttribs: number;
  26818. /** Maximum number of varyings */
  26819. maxVaryingVectors: number;
  26820. /** Maximum number of uniforms per vertex shader */
  26821. maxVertexUniformVectors: number;
  26822. /** Maximum number of uniforms per fragment shader */
  26823. maxFragmentUniformVectors: number;
  26824. /** Defines if standard derivates (dx/dy) are supported */
  26825. standardDerivatives: boolean;
  26826. /** Defines if s3tc texture compression is supported */
  26827. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26828. /** Defines if pvrtc texture compression is supported */
  26829. pvrtc: any;
  26830. /** Defines if etc1 texture compression is supported */
  26831. etc1: any;
  26832. /** Defines if etc2 texture compression is supported */
  26833. etc2: any;
  26834. /** Defines if astc texture compression is supported */
  26835. astc: any;
  26836. /** Defines if float textures are supported */
  26837. textureFloat: boolean;
  26838. /** Defines if vertex array objects are supported */
  26839. vertexArrayObject: boolean;
  26840. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26841. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26842. /** Gets the maximum level of anisotropy supported */
  26843. maxAnisotropy: number;
  26844. /** Defines if instancing is supported */
  26845. instancedArrays: boolean;
  26846. /** Defines if 32 bits indices are supported */
  26847. uintIndices: boolean;
  26848. /** Defines if high precision shaders are supported */
  26849. highPrecisionShaderSupported: boolean;
  26850. /** Defines if depth reading in the fragment shader is supported */
  26851. fragmentDepthSupported: boolean;
  26852. /** Defines if float texture linear filtering is supported*/
  26853. textureFloatLinearFiltering: boolean;
  26854. /** Defines if rendering to float textures is supported */
  26855. textureFloatRender: boolean;
  26856. /** Defines if half float textures are supported*/
  26857. textureHalfFloat: boolean;
  26858. /** Defines if half float texture linear filtering is supported*/
  26859. textureHalfFloatLinearFiltering: boolean;
  26860. /** Defines if rendering to half float textures is supported */
  26861. textureHalfFloatRender: boolean;
  26862. /** Defines if textureLOD shader command is supported */
  26863. textureLOD: boolean;
  26864. /** Defines if draw buffers extension is supported */
  26865. drawBuffersExtension: boolean;
  26866. /** Defines if depth textures are supported */
  26867. depthTextureExtension: boolean;
  26868. /** Defines if float color buffer are supported */
  26869. colorBufferFloat: boolean;
  26870. /** Gets disjoint timer query extension (null if not supported) */
  26871. timerQuery: EXT_disjoint_timer_query;
  26872. /** Defines if timestamp can be used with timer query */
  26873. canUseTimestampForTimerQuery: boolean;
  26874. /** Function used to let the system compiles shaders in background */
  26875. parallelShaderCompile: {
  26876. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26877. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26878. COMPLETION_STATUS_KHR: number;
  26879. };
  26880. }
  26881. /** Interface defining initialization parameters for Engine class */
  26882. export interface EngineOptions extends WebGLContextAttributes {
  26883. /**
  26884. * Defines if the engine should no exceed a specified device ratio
  26885. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26886. */
  26887. limitDeviceRatio?: number;
  26888. /**
  26889. * Defines if webvr should be enabled automatically
  26890. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26891. */
  26892. autoEnableWebVR?: boolean;
  26893. /**
  26894. * Defines if webgl2 should be turned off even if supported
  26895. * @see http://doc.babylonjs.com/features/webgl2
  26896. */
  26897. disableWebGL2Support?: boolean;
  26898. /**
  26899. * Defines if webaudio should be initialized as well
  26900. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26901. */
  26902. audioEngine?: boolean;
  26903. /**
  26904. * Defines if animations should run using a deterministic lock step
  26905. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26906. */
  26907. deterministicLockstep?: boolean;
  26908. /** Defines the maximum steps to use with deterministic lock step mode */
  26909. lockstepMaxSteps?: number;
  26910. /**
  26911. * Defines that engine should ignore context lost events
  26912. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26913. */
  26914. doNotHandleContextLost?: boolean;
  26915. /**
  26916. * Defines that engine should ignore modifying touch action attribute and style
  26917. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26918. */
  26919. doNotHandleTouchAction?: boolean;
  26920. }
  26921. /**
  26922. * Defines the interface used by display changed events
  26923. */
  26924. export interface IDisplayChangedEventArgs {
  26925. /** Gets the vrDisplay object (if any) */
  26926. vrDisplay: Nullable<any>;
  26927. /** Gets a boolean indicating if webVR is supported */
  26928. vrSupported: boolean;
  26929. }
  26930. /**
  26931. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26932. */
  26933. export class Engine {
  26934. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26935. static ExceptionList: ({
  26936. key: string;
  26937. capture: string;
  26938. captureConstraint: number;
  26939. targets: string[];
  26940. } | {
  26941. key: string;
  26942. capture: null;
  26943. captureConstraint: null;
  26944. targets: string[];
  26945. })[];
  26946. /** Gets the list of created engines */
  26947. static readonly Instances: Engine[];
  26948. /**
  26949. * Gets the latest created engine
  26950. */
  26951. static readonly LastCreatedEngine: Nullable<Engine>;
  26952. /**
  26953. * Gets the latest created scene
  26954. */
  26955. static readonly LastCreatedScene: Nullable<Scene>;
  26956. /**
  26957. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26958. * @param flag defines which part of the materials must be marked as dirty
  26959. * @param predicate defines a predicate used to filter which materials should be affected
  26960. */
  26961. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26962. /**
  26963. * Hidden
  26964. */
  26965. static _TextureLoaders: IInternalTextureLoader[];
  26966. /** Defines that alpha blending is disabled */
  26967. static readonly ALPHA_DISABLE: number;
  26968. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26969. static readonly ALPHA_ADD: number;
  26970. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26971. static readonly ALPHA_COMBINE: number;
  26972. /** Defines that alpha blending to DEST - SRC * DEST */
  26973. static readonly ALPHA_SUBTRACT: number;
  26974. /** Defines that alpha blending to SRC * DEST */
  26975. static readonly ALPHA_MULTIPLY: number;
  26976. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26977. static readonly ALPHA_MAXIMIZED: number;
  26978. /** Defines that alpha blending to SRC + DEST */
  26979. static readonly ALPHA_ONEONE: number;
  26980. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26981. static readonly ALPHA_PREMULTIPLIED: number;
  26982. /**
  26983. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26984. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26985. */
  26986. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26987. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26988. static readonly ALPHA_INTERPOLATE: number;
  26989. /**
  26990. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26991. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26992. */
  26993. static readonly ALPHA_SCREENMODE: number;
  26994. /** Defines that the ressource is not delayed*/
  26995. static readonly DELAYLOADSTATE_NONE: number;
  26996. /** Defines that the ressource was successfully delay loaded */
  26997. static readonly DELAYLOADSTATE_LOADED: number;
  26998. /** Defines that the ressource is currently delay loading */
  26999. static readonly DELAYLOADSTATE_LOADING: number;
  27000. /** Defines that the ressource is delayed and has not started loading */
  27001. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27002. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27003. static readonly NEVER: number;
  27004. /** 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 */
  27005. static readonly ALWAYS: number;
  27006. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27007. static readonly LESS: number;
  27008. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27009. static readonly EQUAL: number;
  27010. /** 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 */
  27011. static readonly LEQUAL: number;
  27012. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27013. static readonly GREATER: number;
  27014. /** 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 */
  27015. static readonly GEQUAL: number;
  27016. /** 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 */
  27017. static readonly NOTEQUAL: number;
  27018. /** Passed to stencilOperation to specify that stencil value must be kept */
  27019. static readonly KEEP: number;
  27020. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27021. static readonly REPLACE: number;
  27022. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27023. static readonly INCR: number;
  27024. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27025. static readonly DECR: number;
  27026. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27027. static readonly INVERT: number;
  27028. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27029. static readonly INCR_WRAP: number;
  27030. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27031. static readonly DECR_WRAP: number;
  27032. /** Texture is not repeating outside of 0..1 UVs */
  27033. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27034. /** Texture is repeating outside of 0..1 UVs */
  27035. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27036. /** Texture is repeating and mirrored */
  27037. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27038. /** ALPHA */
  27039. static readonly TEXTUREFORMAT_ALPHA: number;
  27040. /** LUMINANCE */
  27041. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27042. /** LUMINANCE_ALPHA */
  27043. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27044. /** RGB */
  27045. static readonly TEXTUREFORMAT_RGB: number;
  27046. /** RGBA */
  27047. static readonly TEXTUREFORMAT_RGBA: number;
  27048. /** RED */
  27049. static readonly TEXTUREFORMAT_RED: number;
  27050. /** RED (2nd reference) */
  27051. static readonly TEXTUREFORMAT_R: number;
  27052. /** RG */
  27053. static readonly TEXTUREFORMAT_RG: number;
  27054. /** RED_INTEGER */
  27055. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27056. /** RED_INTEGER (2nd reference) */
  27057. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27058. /** RG_INTEGER */
  27059. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27060. /** RGB_INTEGER */
  27061. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27062. /** RGBA_INTEGER */
  27063. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27064. /** UNSIGNED_BYTE */
  27065. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27066. /** UNSIGNED_BYTE (2nd reference) */
  27067. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27068. /** FLOAT */
  27069. static readonly TEXTURETYPE_FLOAT: number;
  27070. /** HALF_FLOAT */
  27071. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27072. /** BYTE */
  27073. static readonly TEXTURETYPE_BYTE: number;
  27074. /** SHORT */
  27075. static readonly TEXTURETYPE_SHORT: number;
  27076. /** UNSIGNED_SHORT */
  27077. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27078. /** INT */
  27079. static readonly TEXTURETYPE_INT: number;
  27080. /** UNSIGNED_INT */
  27081. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27082. /** UNSIGNED_SHORT_4_4_4_4 */
  27083. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27084. /** UNSIGNED_SHORT_5_5_5_1 */
  27085. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27086. /** UNSIGNED_SHORT_5_6_5 */
  27087. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27088. /** UNSIGNED_INT_2_10_10_10_REV */
  27089. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27090. /** UNSIGNED_INT_24_8 */
  27091. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27092. /** UNSIGNED_INT_10F_11F_11F_REV */
  27093. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27094. /** UNSIGNED_INT_5_9_9_9_REV */
  27095. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27096. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27097. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27098. /** nearest is mag = nearest and min = nearest and mip = linear */
  27099. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27100. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27101. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27102. /** Trilinear is mag = linear and min = linear and mip = linear */
  27103. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27104. /** nearest is mag = nearest and min = nearest and mip = linear */
  27105. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27106. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27107. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27108. /** Trilinear is mag = linear and min = linear and mip = linear */
  27109. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27110. /** mag = nearest and min = nearest and mip = nearest */
  27111. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27112. /** mag = nearest and min = linear and mip = nearest */
  27113. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27114. /** mag = nearest and min = linear and mip = linear */
  27115. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27116. /** mag = nearest and min = linear and mip = none */
  27117. static readonly TEXTURE_NEAREST_LINEAR: number;
  27118. /** mag = nearest and min = nearest and mip = none */
  27119. static readonly TEXTURE_NEAREST_NEAREST: number;
  27120. /** mag = linear and min = nearest and mip = nearest */
  27121. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27122. /** mag = linear and min = nearest and mip = linear */
  27123. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27124. /** mag = linear and min = linear and mip = none */
  27125. static readonly TEXTURE_LINEAR_LINEAR: number;
  27126. /** mag = linear and min = nearest and mip = none */
  27127. static readonly TEXTURE_LINEAR_NEAREST: number;
  27128. /** Explicit coordinates mode */
  27129. static readonly TEXTURE_EXPLICIT_MODE: number;
  27130. /** Spherical coordinates mode */
  27131. static readonly TEXTURE_SPHERICAL_MODE: number;
  27132. /** Planar coordinates mode */
  27133. static readonly TEXTURE_PLANAR_MODE: number;
  27134. /** Cubic coordinates mode */
  27135. static readonly TEXTURE_CUBIC_MODE: number;
  27136. /** Projection coordinates mode */
  27137. static readonly TEXTURE_PROJECTION_MODE: number;
  27138. /** Skybox coordinates mode */
  27139. static readonly TEXTURE_SKYBOX_MODE: number;
  27140. /** Inverse Cubic coordinates mode */
  27141. static readonly TEXTURE_INVCUBIC_MODE: number;
  27142. /** Equirectangular coordinates mode */
  27143. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27144. /** Equirectangular Fixed coordinates mode */
  27145. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27146. /** Equirectangular Fixed Mirrored coordinates mode */
  27147. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27148. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27149. static readonly SCALEMODE_FLOOR: number;
  27150. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27151. static readonly SCALEMODE_NEAREST: number;
  27152. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27153. static readonly SCALEMODE_CEILING: number;
  27154. /**
  27155. * Returns the current version of the framework
  27156. */
  27157. static readonly Version: string;
  27158. /**
  27159. * Returns a string describing the current engine
  27160. */
  27161. readonly description: string;
  27162. /**
  27163. * Gets or sets the epsilon value used by collision engine
  27164. */
  27165. static CollisionsEpsilon: number;
  27166. /**
  27167. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27168. */
  27169. static ShadersRepository: string;
  27170. /**
  27171. * Method called to create the default loading screen.
  27172. * This can be overriden in your own app.
  27173. * @param canvas The rendering canvas element
  27174. * @returns The loading screen
  27175. */
  27176. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27177. /**
  27178. * Method called to create the default rescale post process on each engine.
  27179. */
  27180. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27181. /**
  27182. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27183. */
  27184. forcePOTTextures: boolean;
  27185. /**
  27186. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27187. */
  27188. isFullscreen: boolean;
  27189. /**
  27190. * Gets a boolean indicating if the pointer is currently locked
  27191. */
  27192. isPointerLock: boolean;
  27193. /**
  27194. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27195. */
  27196. cullBackFaces: boolean;
  27197. /**
  27198. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27199. */
  27200. renderEvenInBackground: boolean;
  27201. /**
  27202. * Gets or sets a boolean indicating that cache can be kept between frames
  27203. */
  27204. preventCacheWipeBetweenFrames: boolean;
  27205. /**
  27206. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27207. **/
  27208. enableOfflineSupport: boolean;
  27209. /**
  27210. * 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)
  27211. **/
  27212. disableManifestCheck: boolean;
  27213. /**
  27214. * Gets the list of created scenes
  27215. */
  27216. scenes: Scene[];
  27217. /**
  27218. * Event raised when a new scene is created
  27219. */
  27220. onNewSceneAddedObservable: Observable<Scene>;
  27221. /**
  27222. * Gets the list of created postprocesses
  27223. */
  27224. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27225. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27226. validateShaderPrograms: boolean;
  27227. /**
  27228. * Observable event triggered each time the rendering canvas is resized
  27229. */
  27230. onResizeObservable: Observable<Engine>;
  27231. /**
  27232. * Observable event triggered each time the canvas loses focus
  27233. */
  27234. onCanvasBlurObservable: Observable<Engine>;
  27235. /**
  27236. * Observable event triggered each time the canvas gains focus
  27237. */
  27238. onCanvasFocusObservable: Observable<Engine>;
  27239. /**
  27240. * Observable event triggered each time the canvas receives pointerout event
  27241. */
  27242. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27243. /**
  27244. * Observable event triggered before each texture is initialized
  27245. */
  27246. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27247. private _vrDisplay;
  27248. private _vrSupported;
  27249. private _oldSize;
  27250. private _oldHardwareScaleFactor;
  27251. private _vrExclusivePointerMode;
  27252. private _webVRInitPromise;
  27253. /**
  27254. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27255. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27256. */
  27257. readonly isInVRExclusivePointerMode: boolean;
  27258. /**
  27259. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27260. */
  27261. disableUniformBuffers: boolean;
  27262. /** @hidden */
  27263. _uniformBuffers: UniformBuffer[];
  27264. /**
  27265. * Gets a boolean indicating that the engine supports uniform buffers
  27266. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27267. */
  27268. readonly supportsUniformBuffers: boolean;
  27269. /**
  27270. * Observable raised when the engine begins a new frame
  27271. */
  27272. onBeginFrameObservable: Observable<Engine>;
  27273. /**
  27274. * If set, will be used to request the next animation frame for the render loop
  27275. */
  27276. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27277. /**
  27278. * Observable raised when the engine ends the current frame
  27279. */
  27280. onEndFrameObservable: Observable<Engine>;
  27281. /**
  27282. * Observable raised when the engine is about to compile a shader
  27283. */
  27284. onBeforeShaderCompilationObservable: Observable<Engine>;
  27285. /**
  27286. * Observable raised when the engine has jsut compiled a shader
  27287. */
  27288. onAfterShaderCompilationObservable: Observable<Engine>;
  27289. /** @hidden */
  27290. _gl: WebGLRenderingContext;
  27291. private _renderingCanvas;
  27292. private _windowIsBackground;
  27293. private _webGLVersion;
  27294. /**
  27295. * Gets a boolean indicating that only power of 2 textures are supported
  27296. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27297. */
  27298. readonly needPOTTextures: boolean;
  27299. /** @hidden */
  27300. _badOS: boolean;
  27301. /** @hidden */
  27302. _badDesktopOS: boolean;
  27303. /**
  27304. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27305. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27306. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27307. */
  27308. disableTextureBindingOptimization: boolean;
  27309. /**
  27310. * Gets the audio engine
  27311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27312. * @ignorenaming
  27313. */
  27314. static audioEngine: IAudioEngine;
  27315. /**
  27316. * Default AudioEngine factory responsible of creating the Audio Engine.
  27317. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27318. */
  27319. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27320. /**
  27321. * Default offline support factory responsible of creating a tool used to store data locally.
  27322. * By default, this will create a Database object if the workload has been embedded.
  27323. */
  27324. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27325. private _onFocus;
  27326. private _onBlur;
  27327. private _onCanvasPointerOut;
  27328. private _onCanvasBlur;
  27329. private _onCanvasFocus;
  27330. private _onFullscreenChange;
  27331. private _onPointerLockChange;
  27332. private _onVRDisplayPointerRestricted;
  27333. private _onVRDisplayPointerUnrestricted;
  27334. private _onVrDisplayConnect;
  27335. private _onVrDisplayDisconnect;
  27336. private _onVrDisplayPresentChange;
  27337. /**
  27338. * Observable signaled when VR display mode changes
  27339. */
  27340. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27341. /**
  27342. * Observable signaled when VR request present is complete
  27343. */
  27344. onVRRequestPresentComplete: Observable<boolean>;
  27345. /**
  27346. * Observable signaled when VR request present starts
  27347. */
  27348. onVRRequestPresentStart: Observable<Engine>;
  27349. private _hardwareScalingLevel;
  27350. /** @hidden */
  27351. protected _caps: EngineCapabilities;
  27352. private _pointerLockRequested;
  27353. private _isStencilEnable;
  27354. private _colorWrite;
  27355. private _loadingScreen;
  27356. /** @hidden */
  27357. _drawCalls: PerfCounter;
  27358. /** @hidden */
  27359. _textureCollisions: PerfCounter;
  27360. private _glVersion;
  27361. private _glRenderer;
  27362. private _glVendor;
  27363. private _videoTextureSupported;
  27364. private _renderingQueueLaunched;
  27365. private _activeRenderLoops;
  27366. private _deterministicLockstep;
  27367. private _lockstepMaxSteps;
  27368. /**
  27369. * Observable signaled when a context lost event is raised
  27370. */
  27371. onContextLostObservable: Observable<Engine>;
  27372. /**
  27373. * Observable signaled when a context restored event is raised
  27374. */
  27375. onContextRestoredObservable: Observable<Engine>;
  27376. private _onContextLost;
  27377. private _onContextRestored;
  27378. private _contextWasLost;
  27379. private _doNotHandleContextLost;
  27380. /**
  27381. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27383. */
  27384. doNotHandleContextLost: boolean;
  27385. private _performanceMonitor;
  27386. private _fps;
  27387. private _deltaTime;
  27388. /**
  27389. * Turn this value on if you want to pause FPS computation when in background
  27390. */
  27391. disablePerformanceMonitorInBackground: boolean;
  27392. /**
  27393. * Gets the performance monitor attached to this engine
  27394. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27395. */
  27396. readonly performanceMonitor: PerformanceMonitor;
  27397. /** @hidden */
  27398. protected _depthCullingState: _DepthCullingState;
  27399. /** @hidden */
  27400. protected _stencilState: _StencilState;
  27401. /** @hidden */
  27402. protected _alphaState: _AlphaState;
  27403. /** @hidden */
  27404. protected _alphaMode: number;
  27405. protected _internalTexturesCache: InternalTexture[];
  27406. /** @hidden */
  27407. protected _activeChannel: number;
  27408. private _currentTextureChannel;
  27409. /** @hidden */
  27410. protected _boundTexturesCache: {
  27411. [key: string]: Nullable<InternalTexture>;
  27412. };
  27413. /** @hidden */
  27414. protected _currentEffect: Nullable<Effect>;
  27415. /** @hidden */
  27416. protected _currentProgram: Nullable<WebGLProgram>;
  27417. private _compiledEffects;
  27418. private _vertexAttribArraysEnabled;
  27419. /** @hidden */
  27420. protected _cachedViewport: Nullable<Viewport>;
  27421. private _cachedVertexArrayObject;
  27422. /** @hidden */
  27423. protected _cachedVertexBuffers: any;
  27424. /** @hidden */
  27425. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27426. /** @hidden */
  27427. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27428. /** @hidden */
  27429. protected _currentRenderTarget: Nullable<InternalTexture>;
  27430. private _uintIndicesCurrentlySet;
  27431. private _currentBoundBuffer;
  27432. /** @hidden */
  27433. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27434. private _currentBufferPointers;
  27435. private _currentInstanceLocations;
  27436. private _currentInstanceBuffers;
  27437. private _textureUnits;
  27438. private _firstBoundInternalTextureTracker;
  27439. private _lastBoundInternalTextureTracker;
  27440. private _workingCanvas;
  27441. private _workingContext;
  27442. private _rescalePostProcess;
  27443. private _dummyFramebuffer;
  27444. private _externalData;
  27445. private _bindedRenderFunction;
  27446. private _vaoRecordInProgress;
  27447. private _mustWipeVertexAttributes;
  27448. private _emptyTexture;
  27449. private _emptyCubeTexture;
  27450. private _emptyTexture3D;
  27451. /** @hidden */
  27452. _frameHandler: number;
  27453. private _nextFreeTextureSlots;
  27454. private _maxSimultaneousTextures;
  27455. private _activeRequests;
  27456. private _texturesSupported;
  27457. private _textureFormatInUse;
  27458. /**
  27459. * Gets the list of texture formats supported
  27460. */
  27461. readonly texturesSupported: Array<string>;
  27462. /**
  27463. * Gets the list of texture formats in use
  27464. */
  27465. readonly textureFormatInUse: Nullable<string>;
  27466. /**
  27467. * Gets the current viewport
  27468. */
  27469. readonly currentViewport: Nullable<Viewport>;
  27470. /**
  27471. * Gets the default empty texture
  27472. */
  27473. readonly emptyTexture: InternalTexture;
  27474. /**
  27475. * Gets the default empty 3D texture
  27476. */
  27477. readonly emptyTexture3D: InternalTexture;
  27478. /**
  27479. * Gets the default empty cube texture
  27480. */
  27481. readonly emptyCubeTexture: InternalTexture;
  27482. /**
  27483. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27484. */
  27485. readonly premultipliedAlpha: boolean;
  27486. /**
  27487. * Creates a new engine
  27488. * @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
  27489. * @param antialias defines enable antialiasing (default: false)
  27490. * @param options defines further options to be sent to the getContext() function
  27491. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27492. */
  27493. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27494. private _disableTouchAction;
  27495. private _rebuildInternalTextures;
  27496. private _rebuildEffects;
  27497. /**
  27498. * Gets a boolean indicating if all created effects are ready
  27499. * @returns true if all effects are ready
  27500. */
  27501. areAllEffectsReady(): boolean;
  27502. private _rebuildBuffers;
  27503. private _initGLContext;
  27504. /**
  27505. * Gets version of the current webGL context
  27506. */
  27507. readonly webGLVersion: number;
  27508. /**
  27509. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27510. */
  27511. readonly isStencilEnable: boolean;
  27512. private _prepareWorkingCanvas;
  27513. /**
  27514. * Reset the texture cache to empty state
  27515. */
  27516. resetTextureCache(): void;
  27517. /**
  27518. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27519. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27520. * @returns true if engine is in deterministic lock step mode
  27521. */
  27522. isDeterministicLockStep(): boolean;
  27523. /**
  27524. * Gets the max steps when engine is running in deterministic lock step
  27525. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27526. * @returns the max steps
  27527. */
  27528. getLockstepMaxSteps(): number;
  27529. /**
  27530. * Gets an object containing information about the current webGL context
  27531. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27532. */
  27533. getGlInfo(): {
  27534. vendor: string;
  27535. renderer: string;
  27536. version: string;
  27537. };
  27538. /**
  27539. * Gets current aspect ratio
  27540. * @param camera defines the camera to use to get the aspect ratio
  27541. * @param useScreen defines if screen size must be used (or the current render target if any)
  27542. * @returns a number defining the aspect ratio
  27543. */
  27544. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27545. /**
  27546. * Gets current screen aspect ratio
  27547. * @returns a number defining the aspect ratio
  27548. */
  27549. getScreenAspectRatio(): number;
  27550. /**
  27551. * Gets the current render width
  27552. * @param useScreen defines if screen size must be used (or the current render target if any)
  27553. * @returns a number defining the current render width
  27554. */
  27555. getRenderWidth(useScreen?: boolean): number;
  27556. /**
  27557. * Gets the current render height
  27558. * @param useScreen defines if screen size must be used (or the current render target if any)
  27559. * @returns a number defining the current render height
  27560. */
  27561. getRenderHeight(useScreen?: boolean): number;
  27562. /**
  27563. * Gets the HTML canvas attached with the current webGL context
  27564. * @returns a HTML canvas
  27565. */
  27566. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27567. /**
  27568. * Gets the client rect of the HTML canvas attached with the current webGL context
  27569. * @returns a client rectanglee
  27570. */
  27571. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27572. /**
  27573. * Defines the hardware scaling level.
  27574. * By default the hardware scaling level is computed from the window device ratio.
  27575. * 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.
  27576. * @param level defines the level to use
  27577. */
  27578. setHardwareScalingLevel(level: number): void;
  27579. /**
  27580. * Gets the current hardware scaling level.
  27581. * By default the hardware scaling level is computed from the window device ratio.
  27582. * 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.
  27583. * @returns a number indicating the current hardware scaling level
  27584. */
  27585. getHardwareScalingLevel(): number;
  27586. /**
  27587. * Gets the list of loaded textures
  27588. * @returns an array containing all loaded textures
  27589. */
  27590. getLoadedTexturesCache(): InternalTexture[];
  27591. /**
  27592. * Gets the object containing all engine capabilities
  27593. * @returns the EngineCapabilities object
  27594. */
  27595. getCaps(): EngineCapabilities;
  27596. /**
  27597. * Gets the current depth function
  27598. * @returns a number defining the depth function
  27599. */
  27600. getDepthFunction(): Nullable<number>;
  27601. /**
  27602. * Sets the current depth function
  27603. * @param depthFunc defines the function to use
  27604. */
  27605. setDepthFunction(depthFunc: number): void;
  27606. /**
  27607. * Sets the current depth function to GREATER
  27608. */
  27609. setDepthFunctionToGreater(): void;
  27610. /**
  27611. * Sets the current depth function to GEQUAL
  27612. */
  27613. setDepthFunctionToGreaterOrEqual(): void;
  27614. /**
  27615. * Sets the current depth function to LESS
  27616. */
  27617. setDepthFunctionToLess(): void;
  27618. /**
  27619. * Sets the current depth function to LEQUAL
  27620. */
  27621. setDepthFunctionToLessOrEqual(): void;
  27622. /**
  27623. * Gets a boolean indicating if stencil buffer is enabled
  27624. * @returns the current stencil buffer state
  27625. */
  27626. getStencilBuffer(): boolean;
  27627. /**
  27628. * Enable or disable the stencil buffer
  27629. * @param enable defines if the stencil buffer must be enabled or disabled
  27630. */
  27631. setStencilBuffer(enable: boolean): void;
  27632. /**
  27633. * Gets the current stencil mask
  27634. * @returns a number defining the new stencil mask to use
  27635. */
  27636. getStencilMask(): number;
  27637. /**
  27638. * Sets the current stencil mask
  27639. * @param mask defines the new stencil mask to use
  27640. */
  27641. setStencilMask(mask: number): void;
  27642. /**
  27643. * Gets the current stencil function
  27644. * @returns a number defining the stencil function to use
  27645. */
  27646. getStencilFunction(): number;
  27647. /**
  27648. * Gets the current stencil reference value
  27649. * @returns a number defining the stencil reference value to use
  27650. */
  27651. getStencilFunctionReference(): number;
  27652. /**
  27653. * Gets the current stencil mask
  27654. * @returns a number defining the stencil mask to use
  27655. */
  27656. getStencilFunctionMask(): number;
  27657. /**
  27658. * Sets the current stencil function
  27659. * @param stencilFunc defines the new stencil function to use
  27660. */
  27661. setStencilFunction(stencilFunc: number): void;
  27662. /**
  27663. * Sets the current stencil reference
  27664. * @param reference defines the new stencil reference to use
  27665. */
  27666. setStencilFunctionReference(reference: number): void;
  27667. /**
  27668. * Sets the current stencil mask
  27669. * @param mask defines the new stencil mask to use
  27670. */
  27671. setStencilFunctionMask(mask: number): void;
  27672. /**
  27673. * Gets the current stencil operation when stencil fails
  27674. * @returns a number defining stencil operation to use when stencil fails
  27675. */
  27676. getStencilOperationFail(): number;
  27677. /**
  27678. * Gets the current stencil operation when depth fails
  27679. * @returns a number defining stencil operation to use when depth fails
  27680. */
  27681. getStencilOperationDepthFail(): number;
  27682. /**
  27683. * Gets the current stencil operation when stencil passes
  27684. * @returns a number defining stencil operation to use when stencil passes
  27685. */
  27686. getStencilOperationPass(): number;
  27687. /**
  27688. * Sets the stencil operation to use when stencil fails
  27689. * @param operation defines the stencil operation to use when stencil fails
  27690. */
  27691. setStencilOperationFail(operation: number): void;
  27692. /**
  27693. * Sets the stencil operation to use when depth fails
  27694. * @param operation defines the stencil operation to use when depth fails
  27695. */
  27696. setStencilOperationDepthFail(operation: number): void;
  27697. /**
  27698. * Sets the stencil operation to use when stencil passes
  27699. * @param operation defines the stencil operation to use when stencil passes
  27700. */
  27701. setStencilOperationPass(operation: number): void;
  27702. /**
  27703. * Sets a boolean indicating if the dithering state is enabled or disabled
  27704. * @param value defines the dithering state
  27705. */
  27706. setDitheringState(value: boolean): void;
  27707. /**
  27708. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27709. * @param value defines the rasterizer state
  27710. */
  27711. setRasterizerState(value: boolean): void;
  27712. /**
  27713. * stop executing a render loop function and remove it from the execution array
  27714. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27715. */
  27716. stopRenderLoop(renderFunction?: () => void): void;
  27717. /** @hidden */
  27718. _renderLoop(): void;
  27719. /**
  27720. * Register and execute a render loop. The engine can have more than one render function
  27721. * @param renderFunction defines the function to continuously execute
  27722. */
  27723. runRenderLoop(renderFunction: () => void): void;
  27724. /**
  27725. * Toggle full screen mode
  27726. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27727. */
  27728. switchFullscreen(requestPointerLock: boolean): void;
  27729. /**
  27730. * Enters full screen mode
  27731. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27732. */
  27733. enterFullscreen(requestPointerLock: boolean): void;
  27734. /**
  27735. * Exits full screen mode
  27736. */
  27737. exitFullscreen(): void;
  27738. /**
  27739. * Clear the current render buffer or the current render target (if any is set up)
  27740. * @param color defines the color to use
  27741. * @param backBuffer defines if the back buffer must be cleared
  27742. * @param depth defines if the depth buffer must be cleared
  27743. * @param stencil defines if the stencil buffer must be cleared
  27744. */
  27745. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27746. /**
  27747. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27748. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27749. * @param y defines the y-coordinate of the corner of the clear rectangle
  27750. * @param width defines the width of the clear rectangle
  27751. * @param height defines the height of the clear rectangle
  27752. * @param clearColor defines the clear color
  27753. */
  27754. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27755. /**
  27756. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27757. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27758. * @param y defines the y-coordinate of the corner of the clear rectangle
  27759. * @param width defines the width of the clear rectangle
  27760. * @param height defines the height of the clear rectangle
  27761. */
  27762. enableScissor(x: number, y: number, width: number, height: number): void;
  27763. /**
  27764. * Disable previously set scissor test rectangle
  27765. */
  27766. disableScissor(): void;
  27767. private _viewportCached;
  27768. /** @hidden */
  27769. _viewport(x: number, y: number, width: number, height: number): void;
  27770. /**
  27771. * Set the WebGL's viewport
  27772. * @param viewport defines the viewport element to be used
  27773. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27774. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27775. */
  27776. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27777. /**
  27778. * Directly set the WebGL Viewport
  27779. * @param x defines the x coordinate of the viewport (in screen space)
  27780. * @param y defines the y coordinate of the viewport (in screen space)
  27781. * @param width defines the width of the viewport (in screen space)
  27782. * @param height defines the height of the viewport (in screen space)
  27783. * @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
  27784. */
  27785. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27786. /**
  27787. * Begin a new frame
  27788. */
  27789. beginFrame(): void;
  27790. /**
  27791. * Enf the current frame
  27792. */
  27793. endFrame(): void;
  27794. /**
  27795. * Resize the view according to the canvas' size
  27796. */
  27797. resize(): void;
  27798. /**
  27799. * Force a specific size of the canvas
  27800. * @param width defines the new canvas' width
  27801. * @param height defines the new canvas' height
  27802. */
  27803. setSize(width: number, height: number): void;
  27804. /**
  27805. * Gets a boolean indicating if a webVR device was detected
  27806. * @returns true if a webVR device was detected
  27807. */
  27808. isVRDevicePresent(): boolean;
  27809. /**
  27810. * Gets the current webVR device
  27811. * @returns the current webVR device (or null)
  27812. */
  27813. getVRDevice(): any;
  27814. /**
  27815. * Initializes a webVR display and starts listening to display change events
  27816. * The onVRDisplayChangedObservable will be notified upon these changes
  27817. * @returns The onVRDisplayChangedObservable
  27818. */
  27819. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27820. /**
  27821. * Initializes a webVR display and starts listening to display change events
  27822. * The onVRDisplayChangedObservable will be notified upon these changes
  27823. * @returns A promise containing a VRDisplay and if vr is supported
  27824. */
  27825. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27826. /**
  27827. * Call this function to switch to webVR mode
  27828. * Will do nothing if webVR is not supported or if there is no webVR device
  27829. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27830. */
  27831. enableVR(): void;
  27832. /**
  27833. * Call this function to leave webVR mode
  27834. * Will do nothing if webVR is not supported or if there is no webVR device
  27835. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27836. */
  27837. disableVR(): void;
  27838. private _onVRFullScreenTriggered;
  27839. private _getVRDisplaysAsync;
  27840. /**
  27841. * Binds the frame buffer to the specified texture.
  27842. * @param texture The texture to render to or null for the default canvas
  27843. * @param faceIndex The face of the texture to render to in case of cube texture
  27844. * @param requiredWidth The width of the target to render to
  27845. * @param requiredHeight The height of the target to render to
  27846. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27847. * @param depthStencilTexture The depth stencil texture to use to render
  27848. * @param lodLevel defines le lod level to bind to the frame buffer
  27849. */
  27850. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27851. private bindUnboundFramebuffer;
  27852. /**
  27853. * Unbind the current render target texture from the webGL context
  27854. * @param texture defines the render target texture to unbind
  27855. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27856. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27857. */
  27858. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27859. /**
  27860. * Unbind a list of render target textures from the webGL context
  27861. * This is used only when drawBuffer extension or webGL2 are active
  27862. * @param textures defines the render target textures to unbind
  27863. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27864. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27865. */
  27866. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27867. /**
  27868. * Force the mipmap generation for the given render target texture
  27869. * @param texture defines the render target texture to use
  27870. */
  27871. generateMipMapsForCubemap(texture: InternalTexture): void;
  27872. /**
  27873. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27874. */
  27875. flushFramebuffer(): void;
  27876. /**
  27877. * Unbind the current render target and bind the default framebuffer
  27878. */
  27879. restoreDefaultFramebuffer(): void;
  27880. /**
  27881. * Create an uniform buffer
  27882. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27883. * @param elements defines the content of the uniform buffer
  27884. * @returns the webGL uniform buffer
  27885. */
  27886. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27887. /**
  27888. * Create a dynamic uniform buffer
  27889. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27890. * @param elements defines the content of the uniform buffer
  27891. * @returns the webGL uniform buffer
  27892. */
  27893. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27894. /**
  27895. * Update an existing uniform buffer
  27896. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27897. * @param uniformBuffer defines the target uniform buffer
  27898. * @param elements defines the content to update
  27899. * @param offset defines the offset in the uniform buffer where update should start
  27900. * @param count defines the size of the data to update
  27901. */
  27902. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27903. private _resetVertexBufferBinding;
  27904. /**
  27905. * Creates a vertex buffer
  27906. * @param data the data for the vertex buffer
  27907. * @returns the new WebGL static buffer
  27908. */
  27909. createVertexBuffer(data: DataArray): WebGLBuffer;
  27910. /**
  27911. * Creates a dynamic vertex buffer
  27912. * @param data the data for the dynamic vertex buffer
  27913. * @returns the new WebGL dynamic buffer
  27914. */
  27915. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27916. /**
  27917. * Update a dynamic index buffer
  27918. * @param indexBuffer defines the target index buffer
  27919. * @param indices defines the data to update
  27920. * @param offset defines the offset in the target index buffer where update should start
  27921. */
  27922. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27923. /**
  27924. * Updates a dynamic vertex buffer.
  27925. * @param vertexBuffer the vertex buffer to update
  27926. * @param data the data used to update the vertex buffer
  27927. * @param byteOffset the byte offset of the data
  27928. * @param byteLength the byte length of the data
  27929. */
  27930. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27931. private _resetIndexBufferBinding;
  27932. /**
  27933. * Creates a new index buffer
  27934. * @param indices defines the content of the index buffer
  27935. * @param updatable defines if the index buffer must be updatable
  27936. * @returns a new webGL buffer
  27937. */
  27938. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27939. /**
  27940. * Bind a webGL buffer to the webGL context
  27941. * @param buffer defines the buffer to bind
  27942. */
  27943. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27944. /**
  27945. * Bind an uniform buffer to the current webGL context
  27946. * @param buffer defines the buffer to bind
  27947. */
  27948. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27949. /**
  27950. * Bind a buffer to the current webGL context at a given location
  27951. * @param buffer defines the buffer to bind
  27952. * @param location defines the index where to bind the buffer
  27953. */
  27954. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27955. /**
  27956. * Bind a specific block at a given index in a specific shader program
  27957. * @param shaderProgram defines the shader program
  27958. * @param blockName defines the block name
  27959. * @param index defines the index where to bind the block
  27960. */
  27961. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27962. private bindIndexBuffer;
  27963. private bindBuffer;
  27964. /**
  27965. * update the bound buffer with the given data
  27966. * @param data defines the data to update
  27967. */
  27968. updateArrayBuffer(data: Float32Array): void;
  27969. private _vertexAttribPointer;
  27970. private _bindIndexBufferWithCache;
  27971. private _bindVertexBuffersAttributes;
  27972. /**
  27973. * Records a vertex array object
  27974. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27975. * @param vertexBuffers defines the list of vertex buffers to store
  27976. * @param indexBuffer defines the index buffer to store
  27977. * @param effect defines the effect to store
  27978. * @returns the new vertex array object
  27979. */
  27980. recordVertexArrayObject(vertexBuffers: {
  27981. [key: string]: VertexBuffer;
  27982. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27983. /**
  27984. * Bind a specific vertex array object
  27985. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27986. * @param vertexArrayObject defines the vertex array object to bind
  27987. * @param indexBuffer defines the index buffer to bind
  27988. */
  27989. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27990. /**
  27991. * Bind webGl buffers directly to the webGL context
  27992. * @param vertexBuffer defines the vertex buffer to bind
  27993. * @param indexBuffer defines the index buffer to bind
  27994. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27995. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27996. * @param effect defines the effect associated with the vertex buffer
  27997. */
  27998. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27999. private _unbindVertexArrayObject;
  28000. /**
  28001. * Bind a list of vertex buffers to the webGL context
  28002. * @param vertexBuffers defines the list of vertex buffers to bind
  28003. * @param indexBuffer defines the index buffer to bind
  28004. * @param effect defines the effect associated with the vertex buffers
  28005. */
  28006. bindBuffers(vertexBuffers: {
  28007. [key: string]: Nullable<VertexBuffer>;
  28008. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28009. /**
  28010. * Unbind all instance attributes
  28011. */
  28012. unbindInstanceAttributes(): void;
  28013. /**
  28014. * Release and free the memory of a vertex array object
  28015. * @param vao defines the vertex array object to delete
  28016. */
  28017. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28018. /** @hidden */
  28019. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28020. /**
  28021. * Creates a webGL buffer to use with instanciation
  28022. * @param capacity defines the size of the buffer
  28023. * @returns the webGL buffer
  28024. */
  28025. createInstancesBuffer(capacity: number): WebGLBuffer;
  28026. /**
  28027. * Delete a webGL buffer used with instanciation
  28028. * @param buffer defines the webGL buffer to delete
  28029. */
  28030. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28031. /**
  28032. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28033. * @param instancesBuffer defines the webGL buffer to update and bind
  28034. * @param data defines the data to store in the buffer
  28035. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28036. */
  28037. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28038. /**
  28039. * Apply all cached states (depth, culling, stencil and alpha)
  28040. */
  28041. applyStates(): void;
  28042. /**
  28043. * Send a draw order
  28044. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28045. * @param indexStart defines the starting index
  28046. * @param indexCount defines the number of index to draw
  28047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28048. */
  28049. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28050. /**
  28051. * Draw a list of points
  28052. * @param verticesStart defines the index of first vertex to draw
  28053. * @param verticesCount defines the count of vertices to draw
  28054. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28055. */
  28056. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28057. /**
  28058. * Draw a list of unindexed primitives
  28059. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28060. * @param verticesStart defines the index of first vertex to draw
  28061. * @param verticesCount defines the count of vertices to draw
  28062. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28063. */
  28064. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28065. /**
  28066. * Draw a list of indexed primitives
  28067. * @param fillMode defines the primitive to use
  28068. * @param indexStart defines the starting index
  28069. * @param indexCount defines the number of index to draw
  28070. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28071. */
  28072. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28073. /**
  28074. * Draw a list of unindexed primitives
  28075. * @param fillMode defines the primitive to use
  28076. * @param verticesStart defines the index of first vertex to draw
  28077. * @param verticesCount defines the count of vertices to draw
  28078. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28079. */
  28080. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28081. private _drawMode;
  28082. /** @hidden */
  28083. _releaseEffect(effect: Effect): void;
  28084. /** @hidden */
  28085. _deleteProgram(program: WebGLProgram): void;
  28086. /**
  28087. * Create a new effect (used to store vertex/fragment shaders)
  28088. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28089. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28090. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28091. * @param samplers defines an array of string used to represent textures
  28092. * @param defines defines the string containing the defines to use to compile the shaders
  28093. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28094. * @param onCompiled defines a function to call when the effect creation is successful
  28095. * @param onError defines a function to call when the effect creation has failed
  28096. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28097. * @returns the new Effect
  28098. */
  28099. 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;
  28100. private _compileShader;
  28101. private _compileRawShader;
  28102. /**
  28103. * Directly creates a webGL program
  28104. * @param vertexCode defines the vertex shader code to use
  28105. * @param fragmentCode defines the fragment shader code to use
  28106. * @param context defines the webGL context to use (if not set, the current one will be used)
  28107. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28108. * @returns the new webGL program
  28109. */
  28110. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28111. /**
  28112. * Creates a webGL program
  28113. * @param vertexCode defines the vertex shader code to use
  28114. * @param fragmentCode defines the fragment shader code to use
  28115. * @param defines defines the string containing the defines to use to compile the shaders
  28116. * @param context defines the webGL context to use (if not set, the current one will be used)
  28117. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28118. * @returns the new webGL program
  28119. */
  28120. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28121. private _createShaderProgram;
  28122. private _finalizeProgram;
  28123. /** @hidden */
  28124. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28125. /** @hidden */
  28126. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28127. /**
  28128. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28129. * @param shaderProgram defines the webGL program to use
  28130. * @param uniformsNames defines the list of uniform names
  28131. * @returns an array of webGL uniform locations
  28132. */
  28133. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28134. /**
  28135. * Gets the lsit of active attributes for a given webGL program
  28136. * @param shaderProgram defines the webGL program to use
  28137. * @param attributesNames defines the list of attribute names to get
  28138. * @returns an array of indices indicating the offset of each attribute
  28139. */
  28140. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28141. /**
  28142. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28143. * @param effect defines the effect to activate
  28144. */
  28145. enableEffect(effect: Nullable<Effect>): void;
  28146. /**
  28147. * Set the value of an uniform to an array of int32
  28148. * @param uniform defines the webGL uniform location where to store the value
  28149. * @param array defines the array of int32 to store
  28150. */
  28151. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28152. /**
  28153. * Set the value of an uniform to an array of int32 (stored as vec2)
  28154. * @param uniform defines the webGL uniform location where to store the value
  28155. * @param array defines the array of int32 to store
  28156. */
  28157. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28158. /**
  28159. * Set the value of an uniform to an array of int32 (stored as vec3)
  28160. * @param uniform defines the webGL uniform location where to store the value
  28161. * @param array defines the array of int32 to store
  28162. */
  28163. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28164. /**
  28165. * Set the value of an uniform to an array of int32 (stored as vec4)
  28166. * @param uniform defines the webGL uniform location where to store the value
  28167. * @param array defines the array of int32 to store
  28168. */
  28169. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28170. /**
  28171. * Set the value of an uniform to an array of float32
  28172. * @param uniform defines the webGL uniform location where to store the value
  28173. * @param array defines the array of float32 to store
  28174. */
  28175. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28176. /**
  28177. * Set the value of an uniform to an array of float32 (stored as vec2)
  28178. * @param uniform defines the webGL uniform location where to store the value
  28179. * @param array defines the array of float32 to store
  28180. */
  28181. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28182. /**
  28183. * Set the value of an uniform to an array of float32 (stored as vec3)
  28184. * @param uniform defines the webGL uniform location where to store the value
  28185. * @param array defines the array of float32 to store
  28186. */
  28187. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28188. /**
  28189. * Set the value of an uniform to an array of float32 (stored as vec4)
  28190. * @param uniform defines the webGL uniform location where to store the value
  28191. * @param array defines the array of float32 to store
  28192. */
  28193. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28194. /**
  28195. * Set the value of an uniform to an array of number
  28196. * @param uniform defines the webGL uniform location where to store the value
  28197. * @param array defines the array of number to store
  28198. */
  28199. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28200. /**
  28201. * Set the value of an uniform to an array of number (stored as vec2)
  28202. * @param uniform defines the webGL uniform location where to store the value
  28203. * @param array defines the array of number to store
  28204. */
  28205. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28206. /**
  28207. * Set the value of an uniform to an array of number (stored as vec3)
  28208. * @param uniform defines the webGL uniform location where to store the value
  28209. * @param array defines the array of number to store
  28210. */
  28211. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28212. /**
  28213. * Set the value of an uniform to an array of number (stored as vec4)
  28214. * @param uniform defines the webGL uniform location where to store the value
  28215. * @param array defines the array of number to store
  28216. */
  28217. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28218. /**
  28219. * Set the value of an uniform to an array of float32 (stored as matrices)
  28220. * @param uniform defines the webGL uniform location where to store the value
  28221. * @param matrices defines the array of float32 to store
  28222. */
  28223. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28224. /**
  28225. * Set the value of an uniform to a matrix
  28226. * @param uniform defines the webGL uniform location where to store the value
  28227. * @param matrix defines the matrix to store
  28228. */
  28229. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28230. /**
  28231. * Set the value of an uniform to a matrix (3x3)
  28232. * @param uniform defines the webGL uniform location where to store the value
  28233. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28234. */
  28235. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28236. /**
  28237. * Set the value of an uniform to a matrix (2x2)
  28238. * @param uniform defines the webGL uniform location where to store the value
  28239. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28240. */
  28241. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28242. /**
  28243. * Set the value of an uniform to a number (int)
  28244. * @param uniform defines the webGL uniform location where to store the value
  28245. * @param value defines the int number to store
  28246. */
  28247. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28248. /**
  28249. * Set the value of an uniform to a number (float)
  28250. * @param uniform defines the webGL uniform location where to store the value
  28251. * @param value defines the float number to store
  28252. */
  28253. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28254. /**
  28255. * Set the value of an uniform to a vec2
  28256. * @param uniform defines the webGL uniform location where to store the value
  28257. * @param x defines the 1st component of the value
  28258. * @param y defines the 2nd component of the value
  28259. */
  28260. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28261. /**
  28262. * Set the value of an uniform to a vec3
  28263. * @param uniform defines the webGL uniform location where to store the value
  28264. * @param x defines the 1st component of the value
  28265. * @param y defines the 2nd component of the value
  28266. * @param z defines the 3rd component of the value
  28267. */
  28268. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28269. /**
  28270. * Set the value of an uniform to a boolean
  28271. * @param uniform defines the webGL uniform location where to store the value
  28272. * @param bool defines the boolean to store
  28273. */
  28274. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28275. /**
  28276. * Set the value of an uniform to a vec4
  28277. * @param uniform defines the webGL uniform location where to store the value
  28278. * @param x defines the 1st component of the value
  28279. * @param y defines the 2nd component of the value
  28280. * @param z defines the 3rd component of the value
  28281. * @param w defines the 4th component of the value
  28282. */
  28283. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28284. /**
  28285. * Set the value of an uniform to a Color3
  28286. * @param uniform defines the webGL uniform location where to store the value
  28287. * @param color3 defines the color to store
  28288. */
  28289. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28290. /**
  28291. * Set the value of an uniform to a Color3 and an alpha value
  28292. * @param uniform defines the webGL uniform location where to store the value
  28293. * @param color3 defines the color to store
  28294. * @param alpha defines the alpha component to store
  28295. */
  28296. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28297. /**
  28298. * Sets a Color4 on a uniform variable
  28299. * @param uniform defines the uniform location
  28300. * @param color4 defines the value to be set
  28301. */
  28302. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28303. /**
  28304. * Set various states to the webGL context
  28305. * @param culling defines backface culling state
  28306. * @param zOffset defines the value to apply to zOffset (0 by default)
  28307. * @param force defines if states must be applied even if cache is up to date
  28308. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28309. */
  28310. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28311. /**
  28312. * Set the z offset to apply to current rendering
  28313. * @param value defines the offset to apply
  28314. */
  28315. setZOffset(value: number): void;
  28316. /**
  28317. * Gets the current value of the zOffset
  28318. * @returns the current zOffset state
  28319. */
  28320. getZOffset(): number;
  28321. /**
  28322. * Enable or disable depth buffering
  28323. * @param enable defines the state to set
  28324. */
  28325. setDepthBuffer(enable: boolean): void;
  28326. /**
  28327. * Gets a boolean indicating if depth writing is enabled
  28328. * @returns the current depth writing state
  28329. */
  28330. getDepthWrite(): boolean;
  28331. /**
  28332. * Enable or disable depth writing
  28333. * @param enable defines the state to set
  28334. */
  28335. setDepthWrite(enable: boolean): void;
  28336. /**
  28337. * Enable or disable color writing
  28338. * @param enable defines the state to set
  28339. */
  28340. setColorWrite(enable: boolean): void;
  28341. /**
  28342. * Gets a boolean indicating if color writing is enabled
  28343. * @returns the current color writing state
  28344. */
  28345. getColorWrite(): boolean;
  28346. /**
  28347. * Sets alpha constants used by some alpha blending modes
  28348. * @param r defines the red component
  28349. * @param g defines the green component
  28350. * @param b defines the blue component
  28351. * @param a defines the alpha component
  28352. */
  28353. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28354. /**
  28355. * Sets the current alpha mode
  28356. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28357. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28358. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28359. */
  28360. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28361. /**
  28362. * Gets the current alpha mode
  28363. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28364. * @returns the current alpha mode
  28365. */
  28366. getAlphaMode(): number;
  28367. /**
  28368. * Clears the list of texture accessible through engine.
  28369. * This can help preventing texture load conflict due to name collision.
  28370. */
  28371. clearInternalTexturesCache(): void;
  28372. /**
  28373. * Force the entire cache to be cleared
  28374. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28375. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28376. */
  28377. wipeCaches(bruteForce?: boolean): void;
  28378. /**
  28379. * Set the compressed texture format to use, based on the formats you have, and the formats
  28380. * supported by the hardware / browser.
  28381. *
  28382. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28383. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28384. * to API arguments needed to compressed textures. This puts the burden on the container
  28385. * generator to house the arcane code for determining these for current & future formats.
  28386. *
  28387. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28388. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28389. *
  28390. * Note: The result of this call is not taken into account when a texture is base64.
  28391. *
  28392. * @param formatsAvailable defines the list of those format families you have created
  28393. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28394. *
  28395. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28396. * @returns The extension selected.
  28397. */
  28398. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28399. private _getSamplingParameters;
  28400. private _partialLoadImg;
  28401. private _cascadeLoadImgs;
  28402. /** @hidden */
  28403. _createTexture(): WebGLTexture;
  28404. /**
  28405. * Usually called from Texture.ts.
  28406. * Passed information to create a WebGLTexture
  28407. * @param urlArg defines a value which contains one of the following:
  28408. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28409. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28410. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28411. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28412. * @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)
  28413. * @param scene needed for loading to the correct scene
  28414. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28415. * @param onLoad optional callback to be called upon successful completion
  28416. * @param onError optional callback to be called upon failure
  28417. * @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
  28418. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28419. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28420. * @param forcedExtension defines the extension to use to pick the right loader
  28421. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28422. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28423. */
  28424. 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;
  28425. private _rescaleTexture;
  28426. /**
  28427. * Update a raw texture
  28428. * @param texture defines the texture to update
  28429. * @param data defines the data to store in the texture
  28430. * @param format defines the format of the data
  28431. * @param invertY defines if data must be stored with Y axis inverted
  28432. * @param compression defines the compression used (null by default)
  28433. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28434. */
  28435. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28436. /**
  28437. * Creates a raw texture
  28438. * @param data defines the data to store in the texture
  28439. * @param width defines the width of the texture
  28440. * @param height defines the height of the texture
  28441. * @param format defines the format of the data
  28442. * @param generateMipMaps defines if the engine should generate the mip levels
  28443. * @param invertY defines if data must be stored with Y axis inverted
  28444. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28445. * @param compression defines the compression used (null by default)
  28446. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28447. * @returns the raw texture inside an InternalTexture
  28448. */
  28449. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28450. private _unpackFlipYCached;
  28451. /**
  28452. * In case you are sharing the context with other applications, it might
  28453. * be interested to not cache the unpack flip y state to ensure a consistent
  28454. * value would be set.
  28455. */
  28456. enableUnpackFlipYCached: boolean;
  28457. /** @hidden */
  28458. _unpackFlipY(value: boolean): void;
  28459. /** @hidden */
  28460. _getUnpackAlignement(): number;
  28461. /**
  28462. * Creates a dynamic texture
  28463. * @param width defines the width of the texture
  28464. * @param height defines the height of the texture
  28465. * @param generateMipMaps defines if the engine should generate the mip levels
  28466. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28467. * @returns the dynamic texture inside an InternalTexture
  28468. */
  28469. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28470. /**
  28471. * Update the sampling mode of a given texture
  28472. * @param samplingMode defines the required sampling mode
  28473. * @param texture defines the texture to update
  28474. */
  28475. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28476. /**
  28477. * Update the content of a dynamic texture
  28478. * @param texture defines the texture to update
  28479. * @param canvas defines the canvas containing the source
  28480. * @param invertY defines if data must be stored with Y axis inverted
  28481. * @param premulAlpha defines if alpha is stored as premultiplied
  28482. * @param format defines the format of the data
  28483. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28484. */
  28485. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28486. /**
  28487. * Update a video texture
  28488. * @param texture defines the texture to update
  28489. * @param video defines the video element to use
  28490. * @param invertY defines if data must be stored with Y axis inverted
  28491. */
  28492. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28493. /**
  28494. * Updates a depth texture Comparison Mode and Function.
  28495. * If the comparison Function is equal to 0, the mode will be set to none.
  28496. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28497. * @param texture The texture to set the comparison function for
  28498. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28499. */
  28500. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28501. private _setupDepthStencilTexture;
  28502. /**
  28503. * Creates a depth stencil texture.
  28504. * This is only available in WebGL 2 or with the depth texture extension available.
  28505. * @param size The size of face edge in the texture.
  28506. * @param options The options defining the texture.
  28507. * @returns The texture
  28508. */
  28509. createDepthStencilTexture(size: number | {
  28510. width: number;
  28511. height: number;
  28512. }, options: DepthTextureCreationOptions): InternalTexture;
  28513. /**
  28514. * Creates a depth stencil texture.
  28515. * This is only available in WebGL 2 or with the depth texture extension available.
  28516. * @param size The size of face edge in the texture.
  28517. * @param options The options defining the texture.
  28518. * @returns The texture
  28519. */
  28520. private _createDepthStencilTexture;
  28521. /**
  28522. * Creates a depth stencil cube texture.
  28523. * This is only available in WebGL 2.
  28524. * @param size The size of face edge in the cube texture.
  28525. * @param options The options defining the cube texture.
  28526. * @returns The cube texture
  28527. */
  28528. private _createDepthStencilCubeTexture;
  28529. /**
  28530. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28531. * @param renderTarget The render target to set the frame buffer for
  28532. */
  28533. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28534. /**
  28535. * Creates a new render target texture
  28536. * @param size defines the size of the texture
  28537. * @param options defines the options used to create the texture
  28538. * @returns a new render target texture stored in an InternalTexture
  28539. */
  28540. createRenderTargetTexture(size: number | {
  28541. width: number;
  28542. height: number;
  28543. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28544. /**
  28545. * Create a multi render target texture
  28546. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28547. * @param size defines the size of the texture
  28548. * @param options defines the creation options
  28549. * @returns the cube texture as an InternalTexture
  28550. */
  28551. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28552. private _setupFramebufferDepthAttachments;
  28553. /**
  28554. * Updates the sample count of a render target texture
  28555. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28556. * @param texture defines the texture to update
  28557. * @param samples defines the sample count to set
  28558. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28559. */
  28560. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28561. /**
  28562. * Update the sample count for a given multiple render target texture
  28563. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28564. * @param textures defines the textures to update
  28565. * @param samples defines the sample count to set
  28566. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28567. */
  28568. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28569. /** @hidden */
  28570. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28571. /** @hidden */
  28572. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28573. /** @hidden */
  28574. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28575. /** @hidden */
  28576. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28577. /**
  28578. * Creates a new render target cube texture
  28579. * @param size defines the size of the texture
  28580. * @param options defines the options used to create the texture
  28581. * @returns a new render target cube texture stored in an InternalTexture
  28582. */
  28583. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28584. /**
  28585. * Creates a cube texture
  28586. * @param rootUrl defines the url where the files to load is located
  28587. * @param scene defines the current scene
  28588. * @param files defines the list of files to load (1 per face)
  28589. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28590. * @param onLoad defines an optional callback raised when the texture is loaded
  28591. * @param onError defines an optional callback raised if there is an issue to load the texture
  28592. * @param format defines the format of the data
  28593. * @param forcedExtension defines the extension to use to pick the right loader
  28594. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28595. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28596. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28597. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28598. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28599. * @returns the cube texture as an InternalTexture
  28600. */
  28601. 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;
  28602. /**
  28603. * @hidden
  28604. */
  28605. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28606. /**
  28607. * Update a raw cube texture
  28608. * @param texture defines the texture to udpdate
  28609. * @param data defines the data to store
  28610. * @param format defines the data format
  28611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28612. * @param invertY defines if data must be stored with Y axis inverted
  28613. * @param compression defines the compression used (null by default)
  28614. * @param level defines which level of the texture to update
  28615. */
  28616. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28617. /**
  28618. * Creates a new raw cube texture
  28619. * @param data defines the array of data to use to create each face
  28620. * @param size defines the size of the textures
  28621. * @param format defines the format of the data
  28622. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28623. * @param generateMipMaps defines if the engine should generate the mip levels
  28624. * @param invertY defines if data must be stored with Y axis inverted
  28625. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28626. * @param compression defines the compression used (null by default)
  28627. * @returns the cube texture as an InternalTexture
  28628. */
  28629. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28630. /**
  28631. * Creates a new raw cube texture from a specified url
  28632. * @param url defines the url where the data is located
  28633. * @param scene defines the current scene
  28634. * @param size defines the size of the textures
  28635. * @param format defines the format of the data
  28636. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28637. * @param noMipmap defines if the engine should avoid generating the mip levels
  28638. * @param callback defines a callback used to extract texture data from loaded data
  28639. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28640. * @param onLoad defines a callback called when texture is loaded
  28641. * @param onError defines a callback called if there is an error
  28642. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28643. * @param invertY defines if data must be stored with Y axis inverted
  28644. * @returns the cube texture as an InternalTexture
  28645. */
  28646. 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;
  28647. /**
  28648. * Update a raw 3D texture
  28649. * @param texture defines the texture to update
  28650. * @param data defines the data to store
  28651. * @param format defines the data format
  28652. * @param invertY defines if data must be stored with Y axis inverted
  28653. * @param compression defines the used compression (can be null)
  28654. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28655. */
  28656. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28657. /**
  28658. * Creates a new raw 3D texture
  28659. * @param data defines the data used to create the texture
  28660. * @param width defines the width of the texture
  28661. * @param height defines the height of the texture
  28662. * @param depth defines the depth of the texture
  28663. * @param format defines the format of the texture
  28664. * @param generateMipMaps defines if the engine must generate mip levels
  28665. * @param invertY defines if data must be stored with Y axis inverted
  28666. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28667. * @param compression defines the compressed used (can be null)
  28668. * @param textureType defines the compressed used (can be null)
  28669. * @returns a new raw 3D texture (stored in an InternalTexture)
  28670. */
  28671. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28672. private _prepareWebGLTextureContinuation;
  28673. private _prepareWebGLTexture;
  28674. private _convertRGBtoRGBATextureData;
  28675. /** @hidden */
  28676. _releaseFramebufferObjects(texture: InternalTexture): void;
  28677. /** @hidden */
  28678. _releaseTexture(texture: InternalTexture): void;
  28679. private setProgram;
  28680. private _boundUniforms;
  28681. /**
  28682. * Binds an effect to the webGL context
  28683. * @param effect defines the effect to bind
  28684. */
  28685. bindSamplers(effect: Effect): void;
  28686. private _moveBoundTextureOnTop;
  28687. private _getCorrectTextureChannel;
  28688. private _linkTrackers;
  28689. private _removeDesignatedSlot;
  28690. private _activateCurrentTexture;
  28691. /** @hidden */
  28692. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28693. /** @hidden */
  28694. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28695. /**
  28696. * Sets a texture to the webGL context from a postprocess
  28697. * @param channel defines the channel to use
  28698. * @param postProcess defines the source postprocess
  28699. */
  28700. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28701. /**
  28702. * Binds the output of the passed in post process to the texture channel specified
  28703. * @param channel The channel the texture should be bound to
  28704. * @param postProcess The post process which's output should be bound
  28705. */
  28706. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28707. /**
  28708. * Unbind all textures from the webGL context
  28709. */
  28710. unbindAllTextures(): void;
  28711. /**
  28712. * Sets a texture to the according uniform.
  28713. * @param channel The texture channel
  28714. * @param uniform The uniform to set
  28715. * @param texture The texture to apply
  28716. */
  28717. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28718. /**
  28719. * Sets a depth stencil texture from a render target to the according uniform.
  28720. * @param channel The texture channel
  28721. * @param uniform The uniform to set
  28722. * @param texture The render target texture containing the depth stencil texture to apply
  28723. */
  28724. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28725. private _bindSamplerUniformToChannel;
  28726. private _getTextureWrapMode;
  28727. private _setTexture;
  28728. /**
  28729. * Sets an array of texture to the webGL context
  28730. * @param channel defines the channel where the texture array must be set
  28731. * @param uniform defines the associated uniform location
  28732. * @param textures defines the array of textures to bind
  28733. */
  28734. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28735. /** @hidden */
  28736. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28737. private _setTextureParameterFloat;
  28738. private _setTextureParameterInteger;
  28739. /**
  28740. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28741. * @param x defines the x coordinate of the rectangle where pixels must be read
  28742. * @param y defines the y coordinate of the rectangle where pixels must be read
  28743. * @param width defines the width of the rectangle where pixels must be read
  28744. * @param height defines the height of the rectangle where pixels must be read
  28745. * @returns a Uint8Array containing RGBA colors
  28746. */
  28747. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28748. /**
  28749. * Add an externaly attached data from its key.
  28750. * This method call will fail and return false, if such key already exists.
  28751. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28752. * @param key the unique key that identifies the data
  28753. * @param data the data object to associate to the key for this Engine instance
  28754. * @return true if no such key were already present and the data was added successfully, false otherwise
  28755. */
  28756. addExternalData<T>(key: string, data: T): boolean;
  28757. /**
  28758. * Get an externaly attached data from its key
  28759. * @param key the unique key that identifies the data
  28760. * @return the associated data, if present (can be null), or undefined if not present
  28761. */
  28762. getExternalData<T>(key: string): T;
  28763. /**
  28764. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28765. * @param key the unique key that identifies the data
  28766. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28767. * @return the associated data, can be null if the factory returned null.
  28768. */
  28769. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28770. /**
  28771. * Remove an externaly attached data from the Engine instance
  28772. * @param key the unique key that identifies the data
  28773. * @return true if the data was successfully removed, false if it doesn't exist
  28774. */
  28775. removeExternalData(key: string): boolean;
  28776. /**
  28777. * Unbind all vertex attributes from the webGL context
  28778. */
  28779. unbindAllAttributes(): void;
  28780. /**
  28781. * 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
  28782. */
  28783. releaseEffects(): void;
  28784. /**
  28785. * Dispose and release all associated resources
  28786. */
  28787. dispose(): void;
  28788. /**
  28789. * Display the loading screen
  28790. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28791. */
  28792. displayLoadingUI(): void;
  28793. /**
  28794. * Hide the loading screen
  28795. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28796. */
  28797. hideLoadingUI(): void;
  28798. /**
  28799. * Gets the current loading screen object
  28800. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28801. */
  28802. /**
  28803. * Sets the current loading screen object
  28804. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28805. */
  28806. loadingScreen: ILoadingScreen;
  28807. /**
  28808. * Sets the current loading screen text
  28809. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28810. */
  28811. loadingUIText: string;
  28812. /**
  28813. * Sets the current loading screen background color
  28814. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28815. */
  28816. loadingUIBackgroundColor: string;
  28817. /**
  28818. * Attach a new callback raised when context lost event is fired
  28819. * @param callback defines the callback to call
  28820. */
  28821. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28822. /**
  28823. * Attach a new callback raised when context restored event is fired
  28824. * @param callback defines the callback to call
  28825. */
  28826. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28827. /**
  28828. * Gets the source code of the vertex shader associated with a specific webGL program
  28829. * @param program defines the program to use
  28830. * @returns a string containing the source code of the vertex shader associated with the program
  28831. */
  28832. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28833. /**
  28834. * Gets the source code of the fragment shader associated with a specific webGL program
  28835. * @param program defines the program to use
  28836. * @returns a string containing the source code of the fragment shader associated with the program
  28837. */
  28838. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28839. /**
  28840. * Get the current error code of the webGL context
  28841. * @returns the error code
  28842. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28843. */
  28844. getError(): number;
  28845. /**
  28846. * Gets the current framerate
  28847. * @returns a number representing the framerate
  28848. */
  28849. getFps(): number;
  28850. /**
  28851. * Gets the time spent between current and previous frame
  28852. * @returns a number representing the delta time in ms
  28853. */
  28854. getDeltaTime(): number;
  28855. private _measureFps;
  28856. /** @hidden */
  28857. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28858. private _canRenderToFloatFramebuffer;
  28859. private _canRenderToHalfFloatFramebuffer;
  28860. private _canRenderToFramebuffer;
  28861. /** @hidden */
  28862. _getWebGLTextureType(type: number): number;
  28863. private _getInternalFormat;
  28864. /** @hidden */
  28865. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28866. /** @hidden */
  28867. _getRGBAMultiSampleBufferFormat(type: number): number;
  28868. /** @hidden */
  28869. _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;
  28870. /** @hidden */
  28871. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28872. private _partialLoadFile;
  28873. private _cascadeLoadFiles;
  28874. /**
  28875. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28876. * @returns true if the engine can be created
  28877. * @ignorenaming
  28878. */
  28879. static isSupported(): boolean;
  28880. }
  28881. }
  28882. declare module "babylonjs/Materials/effect" {
  28883. import { Observable } from "babylonjs/Misc/observable";
  28884. import { Nullable } from "babylonjs/types";
  28885. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28886. import { Engine } from "babylonjs/Engines/engine";
  28887. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28888. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28889. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28890. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28892. /**
  28893. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28894. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28895. */
  28896. export class EffectFallbacks {
  28897. private _defines;
  28898. private _currentRank;
  28899. private _maxRank;
  28900. private _mesh;
  28901. /**
  28902. * Removes the fallback from the bound mesh.
  28903. */
  28904. unBindMesh(): void;
  28905. /**
  28906. * Adds a fallback on the specified property.
  28907. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28908. * @param define The name of the define in the shader
  28909. */
  28910. addFallback(rank: number, define: string): void;
  28911. /**
  28912. * Sets the mesh to use CPU skinning when needing to fallback.
  28913. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28914. * @param mesh The mesh to use the fallbacks.
  28915. */
  28916. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28917. /**
  28918. * Checks to see if more fallbacks are still availible.
  28919. */
  28920. readonly isMoreFallbacks: boolean;
  28921. /**
  28922. * Removes the defines that shoould be removed when falling back.
  28923. * @param currentDefines defines the current define statements for the shader.
  28924. * @param effect defines the current effect we try to compile
  28925. * @returns The resulting defines with defines of the current rank removed.
  28926. */
  28927. reduce(currentDefines: string, effect: Effect): string;
  28928. }
  28929. /**
  28930. * Options to be used when creating an effect.
  28931. */
  28932. export class EffectCreationOptions {
  28933. /**
  28934. * Atrributes that will be used in the shader.
  28935. */
  28936. attributes: string[];
  28937. /**
  28938. * Uniform varible names that will be set in the shader.
  28939. */
  28940. uniformsNames: string[];
  28941. /**
  28942. * Uniform buffer varible names that will be set in the shader.
  28943. */
  28944. uniformBuffersNames: string[];
  28945. /**
  28946. * Sampler texture variable names that will be set in the shader.
  28947. */
  28948. samplers: string[];
  28949. /**
  28950. * Define statements that will be set in the shader.
  28951. */
  28952. defines: any;
  28953. /**
  28954. * Possible fallbacks for this effect to improve performance when needed.
  28955. */
  28956. fallbacks: Nullable<EffectFallbacks>;
  28957. /**
  28958. * Callback that will be called when the shader is compiled.
  28959. */
  28960. onCompiled: Nullable<(effect: Effect) => void>;
  28961. /**
  28962. * Callback that will be called if an error occurs during shader compilation.
  28963. */
  28964. onError: Nullable<(effect: Effect, errors: string) => void>;
  28965. /**
  28966. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28967. */
  28968. indexParameters: any;
  28969. /**
  28970. * Max number of lights that can be used in the shader.
  28971. */
  28972. maxSimultaneousLights: number;
  28973. /**
  28974. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28975. */
  28976. transformFeedbackVaryings: Nullable<string[]>;
  28977. }
  28978. /**
  28979. * Effect containing vertex and fragment shader that can be executed on an object.
  28980. */
  28981. export class Effect {
  28982. /**
  28983. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28984. */
  28985. static ShadersRepository: string;
  28986. /**
  28987. * Name of the effect.
  28988. */
  28989. name: any;
  28990. /**
  28991. * String container all the define statements that should be set on the shader.
  28992. */
  28993. defines: string;
  28994. /**
  28995. * Callback that will be called when the shader is compiled.
  28996. */
  28997. onCompiled: Nullable<(effect: Effect) => void>;
  28998. /**
  28999. * Callback that will be called if an error occurs during shader compilation.
  29000. */
  29001. onError: Nullable<(effect: Effect, errors: string) => void>;
  29002. /**
  29003. * Callback that will be called when effect is bound.
  29004. */
  29005. onBind: Nullable<(effect: Effect) => void>;
  29006. /**
  29007. * Unique ID of the effect.
  29008. */
  29009. uniqueId: number;
  29010. /**
  29011. * Observable that will be called when the shader is compiled.
  29012. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29013. */
  29014. onCompileObservable: Observable<Effect>;
  29015. /**
  29016. * Observable that will be called if an error occurs during shader compilation.
  29017. */
  29018. onErrorObservable: Observable<Effect>;
  29019. /** @hidden */
  29020. _onBindObservable: Nullable<Observable<Effect>>;
  29021. /**
  29022. * Observable that will be called when effect is bound.
  29023. */
  29024. readonly onBindObservable: Observable<Effect>;
  29025. /** @hidden */
  29026. _bonesComputationForcedToCPU: boolean;
  29027. private static _uniqueIdSeed;
  29028. private _engine;
  29029. private _uniformBuffersNames;
  29030. private _uniformsNames;
  29031. private _samplers;
  29032. private _isReady;
  29033. private _compilationError;
  29034. private _attributesNames;
  29035. private _attributes;
  29036. private _uniforms;
  29037. /**
  29038. * Key for the effect.
  29039. * @hidden
  29040. */
  29041. _key: string;
  29042. private _indexParameters;
  29043. private _fallbacks;
  29044. private _vertexSourceCode;
  29045. private _fragmentSourceCode;
  29046. private _vertexSourceCodeOverride;
  29047. private _fragmentSourceCodeOverride;
  29048. private _transformFeedbackVaryings;
  29049. /**
  29050. * Compiled shader to webGL program.
  29051. * @hidden
  29052. */
  29053. _program: WebGLProgram;
  29054. private _valueCache;
  29055. private static _baseCache;
  29056. /**
  29057. * Instantiates an effect.
  29058. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29059. * @param baseName Name of the effect.
  29060. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29061. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29062. * @param samplers List of sampler variables that will be passed to the shader.
  29063. * @param engine Engine to be used to render the effect
  29064. * @param defines Define statements to be added to the shader.
  29065. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29066. * @param onCompiled Callback that will be called when the shader is compiled.
  29067. * @param onError Callback that will be called if an error occurs during shader compilation.
  29068. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29069. */
  29070. 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);
  29071. /**
  29072. * Unique key for this effect
  29073. */
  29074. readonly key: string;
  29075. /**
  29076. * If the effect has been compiled and prepared.
  29077. * @returns if the effect is compiled and prepared.
  29078. */
  29079. isReady(): boolean;
  29080. /**
  29081. * The engine the effect was initialized with.
  29082. * @returns the engine.
  29083. */
  29084. getEngine(): Engine;
  29085. /**
  29086. * The compiled webGL program for the effect
  29087. * @returns the webGL program.
  29088. */
  29089. getProgram(): WebGLProgram;
  29090. /**
  29091. * The set of names of attribute variables for the shader.
  29092. * @returns An array of attribute names.
  29093. */
  29094. getAttributesNames(): string[];
  29095. /**
  29096. * Returns the attribute at the given index.
  29097. * @param index The index of the attribute.
  29098. * @returns The location of the attribute.
  29099. */
  29100. getAttributeLocation(index: number): number;
  29101. /**
  29102. * Returns the attribute based on the name of the variable.
  29103. * @param name of the attribute to look up.
  29104. * @returns the attribute location.
  29105. */
  29106. getAttributeLocationByName(name: string): number;
  29107. /**
  29108. * The number of attributes.
  29109. * @returns the numnber of attributes.
  29110. */
  29111. getAttributesCount(): number;
  29112. /**
  29113. * Gets the index of a uniform variable.
  29114. * @param uniformName of the uniform to look up.
  29115. * @returns the index.
  29116. */
  29117. getUniformIndex(uniformName: string): number;
  29118. /**
  29119. * Returns the attribute based on the name of the variable.
  29120. * @param uniformName of the uniform to look up.
  29121. * @returns the location of the uniform.
  29122. */
  29123. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29124. /**
  29125. * Returns an array of sampler variable names
  29126. * @returns The array of sampler variable neames.
  29127. */
  29128. getSamplers(): string[];
  29129. /**
  29130. * The error from the last compilation.
  29131. * @returns the error string.
  29132. */
  29133. getCompilationError(): string;
  29134. /**
  29135. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29136. * @param func The callback to be used.
  29137. */
  29138. executeWhenCompiled(func: (effect: Effect) => void): void;
  29139. private _checkIsReady;
  29140. /** @hidden */
  29141. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29142. /** @hidden */
  29143. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29144. /** @hidden */
  29145. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29146. private _processShaderConversion;
  29147. private _processIncludes;
  29148. private _processPrecision;
  29149. /**
  29150. * Recompiles the webGL program
  29151. * @param vertexSourceCode The source code for the vertex shader.
  29152. * @param fragmentSourceCode The source code for the fragment shader.
  29153. * @param onCompiled Callback called when completed.
  29154. * @param onError Callback called on error.
  29155. * @hidden
  29156. */
  29157. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29158. /**
  29159. * Gets the uniform locations of the the specified variable names
  29160. * @param names THe names of the variables to lookup.
  29161. * @returns Array of locations in the same order as variable names.
  29162. */
  29163. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29164. /**
  29165. * Prepares the effect
  29166. * @hidden
  29167. */
  29168. _prepareEffect(): void;
  29169. /**
  29170. * Checks if the effect is supported. (Must be called after compilation)
  29171. */
  29172. readonly isSupported: boolean;
  29173. /**
  29174. * Binds a texture to the engine to be used as output of the shader.
  29175. * @param channel Name of the output variable.
  29176. * @param texture Texture to bind.
  29177. * @hidden
  29178. */
  29179. _bindTexture(channel: string, texture: InternalTexture): void;
  29180. /**
  29181. * Sets a texture on the engine to be used in the shader.
  29182. * @param channel Name of the sampler variable.
  29183. * @param texture Texture to set.
  29184. */
  29185. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29186. /**
  29187. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29188. * @param channel Name of the sampler variable.
  29189. * @param texture Texture to set.
  29190. */
  29191. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29192. /**
  29193. * Sets an array of textures on the engine to be used in the shader.
  29194. * @param channel Name of the variable.
  29195. * @param textures Textures to set.
  29196. */
  29197. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29198. /**
  29199. * 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)
  29200. * @param channel Name of the sampler variable.
  29201. * @param postProcess Post process to get the input texture from.
  29202. */
  29203. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29204. /**
  29205. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29206. * 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)
  29207. * @param channel Name of the sampler variable.
  29208. * @param postProcess Post process to get the output texture from.
  29209. */
  29210. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29211. /** @hidden */
  29212. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29213. /** @hidden */
  29214. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29215. /** @hidden */
  29216. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29217. /** @hidden */
  29218. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29219. /**
  29220. * Binds a buffer to a uniform.
  29221. * @param buffer Buffer to bind.
  29222. * @param name Name of the uniform variable to bind to.
  29223. */
  29224. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29225. /**
  29226. * Binds block to a uniform.
  29227. * @param blockName Name of the block to bind.
  29228. * @param index Index to bind.
  29229. */
  29230. bindUniformBlock(blockName: string, index: number): void;
  29231. /**
  29232. * Sets an interger value on a uniform variable.
  29233. * @param uniformName Name of the variable.
  29234. * @param value Value to be set.
  29235. * @returns this effect.
  29236. */
  29237. setInt(uniformName: string, value: number): Effect;
  29238. /**
  29239. * Sets an int array on a uniform variable.
  29240. * @param uniformName Name of the variable.
  29241. * @param array array to be set.
  29242. * @returns this effect.
  29243. */
  29244. setIntArray(uniformName: string, array: Int32Array): Effect;
  29245. /**
  29246. * 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)
  29247. * @param uniformName Name of the variable.
  29248. * @param array array to be set.
  29249. * @returns this effect.
  29250. */
  29251. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29252. /**
  29253. * 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)
  29254. * @param uniformName Name of the variable.
  29255. * @param array array to be set.
  29256. * @returns this effect.
  29257. */
  29258. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29259. /**
  29260. * 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)
  29261. * @param uniformName Name of the variable.
  29262. * @param array array to be set.
  29263. * @returns this effect.
  29264. */
  29265. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29266. /**
  29267. * Sets an float array on a uniform variable.
  29268. * @param uniformName Name of the variable.
  29269. * @param array array to be set.
  29270. * @returns this effect.
  29271. */
  29272. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29273. /**
  29274. * 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)
  29275. * @param uniformName Name of the variable.
  29276. * @param array array to be set.
  29277. * @returns this effect.
  29278. */
  29279. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29280. /**
  29281. * 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)
  29282. * @param uniformName Name of the variable.
  29283. * @param array array to be set.
  29284. * @returns this effect.
  29285. */
  29286. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29287. /**
  29288. * 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)
  29289. * @param uniformName Name of the variable.
  29290. * @param array array to be set.
  29291. * @returns this effect.
  29292. */
  29293. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29294. /**
  29295. * Sets an array on a uniform variable.
  29296. * @param uniformName Name of the variable.
  29297. * @param array array to be set.
  29298. * @returns this effect.
  29299. */
  29300. setArray(uniformName: string, array: number[]): Effect;
  29301. /**
  29302. * 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)
  29303. * @param uniformName Name of the variable.
  29304. * @param array array to be set.
  29305. * @returns this effect.
  29306. */
  29307. setArray2(uniformName: string, array: number[]): Effect;
  29308. /**
  29309. * 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)
  29310. * @param uniformName Name of the variable.
  29311. * @param array array to be set.
  29312. * @returns this effect.
  29313. */
  29314. setArray3(uniformName: string, array: number[]): Effect;
  29315. /**
  29316. * 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)
  29317. * @param uniformName Name of the variable.
  29318. * @param array array to be set.
  29319. * @returns this effect.
  29320. */
  29321. setArray4(uniformName: string, array: number[]): Effect;
  29322. /**
  29323. * Sets matrices on a uniform variable.
  29324. * @param uniformName Name of the variable.
  29325. * @param matrices matrices to be set.
  29326. * @returns this effect.
  29327. */
  29328. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29329. /**
  29330. * Sets matrix on a uniform variable.
  29331. * @param uniformName Name of the variable.
  29332. * @param matrix matrix to be set.
  29333. * @returns this effect.
  29334. */
  29335. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29336. /**
  29337. * 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)
  29338. * @param uniformName Name of the variable.
  29339. * @param matrix matrix to be set.
  29340. * @returns this effect.
  29341. */
  29342. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29343. /**
  29344. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29345. * @param uniformName Name of the variable.
  29346. * @param matrix matrix to be set.
  29347. * @returns this effect.
  29348. */
  29349. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29350. /**
  29351. * Sets a float on a uniform variable.
  29352. * @param uniformName Name of the variable.
  29353. * @param value value to be set.
  29354. * @returns this effect.
  29355. */
  29356. setFloat(uniformName: string, value: number): Effect;
  29357. /**
  29358. * Sets a boolean on a uniform variable.
  29359. * @param uniformName Name of the variable.
  29360. * @param bool value to be set.
  29361. * @returns this effect.
  29362. */
  29363. setBool(uniformName: string, bool: boolean): Effect;
  29364. /**
  29365. * Sets a Vector2 on a uniform variable.
  29366. * @param uniformName Name of the variable.
  29367. * @param vector2 vector2 to be set.
  29368. * @returns this effect.
  29369. */
  29370. setVector2(uniformName: string, vector2: Vector2): Effect;
  29371. /**
  29372. * Sets a float2 on a uniform variable.
  29373. * @param uniformName Name of the variable.
  29374. * @param x First float in float2.
  29375. * @param y Second float in float2.
  29376. * @returns this effect.
  29377. */
  29378. setFloat2(uniformName: string, x: number, y: number): Effect;
  29379. /**
  29380. * Sets a Vector3 on a uniform variable.
  29381. * @param uniformName Name of the variable.
  29382. * @param vector3 Value to be set.
  29383. * @returns this effect.
  29384. */
  29385. setVector3(uniformName: string, vector3: Vector3): Effect;
  29386. /**
  29387. * Sets a float3 on a uniform variable.
  29388. * @param uniformName Name of the variable.
  29389. * @param x First float in float3.
  29390. * @param y Second float in float3.
  29391. * @param z Third float in float3.
  29392. * @returns this effect.
  29393. */
  29394. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29395. /**
  29396. * Sets a Vector4 on a uniform variable.
  29397. * @param uniformName Name of the variable.
  29398. * @param vector4 Value to be set.
  29399. * @returns this effect.
  29400. */
  29401. setVector4(uniformName: string, vector4: Vector4): Effect;
  29402. /**
  29403. * Sets a float4 on a uniform variable.
  29404. * @param uniformName Name of the variable.
  29405. * @param x First float in float4.
  29406. * @param y Second float in float4.
  29407. * @param z Third float in float4.
  29408. * @param w Fourth float in float4.
  29409. * @returns this effect.
  29410. */
  29411. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29412. /**
  29413. * Sets a Color3 on a uniform variable.
  29414. * @param uniformName Name of the variable.
  29415. * @param color3 Value to be set.
  29416. * @returns this effect.
  29417. */
  29418. setColor3(uniformName: string, color3: Color3): Effect;
  29419. /**
  29420. * Sets a Color4 on a uniform variable.
  29421. * @param uniformName Name of the variable.
  29422. * @param color3 Value to be set.
  29423. * @param alpha Alpha value to be set.
  29424. * @returns this effect.
  29425. */
  29426. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29427. /**
  29428. * Sets a Color4 on a uniform variable
  29429. * @param uniformName defines the name of the variable
  29430. * @param color4 defines the value to be set
  29431. * @returns this effect.
  29432. */
  29433. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29434. /**
  29435. * This function will add a new shader to the shader store
  29436. * @param name the name of the shader
  29437. * @param pixelShader optional pixel shader content
  29438. * @param vertexShader optional vertex shader content
  29439. */
  29440. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29441. /**
  29442. * Store of each shader (The can be looked up using effect.key)
  29443. */
  29444. static ShadersStore: {
  29445. [key: string]: string;
  29446. };
  29447. /**
  29448. * Store of each included file for a shader (The can be looked up using effect.key)
  29449. */
  29450. static IncludesShadersStore: {
  29451. [key: string]: string;
  29452. };
  29453. /**
  29454. * Resets the cache of effects.
  29455. */
  29456. static ResetCache(): void;
  29457. }
  29458. }
  29459. declare module "babylonjs/Materials/colorCurves" {
  29460. import { Effect } from "babylonjs/Materials/effect";
  29461. /**
  29462. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29463. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29464. * 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;
  29465. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29466. */
  29467. export class ColorCurves {
  29468. private _dirty;
  29469. private _tempColor;
  29470. private _globalCurve;
  29471. private _highlightsCurve;
  29472. private _midtonesCurve;
  29473. private _shadowsCurve;
  29474. private _positiveCurve;
  29475. private _negativeCurve;
  29476. private _globalHue;
  29477. private _globalDensity;
  29478. private _globalSaturation;
  29479. private _globalExposure;
  29480. /**
  29481. * Gets the global Hue value.
  29482. * 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).
  29483. */
  29484. /**
  29485. * Sets the global Hue value.
  29486. * 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).
  29487. */
  29488. globalHue: number;
  29489. /**
  29490. * Gets the global Density value.
  29491. * 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.
  29492. * Values less than zero provide a filter of opposite hue.
  29493. */
  29494. /**
  29495. * Sets the global Density value.
  29496. * 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.
  29497. * Values less than zero provide a filter of opposite hue.
  29498. */
  29499. globalDensity: number;
  29500. /**
  29501. * Gets the global Saturation value.
  29502. * 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.
  29503. */
  29504. /**
  29505. * Sets the global Saturation value.
  29506. * 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.
  29507. */
  29508. globalSaturation: number;
  29509. /**
  29510. * Gets the global Exposure value.
  29511. * 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.
  29512. */
  29513. /**
  29514. * Sets the global Exposure value.
  29515. * 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.
  29516. */
  29517. globalExposure: number;
  29518. private _highlightsHue;
  29519. private _highlightsDensity;
  29520. private _highlightsSaturation;
  29521. private _highlightsExposure;
  29522. /**
  29523. * Gets the highlights Hue value.
  29524. * 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).
  29525. */
  29526. /**
  29527. * Sets the highlights Hue value.
  29528. * 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).
  29529. */
  29530. highlightsHue: number;
  29531. /**
  29532. * Gets the highlights Density value.
  29533. * 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.
  29534. * Values less than zero provide a filter of opposite hue.
  29535. */
  29536. /**
  29537. * Sets the highlights Density value.
  29538. * 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.
  29539. * Values less than zero provide a filter of opposite hue.
  29540. */
  29541. highlightsDensity: number;
  29542. /**
  29543. * Gets the highlights Saturation value.
  29544. * 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.
  29545. */
  29546. /**
  29547. * Sets the highlights Saturation value.
  29548. * 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.
  29549. */
  29550. highlightsSaturation: number;
  29551. /**
  29552. * Gets the highlights Exposure value.
  29553. * 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.
  29554. */
  29555. /**
  29556. * Sets the highlights Exposure value.
  29557. * 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.
  29558. */
  29559. highlightsExposure: number;
  29560. private _midtonesHue;
  29561. private _midtonesDensity;
  29562. private _midtonesSaturation;
  29563. private _midtonesExposure;
  29564. /**
  29565. * Gets the midtones Hue value.
  29566. * 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).
  29567. */
  29568. /**
  29569. * Sets the midtones Hue value.
  29570. * 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).
  29571. */
  29572. midtonesHue: number;
  29573. /**
  29574. * Gets the midtones Density value.
  29575. * 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.
  29576. * Values less than zero provide a filter of opposite hue.
  29577. */
  29578. /**
  29579. * Sets the midtones Density value.
  29580. * 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.
  29581. * Values less than zero provide a filter of opposite hue.
  29582. */
  29583. midtonesDensity: number;
  29584. /**
  29585. * Gets the midtones Saturation value.
  29586. * 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.
  29587. */
  29588. /**
  29589. * Sets the midtones Saturation value.
  29590. * 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.
  29591. */
  29592. midtonesSaturation: number;
  29593. /**
  29594. * Gets the midtones Exposure value.
  29595. * 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.
  29596. */
  29597. /**
  29598. * Sets the midtones Exposure value.
  29599. * 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.
  29600. */
  29601. midtonesExposure: number;
  29602. private _shadowsHue;
  29603. private _shadowsDensity;
  29604. private _shadowsSaturation;
  29605. private _shadowsExposure;
  29606. /**
  29607. * Gets the shadows Hue value.
  29608. * 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).
  29609. */
  29610. /**
  29611. * Sets the shadows Hue value.
  29612. * 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).
  29613. */
  29614. shadowsHue: number;
  29615. /**
  29616. * Gets the shadows Density value.
  29617. * 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.
  29618. * Values less than zero provide a filter of opposite hue.
  29619. */
  29620. /**
  29621. * Sets the shadows Density value.
  29622. * 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.
  29623. * Values less than zero provide a filter of opposite hue.
  29624. */
  29625. shadowsDensity: number;
  29626. /**
  29627. * Gets the shadows Saturation value.
  29628. * 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.
  29629. */
  29630. /**
  29631. * Sets the shadows Saturation value.
  29632. * 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.
  29633. */
  29634. shadowsSaturation: number;
  29635. /**
  29636. * Gets the shadows Exposure value.
  29637. * 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.
  29638. */
  29639. /**
  29640. * Sets the shadows Exposure value.
  29641. * 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.
  29642. */
  29643. shadowsExposure: number;
  29644. /**
  29645. * Returns the class name
  29646. * @returns The class name
  29647. */
  29648. getClassName(): string;
  29649. /**
  29650. * Binds the color curves to the shader.
  29651. * @param colorCurves The color curve to bind
  29652. * @param effect The effect to bind to
  29653. * @param positiveUniform The positive uniform shader parameter
  29654. * @param neutralUniform The neutral uniform shader parameter
  29655. * @param negativeUniform The negative uniform shader parameter
  29656. */
  29657. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29658. /**
  29659. * Prepare the list of uniforms associated with the ColorCurves effects.
  29660. * @param uniformsList The list of uniforms used in the effect
  29661. */
  29662. static PrepareUniforms(uniformsList: string[]): void;
  29663. /**
  29664. * Returns color grading data based on a hue, density, saturation and exposure value.
  29665. * @param filterHue The hue of the color filter.
  29666. * @param filterDensity The density of the color filter.
  29667. * @param saturation The saturation.
  29668. * @param exposure The exposure.
  29669. * @param result The result data container.
  29670. */
  29671. private getColorGradingDataToRef;
  29672. /**
  29673. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29674. * @param value The input slider value in range [-100,100].
  29675. * @returns Adjusted value.
  29676. */
  29677. private static applyColorGradingSliderNonlinear;
  29678. /**
  29679. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29680. * @param hue The hue (H) input.
  29681. * @param saturation The saturation (S) input.
  29682. * @param brightness The brightness (B) input.
  29683. * @result An RGBA color represented as Vector4.
  29684. */
  29685. private static fromHSBToRef;
  29686. /**
  29687. * Returns a value clamped between min and max
  29688. * @param value The value to clamp
  29689. * @param min The minimum of value
  29690. * @param max The maximum of value
  29691. * @returns The clamped value.
  29692. */
  29693. private static clamp;
  29694. /**
  29695. * Clones the current color curve instance.
  29696. * @return The cloned curves
  29697. */
  29698. clone(): ColorCurves;
  29699. /**
  29700. * Serializes the current color curve instance to a json representation.
  29701. * @return a JSON representation
  29702. */
  29703. serialize(): any;
  29704. /**
  29705. * Parses the color curve from a json representation.
  29706. * @param source the JSON source to parse
  29707. * @return The parsed curves
  29708. */
  29709. static Parse(source: any): ColorCurves;
  29710. }
  29711. }
  29712. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29713. import { Observable } from "babylonjs/Misc/observable";
  29714. import { Nullable } from "babylonjs/types";
  29715. import { Color4 } from "babylonjs/Maths/math";
  29716. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29717. import { Effect } from "babylonjs/Materials/effect";
  29718. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29719. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29720. /**
  29721. * Interface to follow in your material defines to integrate easily the
  29722. * Image proccessing functions.
  29723. * @hidden
  29724. */
  29725. export interface IImageProcessingConfigurationDefines {
  29726. IMAGEPROCESSING: boolean;
  29727. VIGNETTE: boolean;
  29728. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29729. VIGNETTEBLENDMODEOPAQUE: boolean;
  29730. TONEMAPPING: boolean;
  29731. TONEMAPPING_ACES: boolean;
  29732. CONTRAST: boolean;
  29733. EXPOSURE: boolean;
  29734. COLORCURVES: boolean;
  29735. COLORGRADING: boolean;
  29736. COLORGRADING3D: boolean;
  29737. SAMPLER3DGREENDEPTH: boolean;
  29738. SAMPLER3DBGRMAP: boolean;
  29739. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29740. }
  29741. /**
  29742. * @hidden
  29743. */
  29744. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29745. IMAGEPROCESSING: boolean;
  29746. VIGNETTE: boolean;
  29747. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29748. VIGNETTEBLENDMODEOPAQUE: boolean;
  29749. TONEMAPPING: boolean;
  29750. TONEMAPPING_ACES: boolean;
  29751. CONTRAST: boolean;
  29752. COLORCURVES: boolean;
  29753. COLORGRADING: boolean;
  29754. COLORGRADING3D: boolean;
  29755. SAMPLER3DGREENDEPTH: boolean;
  29756. SAMPLER3DBGRMAP: boolean;
  29757. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29758. EXPOSURE: boolean;
  29759. constructor();
  29760. }
  29761. /**
  29762. * This groups together the common properties used for image processing either in direct forward pass
  29763. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29764. * or not.
  29765. */
  29766. export class ImageProcessingConfiguration {
  29767. /**
  29768. * Default tone mapping applied in BabylonJS.
  29769. */
  29770. static readonly TONEMAPPING_STANDARD: number;
  29771. /**
  29772. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29773. * to other engines rendering to increase portability.
  29774. */
  29775. static readonly TONEMAPPING_ACES: number;
  29776. /**
  29777. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29778. */
  29779. colorCurves: Nullable<ColorCurves>;
  29780. private _colorCurvesEnabled;
  29781. /**
  29782. * Gets wether the color curves effect is enabled.
  29783. */
  29784. /**
  29785. * Sets wether the color curves effect is enabled.
  29786. */
  29787. colorCurvesEnabled: boolean;
  29788. private _colorGradingTexture;
  29789. /**
  29790. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29791. */
  29792. /**
  29793. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29794. */
  29795. colorGradingTexture: Nullable<BaseTexture>;
  29796. private _colorGradingEnabled;
  29797. /**
  29798. * Gets wether the color grading effect is enabled.
  29799. */
  29800. /**
  29801. * Sets wether the color grading effect is enabled.
  29802. */
  29803. colorGradingEnabled: boolean;
  29804. private _colorGradingWithGreenDepth;
  29805. /**
  29806. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29807. */
  29808. /**
  29809. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29810. */
  29811. colorGradingWithGreenDepth: boolean;
  29812. private _colorGradingBGR;
  29813. /**
  29814. * Gets wether the color grading texture contains BGR values.
  29815. */
  29816. /**
  29817. * Sets wether the color grading texture contains BGR values.
  29818. */
  29819. colorGradingBGR: boolean;
  29820. /** @hidden */
  29821. _exposure: number;
  29822. /**
  29823. * Gets the Exposure used in the effect.
  29824. */
  29825. /**
  29826. * Sets the Exposure used in the effect.
  29827. */
  29828. exposure: number;
  29829. private _toneMappingEnabled;
  29830. /**
  29831. * Gets wether the tone mapping effect is enabled.
  29832. */
  29833. /**
  29834. * Sets wether the tone mapping effect is enabled.
  29835. */
  29836. toneMappingEnabled: boolean;
  29837. private _toneMappingType;
  29838. /**
  29839. * Gets the type of tone mapping effect.
  29840. */
  29841. /**
  29842. * Sets the type of tone mapping effect used in BabylonJS.
  29843. */
  29844. toneMappingType: number;
  29845. protected _contrast: number;
  29846. /**
  29847. * Gets the contrast used in the effect.
  29848. */
  29849. /**
  29850. * Sets the contrast used in the effect.
  29851. */
  29852. contrast: number;
  29853. /**
  29854. * Vignette stretch size.
  29855. */
  29856. vignetteStretch: number;
  29857. /**
  29858. * Vignette centre X Offset.
  29859. */
  29860. vignetteCentreX: number;
  29861. /**
  29862. * Vignette centre Y Offset.
  29863. */
  29864. vignetteCentreY: number;
  29865. /**
  29866. * Vignette weight or intensity of the vignette effect.
  29867. */
  29868. vignetteWeight: number;
  29869. /**
  29870. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29871. * if vignetteEnabled is set to true.
  29872. */
  29873. vignetteColor: Color4;
  29874. /**
  29875. * Camera field of view used by the Vignette effect.
  29876. */
  29877. vignetteCameraFov: number;
  29878. private _vignetteBlendMode;
  29879. /**
  29880. * Gets the vignette blend mode allowing different kind of effect.
  29881. */
  29882. /**
  29883. * Sets the vignette blend mode allowing different kind of effect.
  29884. */
  29885. vignetteBlendMode: number;
  29886. private _vignetteEnabled;
  29887. /**
  29888. * Gets wether the vignette effect is enabled.
  29889. */
  29890. /**
  29891. * Sets wether the vignette effect is enabled.
  29892. */
  29893. vignetteEnabled: boolean;
  29894. private _applyByPostProcess;
  29895. /**
  29896. * Gets wether the image processing is applied through a post process or not.
  29897. */
  29898. /**
  29899. * Sets wether the image processing is applied through a post process or not.
  29900. */
  29901. applyByPostProcess: boolean;
  29902. private _isEnabled;
  29903. /**
  29904. * Gets wether the image processing is enabled or not.
  29905. */
  29906. /**
  29907. * Sets wether the image processing is enabled or not.
  29908. */
  29909. isEnabled: boolean;
  29910. /**
  29911. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29912. */
  29913. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29914. /**
  29915. * Method called each time the image processing information changes requires to recompile the effect.
  29916. */
  29917. protected _updateParameters(): void;
  29918. /**
  29919. * Gets the current class name.
  29920. * @return "ImageProcessingConfiguration"
  29921. */
  29922. getClassName(): string;
  29923. /**
  29924. * Prepare the list of uniforms associated with the Image Processing effects.
  29925. * @param uniforms The list of uniforms used in the effect
  29926. * @param defines the list of defines currently in use
  29927. */
  29928. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29929. /**
  29930. * Prepare the list of samplers associated with the Image Processing effects.
  29931. * @param samplersList The list of uniforms used in the effect
  29932. * @param defines the list of defines currently in use
  29933. */
  29934. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29935. /**
  29936. * Prepare the list of defines associated to the shader.
  29937. * @param defines the list of defines to complete
  29938. * @param forPostProcess Define if we are currently in post process mode or not
  29939. */
  29940. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29941. /**
  29942. * Returns true if all the image processing information are ready.
  29943. * @returns True if ready, otherwise, false
  29944. */
  29945. isReady(): boolean;
  29946. /**
  29947. * Binds the image processing to the shader.
  29948. * @param effect The effect to bind to
  29949. * @param aspectRatio Define the current aspect ratio of the effect
  29950. */
  29951. bind(effect: Effect, aspectRatio?: number): void;
  29952. /**
  29953. * Clones the current image processing instance.
  29954. * @return The cloned image processing
  29955. */
  29956. clone(): ImageProcessingConfiguration;
  29957. /**
  29958. * Serializes the current image processing instance to a json representation.
  29959. * @return a JSON representation
  29960. */
  29961. serialize(): any;
  29962. /**
  29963. * Parses the image processing from a json representation.
  29964. * @param source the JSON source to parse
  29965. * @return The parsed image processing
  29966. */
  29967. static Parse(source: any): ImageProcessingConfiguration;
  29968. private static _VIGNETTEMODE_MULTIPLY;
  29969. private static _VIGNETTEMODE_OPAQUE;
  29970. /**
  29971. * Used to apply the vignette as a mix with the pixel color.
  29972. */
  29973. static readonly VIGNETTEMODE_MULTIPLY: number;
  29974. /**
  29975. * Used to apply the vignette as a replacement of the pixel color.
  29976. */
  29977. static readonly VIGNETTEMODE_OPAQUE: number;
  29978. }
  29979. }
  29980. declare module "babylonjs/Materials/fresnelParameters" {
  29981. import { Color3 } from "babylonjs/Maths/math";
  29982. /**
  29983. * This represents all the required information to add a fresnel effect on a material:
  29984. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29985. */
  29986. export class FresnelParameters {
  29987. private _isEnabled;
  29988. /**
  29989. * Define if the fresnel effect is enable or not.
  29990. */
  29991. isEnabled: boolean;
  29992. /**
  29993. * Define the color used on edges (grazing angle)
  29994. */
  29995. leftColor: Color3;
  29996. /**
  29997. * Define the color used on center
  29998. */
  29999. rightColor: Color3;
  30000. /**
  30001. * Define bias applied to computed fresnel term
  30002. */
  30003. bias: number;
  30004. /**
  30005. * Defined the power exponent applied to fresnel term
  30006. */
  30007. power: number;
  30008. /**
  30009. * Clones the current fresnel and its valuues
  30010. * @returns a clone fresnel configuration
  30011. */
  30012. clone(): FresnelParameters;
  30013. /**
  30014. * Serializes the current fresnel parameters to a JSON representation.
  30015. * @return the JSON serialization
  30016. */
  30017. serialize(): any;
  30018. /**
  30019. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30020. * @param parsedFresnelParameters Define the JSON representation
  30021. * @returns the parsed parameters
  30022. */
  30023. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30024. }
  30025. }
  30026. declare module "babylonjs/Misc/decorators" {
  30027. import { Nullable } from "babylonjs/types";
  30028. import { Scene } from "babylonjs/scene";
  30029. import { IAnimatable } from "babylonjs/Misc/tools";
  30030. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30031. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30032. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30033. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30034. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30035. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30036. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30037. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30038. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30039. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30040. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30041. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30042. /**
  30043. * Decorator used to define property that can be serialized as reference to a camera
  30044. * @param sourceName defines the name of the property to decorate
  30045. */
  30046. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30047. /**
  30048. * Class used to help serialization objects
  30049. */
  30050. export class SerializationHelper {
  30051. /** hidden */
  30052. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30053. /** hidden */
  30054. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30055. /** hidden */
  30056. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30057. /** hidden */
  30058. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30059. /**
  30060. * Appends the serialized animations from the source animations
  30061. * @param source Source containing the animations
  30062. * @param destination Target to store the animations
  30063. */
  30064. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30065. /**
  30066. * Static function used to serialized a specific entity
  30067. * @param entity defines the entity to serialize
  30068. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30069. * @returns a JSON compatible object representing the serialization of the entity
  30070. */
  30071. static Serialize<T>(entity: T, serializationObject?: any): any;
  30072. /**
  30073. * Creates a new entity from a serialization data object
  30074. * @param creationFunction defines a function used to instanciated the new entity
  30075. * @param source defines the source serialization data
  30076. * @param scene defines the hosting scene
  30077. * @param rootUrl defines the root url for resources
  30078. * @returns a new entity
  30079. */
  30080. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30081. /**
  30082. * Clones an object
  30083. * @param creationFunction defines the function used to instanciate the new object
  30084. * @param source defines the source object
  30085. * @returns the cloned object
  30086. */
  30087. static Clone<T>(creationFunction: () => T, source: T): T;
  30088. /**
  30089. * Instanciates a new object based on a source one (some data will be shared between both object)
  30090. * @param creationFunction defines the function used to instanciate the new object
  30091. * @param source defines the source object
  30092. * @returns the new object
  30093. */
  30094. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30095. }
  30096. }
  30097. declare module "babylonjs/Cameras/camera" {
  30098. import { SmartArray } from "babylonjs/Misc/smartArray";
  30099. import { Observable } from "babylonjs/Misc/observable";
  30100. import { Nullable } from "babylonjs/types";
  30101. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30102. import { Scene } from "babylonjs/scene";
  30103. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30104. import { Node } from "babylonjs/node";
  30105. import { Mesh } from "babylonjs/Meshes/mesh";
  30106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30107. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30108. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30109. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30110. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30111. import { Ray } from "babylonjs/Culling/ray";
  30112. /**
  30113. * This is the base class of all the camera used in the application.
  30114. * @see http://doc.babylonjs.com/features/cameras
  30115. */
  30116. export class Camera extends Node {
  30117. /** @hidden */
  30118. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30119. /**
  30120. * This is the default projection mode used by the cameras.
  30121. * It helps recreating a feeling of perspective and better appreciate depth.
  30122. * This is the best way to simulate real life cameras.
  30123. */
  30124. static readonly PERSPECTIVE_CAMERA: number;
  30125. /**
  30126. * This helps creating camera with an orthographic mode.
  30127. * 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.
  30128. */
  30129. static readonly ORTHOGRAPHIC_CAMERA: number;
  30130. /**
  30131. * This is the default FOV mode for perspective cameras.
  30132. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30133. */
  30134. static readonly FOVMODE_VERTICAL_FIXED: number;
  30135. /**
  30136. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30137. */
  30138. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30139. /**
  30140. * This specifies ther is no need for a camera rig.
  30141. * Basically only one eye is rendered corresponding to the camera.
  30142. */
  30143. static readonly RIG_MODE_NONE: number;
  30144. /**
  30145. * Simulates a camera Rig with one blue eye and one red eye.
  30146. * This can be use with 3d blue and red glasses.
  30147. */
  30148. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30149. /**
  30150. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30151. */
  30152. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30153. /**
  30154. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30155. */
  30156. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30157. /**
  30158. * Defines that both eyes of the camera will be rendered over under each other.
  30159. */
  30160. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30161. /**
  30162. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30163. */
  30164. static readonly RIG_MODE_VR: number;
  30165. /**
  30166. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30167. */
  30168. static readonly RIG_MODE_WEBVR: number;
  30169. /**
  30170. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30171. */
  30172. static readonly RIG_MODE_CUSTOM: number;
  30173. /**
  30174. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30175. */
  30176. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30177. /**
  30178. * @hidden
  30179. * Might be removed once multiview will be a thing
  30180. */
  30181. static UseAlternateWebVRRendering: boolean;
  30182. /**
  30183. * Define the input manager associated with the camera.
  30184. */
  30185. inputs: CameraInputsManager<Camera>;
  30186. /** @hidden */
  30187. _position: Vector3;
  30188. /**
  30189. * Define the current local position of the camera in the scene
  30190. */
  30191. position: Vector3;
  30192. /**
  30193. * The vector the camera should consider as up.
  30194. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30195. */
  30196. upVector: Vector3;
  30197. /**
  30198. * Define the current limit on the left side for an orthographic camera
  30199. * In scene unit
  30200. */
  30201. orthoLeft: Nullable<number>;
  30202. /**
  30203. * Define the current limit on the right side for an orthographic camera
  30204. * In scene unit
  30205. */
  30206. orthoRight: Nullable<number>;
  30207. /**
  30208. * Define the current limit on the bottom side for an orthographic camera
  30209. * In scene unit
  30210. */
  30211. orthoBottom: Nullable<number>;
  30212. /**
  30213. * Define the current limit on the top side for an orthographic camera
  30214. * In scene unit
  30215. */
  30216. orthoTop: Nullable<number>;
  30217. /**
  30218. * Field Of View is set in Radians. (default is 0.8)
  30219. */
  30220. fov: number;
  30221. /**
  30222. * Define the minimum distance the camera can see from.
  30223. * This is important to note that the depth buffer are not infinite and the closer it starts
  30224. * the more your scene might encounter depth fighting issue.
  30225. */
  30226. minZ: number;
  30227. /**
  30228. * Define the maximum distance the camera can see to.
  30229. * This is important to note that the depth buffer are not infinite and the further it end
  30230. * the more your scene might encounter depth fighting issue.
  30231. */
  30232. maxZ: number;
  30233. /**
  30234. * Define the default inertia of the camera.
  30235. * This helps giving a smooth feeling to the camera movement.
  30236. */
  30237. inertia: number;
  30238. /**
  30239. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30240. */
  30241. mode: number;
  30242. /**
  30243. * Define wether the camera is intermediate.
  30244. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30245. */
  30246. isIntermediate: boolean;
  30247. /**
  30248. * Define the viewport of the camera.
  30249. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30250. */
  30251. viewport: Viewport;
  30252. /**
  30253. * Restricts the camera to viewing objects with the same layerMask.
  30254. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30255. */
  30256. layerMask: number;
  30257. /**
  30258. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30259. */
  30260. fovMode: number;
  30261. /**
  30262. * Rig mode of the camera.
  30263. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30264. * This is normally controlled byt the camera themselves as internal use.
  30265. */
  30266. cameraRigMode: number;
  30267. /**
  30268. * Defines the distance between both "eyes" in case of a RIG
  30269. */
  30270. interaxialDistance: number;
  30271. /**
  30272. * Defines if stereoscopic rendering is done side by side or over under.
  30273. */
  30274. isStereoscopicSideBySide: boolean;
  30275. /**
  30276. * 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
  30277. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30278. * else in the scene.
  30279. */
  30280. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30281. /**
  30282. * When set, the camera will render to this render target instead of the default canvas
  30283. */
  30284. outputRenderTarget: Nullable<RenderTargetTexture>;
  30285. /**
  30286. * Observable triggered when the camera view matrix has changed.
  30287. */
  30288. onViewMatrixChangedObservable: Observable<Camera>;
  30289. /**
  30290. * Observable triggered when the camera Projection matrix has changed.
  30291. */
  30292. onProjectionMatrixChangedObservable: Observable<Camera>;
  30293. /**
  30294. * Observable triggered when the inputs have been processed.
  30295. */
  30296. onAfterCheckInputsObservable: Observable<Camera>;
  30297. /**
  30298. * Observable triggered when reset has been called and applied to the camera.
  30299. */
  30300. onRestoreStateObservable: Observable<Camera>;
  30301. /** @hidden */
  30302. _cameraRigParams: any;
  30303. /** @hidden */
  30304. _rigCameras: Camera[];
  30305. /** @hidden */
  30306. _rigPostProcess: Nullable<PostProcess>;
  30307. protected _webvrViewMatrix: Matrix;
  30308. /** @hidden */
  30309. _skipRendering: boolean;
  30310. /** @hidden */
  30311. _alternateCamera: Camera;
  30312. /** @hidden */
  30313. _projectionMatrix: Matrix;
  30314. /** @hidden */
  30315. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30316. /** @hidden */
  30317. _activeMeshes: SmartArray<AbstractMesh>;
  30318. protected _globalPosition: Vector3;
  30319. /** hidden */
  30320. _computedViewMatrix: Matrix;
  30321. private _doNotComputeProjectionMatrix;
  30322. private _transformMatrix;
  30323. private _frustumPlanes;
  30324. private _refreshFrustumPlanes;
  30325. private _storedFov;
  30326. private _stateStored;
  30327. /**
  30328. * Instantiates a new camera object.
  30329. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30330. * @see http://doc.babylonjs.com/features/cameras
  30331. * @param name Defines the name of the camera in the scene
  30332. * @param position Defines the position of the camera
  30333. * @param scene Defines the scene the camera belongs too
  30334. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30335. */
  30336. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30337. /**
  30338. * Store current camera state (fov, position, etc..)
  30339. * @returns the camera
  30340. */
  30341. storeState(): Camera;
  30342. /**
  30343. * Restores the camera state values if it has been stored. You must call storeState() first
  30344. */
  30345. protected _restoreStateValues(): boolean;
  30346. /**
  30347. * Restored camera state. You must call storeState() first.
  30348. * @returns true if restored and false otherwise
  30349. */
  30350. restoreState(): boolean;
  30351. /**
  30352. * Gets the class name of the camera.
  30353. * @returns the class name
  30354. */
  30355. getClassName(): string;
  30356. /** @hidden */
  30357. readonly _isCamera: boolean;
  30358. /**
  30359. * Gets a string representation of the camera useful for debug purpose.
  30360. * @param fullDetails Defines that a more verboe level of logging is required
  30361. * @returns the string representation
  30362. */
  30363. toString(fullDetails?: boolean): string;
  30364. /**
  30365. * Gets the current world space position of the camera.
  30366. */
  30367. readonly globalPosition: Vector3;
  30368. /**
  30369. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30370. * @returns the active meshe list
  30371. */
  30372. getActiveMeshes(): SmartArray<AbstractMesh>;
  30373. /**
  30374. * Check wether a mesh is part of the current active mesh list of the camera
  30375. * @param mesh Defines the mesh to check
  30376. * @returns true if active, false otherwise
  30377. */
  30378. isActiveMesh(mesh: Mesh): boolean;
  30379. /**
  30380. * Is this camera ready to be used/rendered
  30381. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30382. * @return true if the camera is ready
  30383. */
  30384. isReady(completeCheck?: boolean): boolean;
  30385. /** @hidden */
  30386. _initCache(): void;
  30387. /** @hidden */
  30388. _updateCache(ignoreParentClass?: boolean): void;
  30389. /** @hidden */
  30390. _isSynchronized(): boolean;
  30391. /** @hidden */
  30392. _isSynchronizedViewMatrix(): boolean;
  30393. /** @hidden */
  30394. _isSynchronizedProjectionMatrix(): boolean;
  30395. /**
  30396. * Attach the input controls to a specific dom element to get the input from.
  30397. * @param element Defines the element the controls should be listened from
  30398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30399. */
  30400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30401. /**
  30402. * Detach the current controls from the specified dom element.
  30403. * @param element Defines the element to stop listening the inputs from
  30404. */
  30405. detachControl(element: HTMLElement): void;
  30406. /**
  30407. * Update the camera state according to the different inputs gathered during the frame.
  30408. */
  30409. update(): void;
  30410. /** @hidden */
  30411. _checkInputs(): void;
  30412. /** @hidden */
  30413. readonly rigCameras: Camera[];
  30414. /**
  30415. * Gets the post process used by the rig cameras
  30416. */
  30417. readonly rigPostProcess: Nullable<PostProcess>;
  30418. /**
  30419. * Internal, gets the first post proces.
  30420. * @returns the first post process to be run on this camera.
  30421. */
  30422. _getFirstPostProcess(): Nullable<PostProcess>;
  30423. private _cascadePostProcessesToRigCams;
  30424. /**
  30425. * Attach a post process to the camera.
  30426. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30427. * @param postProcess The post process to attach to the camera
  30428. * @param insertAt The position of the post process in case several of them are in use in the scene
  30429. * @returns the position the post process has been inserted at
  30430. */
  30431. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30432. /**
  30433. * Detach a post process to the camera.
  30434. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30435. * @param postProcess The post process to detach from the camera
  30436. */
  30437. detachPostProcess(postProcess: PostProcess): void;
  30438. /**
  30439. * Gets the current world matrix of the camera
  30440. */
  30441. getWorldMatrix(): Matrix;
  30442. /** @hidden */
  30443. _getViewMatrix(): Matrix;
  30444. /**
  30445. * Gets the current view matrix of the camera.
  30446. * @param force forces the camera to recompute the matrix without looking at the cached state
  30447. * @returns the view matrix
  30448. */
  30449. getViewMatrix(force?: boolean): Matrix;
  30450. /**
  30451. * Freeze the projection matrix.
  30452. * It will prevent the cache check of the camera projection compute and can speed up perf
  30453. * if no parameter of the camera are meant to change
  30454. * @param projection Defines manually a projection if necessary
  30455. */
  30456. freezeProjectionMatrix(projection?: Matrix): void;
  30457. /**
  30458. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30459. */
  30460. unfreezeProjectionMatrix(): void;
  30461. /**
  30462. * Gets the current projection matrix of the camera.
  30463. * @param force forces the camera to recompute the matrix without looking at the cached state
  30464. * @returns the projection matrix
  30465. */
  30466. getProjectionMatrix(force?: boolean): Matrix;
  30467. /**
  30468. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30469. * @returns a Matrix
  30470. */
  30471. getTransformationMatrix(): Matrix;
  30472. private _updateFrustumPlanes;
  30473. /**
  30474. * Checks if a cullable object (mesh...) is in the camera frustum
  30475. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30476. * @param target The object to check
  30477. * @returns true if the object is in frustum otherwise false
  30478. */
  30479. isInFrustum(target: ICullable): boolean;
  30480. /**
  30481. * Checks if a cullable object (mesh...) is in the camera frustum
  30482. * Unlike isInFrustum this cheks the full bounding box
  30483. * @param target The object to check
  30484. * @returns true if the object is in frustum otherwise false
  30485. */
  30486. isCompletelyInFrustum(target: ICullable): boolean;
  30487. /**
  30488. * Gets a ray in the forward direction from the camera.
  30489. * @param length Defines the length of the ray to create
  30490. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30491. * @param origin Defines the start point of the ray which defaults to the camera position
  30492. * @returns the forward ray
  30493. */
  30494. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30495. /**
  30496. * Releases resources associated with this node.
  30497. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30498. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30499. */
  30500. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30501. /** @hidden */
  30502. _isLeftCamera: boolean;
  30503. /**
  30504. * Gets the left camera of a rig setup in case of Rigged Camera
  30505. */
  30506. readonly isLeftCamera: boolean;
  30507. /** @hidden */
  30508. _isRightCamera: boolean;
  30509. /**
  30510. * Gets the right camera of a rig setup in case of Rigged Camera
  30511. */
  30512. readonly isRightCamera: boolean;
  30513. /**
  30514. * Gets the left camera of a rig setup in case of Rigged Camera
  30515. */
  30516. readonly leftCamera: Nullable<FreeCamera>;
  30517. /**
  30518. * Gets the right camera of a rig setup in case of Rigged Camera
  30519. */
  30520. readonly rightCamera: Nullable<FreeCamera>;
  30521. /**
  30522. * Gets the left camera target of a rig setup in case of Rigged Camera
  30523. * @returns the target position
  30524. */
  30525. getLeftTarget(): Nullable<Vector3>;
  30526. /**
  30527. * Gets the right camera target of a rig setup in case of Rigged Camera
  30528. * @returns the target position
  30529. */
  30530. getRightTarget(): Nullable<Vector3>;
  30531. /**
  30532. * @hidden
  30533. */
  30534. setCameraRigMode(mode: number, rigParams: any): void;
  30535. /** @hidden */
  30536. static _setStereoscopicRigMode(camera: Camera): void;
  30537. /** @hidden */
  30538. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30539. /** @hidden */
  30540. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30541. /** @hidden */
  30542. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30543. /** @hidden */
  30544. _getVRProjectionMatrix(): Matrix;
  30545. protected _updateCameraRotationMatrix(): void;
  30546. protected _updateWebVRCameraRotationMatrix(): void;
  30547. /**
  30548. * This function MUST be overwritten by the different WebVR cameras available.
  30549. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30550. * @hidden
  30551. */
  30552. _getWebVRProjectionMatrix(): Matrix;
  30553. /**
  30554. * This function MUST be overwritten by the different WebVR cameras available.
  30555. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30556. * @hidden
  30557. */
  30558. _getWebVRViewMatrix(): Matrix;
  30559. /** @hidden */
  30560. setCameraRigParameter(name: string, value: any): void;
  30561. /**
  30562. * needs to be overridden by children so sub has required properties to be copied
  30563. * @hidden
  30564. */
  30565. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30566. /**
  30567. * May need to be overridden by children
  30568. * @hidden
  30569. */
  30570. _updateRigCameras(): void;
  30571. /** @hidden */
  30572. _setupInputs(): void;
  30573. /**
  30574. * Serialiaze the camera setup to a json represention
  30575. * @returns the JSON representation
  30576. */
  30577. serialize(): any;
  30578. /**
  30579. * Clones the current camera.
  30580. * @param name The cloned camera name
  30581. * @returns the cloned camera
  30582. */
  30583. clone(name: string): Camera;
  30584. /**
  30585. * Gets the direction of the camera relative to a given local axis.
  30586. * @param localAxis Defines the reference axis to provide a relative direction.
  30587. * @return the direction
  30588. */
  30589. getDirection(localAxis: Vector3): Vector3;
  30590. /**
  30591. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30592. * @param localAxis Defines the reference axis to provide a relative direction.
  30593. * @param result Defines the vector to store the result in
  30594. */
  30595. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30596. /**
  30597. * Gets a camera constructor for a given camera type
  30598. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30599. * @param name The name of the camera the result will be able to instantiate
  30600. * @param scene The scene the result will construct the camera in
  30601. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30602. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30603. * @returns a factory method to construc the camera
  30604. */
  30605. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30606. /**
  30607. * Compute the world matrix of the camera.
  30608. * @returns the camera workd matrix
  30609. */
  30610. computeWorldMatrix(): Matrix;
  30611. /**
  30612. * Parse a JSON and creates the camera from the parsed information
  30613. * @param parsedCamera The JSON to parse
  30614. * @param scene The scene to instantiate the camera in
  30615. * @returns the newly constructed camera
  30616. */
  30617. static Parse(parsedCamera: any, scene: Scene): Camera;
  30618. }
  30619. }
  30620. declare module "babylonjs/Misc/tools" {
  30621. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30622. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30623. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30624. import { Observable } from "babylonjs/Misc/observable";
  30625. import { DomManagement } from "babylonjs/Misc/domManagement";
  30626. import { Camera } from "babylonjs/Cameras/camera";
  30627. import { Engine } from "babylonjs/Engines/engine";
  30628. import { Animation } from "babylonjs/Animations/animation";
  30629. /**
  30630. * Interface for any object that can request an animation frame
  30631. */
  30632. export interface ICustomAnimationFrameRequester {
  30633. /**
  30634. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30635. */
  30636. renderFunction?: Function;
  30637. /**
  30638. * Called to request the next frame to render to
  30639. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30640. */
  30641. requestAnimationFrame: Function;
  30642. /**
  30643. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30644. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30645. */
  30646. requestID?: number;
  30647. }
  30648. /**
  30649. * Interface containing an array of animations
  30650. */
  30651. export interface IAnimatable {
  30652. /**
  30653. * Array of animations
  30654. */
  30655. animations: Array<Animation>;
  30656. }
  30657. /** Interface used by value gradients (color, factor, ...) */
  30658. export interface IValueGradient {
  30659. /**
  30660. * Gets or sets the gradient value (between 0 and 1)
  30661. */
  30662. gradient: number;
  30663. }
  30664. /** Class used to store color4 gradient */
  30665. export class ColorGradient implements IValueGradient {
  30666. /**
  30667. * Gets or sets the gradient value (between 0 and 1)
  30668. */
  30669. gradient: number;
  30670. /**
  30671. * Gets or sets first associated color
  30672. */
  30673. color1: Color4;
  30674. /**
  30675. * Gets or sets second associated color
  30676. */
  30677. color2?: Color4;
  30678. /**
  30679. * Will get a color picked randomly between color1 and color2.
  30680. * If color2 is undefined then color1 will be used
  30681. * @param result defines the target Color4 to store the result in
  30682. */
  30683. getColorToRef(result: Color4): void;
  30684. }
  30685. /** Class used to store color 3 gradient */
  30686. export class Color3Gradient implements IValueGradient {
  30687. /**
  30688. * Gets or sets the gradient value (between 0 and 1)
  30689. */
  30690. gradient: number;
  30691. /**
  30692. * Gets or sets the associated color
  30693. */
  30694. color: Color3;
  30695. }
  30696. /** Class used to store factor gradient */
  30697. export class FactorGradient implements IValueGradient {
  30698. /**
  30699. * Gets or sets the gradient value (between 0 and 1)
  30700. */
  30701. gradient: number;
  30702. /**
  30703. * Gets or sets first associated factor
  30704. */
  30705. factor1: number;
  30706. /**
  30707. * Gets or sets second associated factor
  30708. */
  30709. factor2?: number;
  30710. /**
  30711. * Will get a number picked randomly between factor1 and factor2.
  30712. * If factor2 is undefined then factor1 will be used
  30713. * @returns the picked number
  30714. */
  30715. getFactor(): number;
  30716. }
  30717. /**
  30718. * @ignore
  30719. * Application error to support additional information when loading a file
  30720. */
  30721. export class LoadFileError extends Error {
  30722. /** defines the optional XHR request */
  30723. request?: XMLHttpRequest | undefined;
  30724. private static _setPrototypeOf;
  30725. /**
  30726. * Creates a new LoadFileError
  30727. * @param message defines the message of the error
  30728. * @param request defines the optional XHR request
  30729. */
  30730. constructor(message: string,
  30731. /** defines the optional XHR request */
  30732. request?: XMLHttpRequest | undefined);
  30733. }
  30734. /**
  30735. * Class used to define a retry strategy when error happens while loading assets
  30736. */
  30737. export class RetryStrategy {
  30738. /**
  30739. * Function used to defines an exponential back off strategy
  30740. * @param maxRetries defines the maximum number of retries (3 by default)
  30741. * @param baseInterval defines the interval between retries
  30742. * @returns the strategy function to use
  30743. */
  30744. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30745. }
  30746. /**
  30747. * File request interface
  30748. */
  30749. export interface IFileRequest {
  30750. /**
  30751. * Raised when the request is complete (success or error).
  30752. */
  30753. onCompleteObservable: Observable<IFileRequest>;
  30754. /**
  30755. * Aborts the request for a file.
  30756. */
  30757. abort: () => void;
  30758. }
  30759. /**
  30760. * Class containing a set of static utilities functions
  30761. */
  30762. export class Tools {
  30763. /**
  30764. * Gets or sets the base URL to use to load assets
  30765. */
  30766. static BaseUrl: string;
  30767. /**
  30768. * Enable/Disable Custom HTTP Request Headers globally.
  30769. * default = false
  30770. * @see CustomRequestHeaders
  30771. */
  30772. static UseCustomRequestHeaders: boolean;
  30773. /**
  30774. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30775. * i.e. when loading files, where the server/service expects an Authorization header.
  30776. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30777. */
  30778. static CustomRequestHeaders: {
  30779. [key: string]: string;
  30780. };
  30781. /**
  30782. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30783. */
  30784. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30785. /**
  30786. * Default behaviour for cors in the application.
  30787. * It can be a string if the expected behavior is identical in the entire app.
  30788. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30789. */
  30790. static CorsBehavior: string | ((url: string | string[]) => string);
  30791. /**
  30792. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30793. * @ignorenaming
  30794. */
  30795. static UseFallbackTexture: boolean;
  30796. /**
  30797. * Use this object to register external classes like custom textures or material
  30798. * to allow the laoders to instantiate them
  30799. */
  30800. static RegisteredExternalClasses: {
  30801. [key: string]: Object;
  30802. };
  30803. /**
  30804. * Texture content used if a texture cannot loaded
  30805. * @ignorenaming
  30806. */
  30807. static fallbackTexture: string;
  30808. /**
  30809. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30810. * @param u defines the coordinate on X axis
  30811. * @param v defines the coordinate on Y axis
  30812. * @param width defines the width of the source data
  30813. * @param height defines the height of the source data
  30814. * @param pixels defines the source byte array
  30815. * @param color defines the output color
  30816. */
  30817. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30818. /**
  30819. * Interpolates between a and b via alpha
  30820. * @param a The lower value (returned when alpha = 0)
  30821. * @param b The upper value (returned when alpha = 1)
  30822. * @param alpha The interpolation-factor
  30823. * @return The mixed value
  30824. */
  30825. static Mix(a: number, b: number, alpha: number): number;
  30826. /**
  30827. * Tries to instantiate a new object from a given class name
  30828. * @param className defines the class name to instantiate
  30829. * @returns the new object or null if the system was not able to do the instantiation
  30830. */
  30831. static Instantiate(className: string): any;
  30832. /**
  30833. * Provides a slice function that will work even on IE
  30834. * @param data defines the array to slice
  30835. * @param start defines the start of the data (optional)
  30836. * @param end defines the end of the data (optional)
  30837. * @returns the new sliced array
  30838. */
  30839. static Slice<T>(data: T, start?: number, end?: number): T;
  30840. /**
  30841. * Polyfill for setImmediate
  30842. * @param action defines the action to execute after the current execution block
  30843. */
  30844. static SetImmediate(action: () => void): void;
  30845. /**
  30846. * Function indicating if a number is an exponent of 2
  30847. * @param value defines the value to test
  30848. * @returns true if the value is an exponent of 2
  30849. */
  30850. static IsExponentOfTwo(value: number): boolean;
  30851. private static _tmpFloatArray;
  30852. /**
  30853. * Returns the nearest 32-bit single precision float representation of a Number
  30854. * @param value A Number. If the parameter is of a different type, it will get converted
  30855. * to a number or to NaN if it cannot be converted
  30856. * @returns number
  30857. */
  30858. static FloatRound(value: number): number;
  30859. /**
  30860. * Find the next highest power of two.
  30861. * @param x Number to start search from.
  30862. * @return Next highest power of two.
  30863. */
  30864. static CeilingPOT(x: number): number;
  30865. /**
  30866. * Find the next lowest power of two.
  30867. * @param x Number to start search from.
  30868. * @return Next lowest power of two.
  30869. */
  30870. static FloorPOT(x: number): number;
  30871. /**
  30872. * Find the nearest power of two.
  30873. * @param x Number to start search from.
  30874. * @return Next nearest power of two.
  30875. */
  30876. static NearestPOT(x: number): number;
  30877. /**
  30878. * Get the closest exponent of two
  30879. * @param value defines the value to approximate
  30880. * @param max defines the maximum value to return
  30881. * @param mode defines how to define the closest value
  30882. * @returns closest exponent of two of the given value
  30883. */
  30884. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30885. /**
  30886. * Extracts the filename from a path
  30887. * @param path defines the path to use
  30888. * @returns the filename
  30889. */
  30890. static GetFilename(path: string): string;
  30891. /**
  30892. * Extracts the "folder" part of a path (everything before the filename).
  30893. * @param uri The URI to extract the info from
  30894. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30895. * @returns The "folder" part of the path
  30896. */
  30897. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30898. /**
  30899. * Extracts text content from a DOM element hierarchy
  30900. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30901. */
  30902. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30903. /**
  30904. * Convert an angle in radians to degrees
  30905. * @param angle defines the angle to convert
  30906. * @returns the angle in degrees
  30907. */
  30908. static ToDegrees(angle: number): number;
  30909. /**
  30910. * Convert an angle in degrees to radians
  30911. * @param angle defines the angle to convert
  30912. * @returns the angle in radians
  30913. */
  30914. static ToRadians(angle: number): number;
  30915. /**
  30916. * Encode a buffer to a base64 string
  30917. * @param buffer defines the buffer to encode
  30918. * @returns the encoded string
  30919. */
  30920. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30921. /**
  30922. * Extracts minimum and maximum values from a list of indexed positions
  30923. * @param positions defines the positions to use
  30924. * @param indices defines the indices to the positions
  30925. * @param indexStart defines the start index
  30926. * @param indexCount defines the end index
  30927. * @param bias defines bias value to add to the result
  30928. * @return minimum and maximum values
  30929. */
  30930. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30931. minimum: Vector3;
  30932. maximum: Vector3;
  30933. };
  30934. /**
  30935. * Extracts minimum and maximum values from a list of positions
  30936. * @param positions defines the positions to use
  30937. * @param start defines the start index in the positions array
  30938. * @param count defines the number of positions to handle
  30939. * @param bias defines bias value to add to the result
  30940. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30941. * @return minimum and maximum values
  30942. */
  30943. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30944. minimum: Vector3;
  30945. maximum: Vector3;
  30946. };
  30947. /**
  30948. * Returns an array if obj is not an array
  30949. * @param obj defines the object to evaluate as an array
  30950. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30951. * @returns either obj directly if obj is an array or a new array containing obj
  30952. */
  30953. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30954. /**
  30955. * Gets the pointer prefix to use
  30956. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30957. */
  30958. static GetPointerPrefix(): string;
  30959. /**
  30960. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30961. * @param func - the function to be called
  30962. * @param requester - the object that will request the next frame. Falls back to window.
  30963. * @returns frame number
  30964. */
  30965. static QueueNewFrame(func: () => void, requester?: any): number;
  30966. /**
  30967. * Ask the browser to promote the current element to fullscreen rendering mode
  30968. * @param element defines the DOM element to promote
  30969. */
  30970. static RequestFullscreen(element: HTMLElement): void;
  30971. /**
  30972. * Asks the browser to exit fullscreen mode
  30973. */
  30974. static ExitFullscreen(): void;
  30975. /**
  30976. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30977. * @param url define the url we are trying
  30978. * @param element define the dom element where to configure the cors policy
  30979. */
  30980. static SetCorsBehavior(url: string | string[], element: {
  30981. crossOrigin: string | null;
  30982. }): void;
  30983. /**
  30984. * Removes unwanted characters from an url
  30985. * @param url defines the url to clean
  30986. * @returns the cleaned url
  30987. */
  30988. static CleanUrl(url: string): string;
  30989. /**
  30990. * Gets or sets a function used to pre-process url before using them to load assets
  30991. */
  30992. static PreprocessUrl: (url: string) => string;
  30993. /**
  30994. * Loads an image as an HTMLImageElement.
  30995. * @param input url string, ArrayBuffer, or Blob to load
  30996. * @param onLoad callback called when the image successfully loads
  30997. * @param onError callback called when the image fails to load
  30998. * @param offlineProvider offline provider for caching
  30999. * @returns the HTMLImageElement of the loaded image
  31000. */
  31001. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31002. /**
  31003. * Loads a file
  31004. * @param url url string, ArrayBuffer, or Blob to load
  31005. * @param onSuccess callback called when the file successfully loads
  31006. * @param onProgress callback called while file is loading (if the server supports this mode)
  31007. * @param offlineProvider defines the offline provider for caching
  31008. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31009. * @param onError callback called when the file fails to load
  31010. * @returns a file request object
  31011. */
  31012. 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;
  31013. /**
  31014. * Load a script (identified by an url). When the url returns, the
  31015. * content of this file is added into a new script element, attached to the DOM (body element)
  31016. * @param scriptUrl defines the url of the script to laod
  31017. * @param onSuccess defines the callback called when the script is loaded
  31018. * @param onError defines the callback to call if an error occurs
  31019. */
  31020. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31021. /**
  31022. * Loads a file from a blob
  31023. * @param fileToLoad defines the blob to use
  31024. * @param callback defines the callback to call when data is loaded
  31025. * @param progressCallback defines the callback to call during loading process
  31026. * @returns a file request object
  31027. */
  31028. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31029. /**
  31030. * Loads a file
  31031. * @param fileToLoad defines the file to load
  31032. * @param callback defines the callback to call when data is loaded
  31033. * @param progressCallBack defines the callback to call during loading process
  31034. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31035. * @returns a file request object
  31036. */
  31037. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31038. /**
  31039. * Creates a data url from a given string content
  31040. * @param content defines the content to convert
  31041. * @returns the new data url link
  31042. */
  31043. static FileAsURL(content: string): string;
  31044. /**
  31045. * Format the given number to a specific decimal format
  31046. * @param value defines the number to format
  31047. * @param decimals defines the number of decimals to use
  31048. * @returns the formatted string
  31049. */
  31050. static Format(value: number, decimals?: number): string;
  31051. /**
  31052. * Checks if a given vector is inside a specific range
  31053. * @param v defines the vector to test
  31054. * @param min defines the minimum range
  31055. * @param max defines the maximum range
  31056. */
  31057. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31058. /**
  31059. * Tries to copy an object by duplicating every property
  31060. * @param source defines the source object
  31061. * @param destination defines the target object
  31062. * @param doNotCopyList defines a list of properties to avoid
  31063. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31064. */
  31065. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31066. /**
  31067. * Gets a boolean indicating if the given object has no own property
  31068. * @param obj defines the object to test
  31069. * @returns true if object has no own property
  31070. */
  31071. static IsEmpty(obj: any): boolean;
  31072. /**
  31073. * Function used to register events at window level
  31074. * @param events defines the events to register
  31075. */
  31076. static RegisterTopRootEvents(events: {
  31077. name: string;
  31078. handler: Nullable<(e: FocusEvent) => any>;
  31079. }[]): void;
  31080. /**
  31081. * Function used to unregister events from window level
  31082. * @param events defines the events to unregister
  31083. */
  31084. static UnregisterTopRootEvents(events: {
  31085. name: string;
  31086. handler: Nullable<(e: FocusEvent) => any>;
  31087. }[]): void;
  31088. /**
  31089. * @ignore
  31090. */
  31091. static _ScreenshotCanvas: HTMLCanvasElement;
  31092. /**
  31093. * Dumps the current bound framebuffer
  31094. * @param width defines the rendering width
  31095. * @param height defines the rendering height
  31096. * @param engine defines the hosting engine
  31097. * @param successCallback defines the callback triggered once the data are available
  31098. * @param mimeType defines the mime type of the result
  31099. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31100. */
  31101. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31102. /**
  31103. * Converts the canvas data to blob.
  31104. * This acts as a polyfill for browsers not supporting the to blob function.
  31105. * @param canvas Defines the canvas to extract the data from
  31106. * @param successCallback Defines the callback triggered once the data are available
  31107. * @param mimeType Defines the mime type of the result
  31108. */
  31109. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31110. /**
  31111. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31112. * @param successCallback defines the callback triggered once the data are available
  31113. * @param mimeType defines the mime type of the result
  31114. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31115. */
  31116. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31117. /**
  31118. * Downloads a blob in the browser
  31119. * @param blob defines the blob to download
  31120. * @param fileName defines the name of the downloaded file
  31121. */
  31122. static Download(blob: Blob, fileName: string): void;
  31123. /**
  31124. * Captures a screenshot of the current rendering
  31125. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31126. * @param engine defines the rendering engine
  31127. * @param camera defines the source camera
  31128. * @param size This parameter can be set to a single number or to an object with the
  31129. * following (optional) properties: precision, width, height. If a single number is passed,
  31130. * it will be used for both width and height. If an object is passed, the screenshot size
  31131. * will be derived from the parameters. The precision property is a multiplier allowing
  31132. * rendering at a higher or lower resolution
  31133. * @param successCallback defines the callback receives a single parameter which contains the
  31134. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31135. * src parameter of an <img> to display it
  31136. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31137. * Check your browser for supported MIME types
  31138. */
  31139. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31140. /**
  31141. * Generates an image screenshot from the specified camera.
  31142. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31143. * @param engine The engine to use for rendering
  31144. * @param camera The camera to use for rendering
  31145. * @param size This parameter can be set to a single number or to an object with the
  31146. * following (optional) properties: precision, width, height. If a single number is passed,
  31147. * it will be used for both width and height. If an object is passed, the screenshot size
  31148. * will be derived from the parameters. The precision property is a multiplier allowing
  31149. * rendering at a higher or lower resolution
  31150. * @param successCallback The callback receives a single parameter which contains the
  31151. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31152. * src parameter of an <img> to display it
  31153. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31154. * Check your browser for supported MIME types
  31155. * @param samples Texture samples (default: 1)
  31156. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31157. * @param fileName A name for for the downloaded file.
  31158. */
  31159. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31160. /**
  31161. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31162. * Be aware Math.random() could cause collisions, but:
  31163. * "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"
  31164. * @returns a pseudo random id
  31165. */
  31166. static RandomId(): string;
  31167. /**
  31168. * Test if the given uri is a base64 string
  31169. * @param uri The uri to test
  31170. * @return True if the uri is a base64 string or false otherwise
  31171. */
  31172. static IsBase64(uri: string): boolean;
  31173. /**
  31174. * Decode the given base64 uri.
  31175. * @param uri The uri to decode
  31176. * @return The decoded base64 data.
  31177. */
  31178. static DecodeBase64(uri: string): ArrayBuffer;
  31179. /**
  31180. * No log
  31181. */
  31182. static readonly NoneLogLevel: number;
  31183. /**
  31184. * Only message logs
  31185. */
  31186. static readonly MessageLogLevel: number;
  31187. /**
  31188. * Only warning logs
  31189. */
  31190. static readonly WarningLogLevel: number;
  31191. /**
  31192. * Only error logs
  31193. */
  31194. static readonly ErrorLogLevel: number;
  31195. /**
  31196. * All logs
  31197. */
  31198. static readonly AllLogLevel: number;
  31199. /**
  31200. * Gets a value indicating the number of loading errors
  31201. * @ignorenaming
  31202. */
  31203. static readonly errorsCount: number;
  31204. /**
  31205. * Callback called when a new log is added
  31206. */
  31207. static OnNewCacheEntry: (entry: string) => void;
  31208. /**
  31209. * Log a message to the console
  31210. * @param message defines the message to log
  31211. */
  31212. static Log(message: string): void;
  31213. /**
  31214. * Write a warning message to the console
  31215. * @param message defines the message to log
  31216. */
  31217. static Warn(message: string): void;
  31218. /**
  31219. * Write an error message to the console
  31220. * @param message defines the message to log
  31221. */
  31222. static Error(message: string): void;
  31223. /**
  31224. * Gets current log cache (list of logs)
  31225. */
  31226. static readonly LogCache: string;
  31227. /**
  31228. * Clears the log cache
  31229. */
  31230. static ClearLogCache(): void;
  31231. /**
  31232. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31233. */
  31234. static LogLevels: number;
  31235. /**
  31236. * Checks if the loaded document was accessed via `file:`-Protocol.
  31237. * @returns boolean
  31238. */
  31239. static IsFileURL(): boolean;
  31240. /**
  31241. * Checks if the window object exists
  31242. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31243. */
  31244. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31245. /**
  31246. * No performance log
  31247. */
  31248. static readonly PerformanceNoneLogLevel: number;
  31249. /**
  31250. * Use user marks to log performance
  31251. */
  31252. static readonly PerformanceUserMarkLogLevel: number;
  31253. /**
  31254. * Log performance to the console
  31255. */
  31256. static readonly PerformanceConsoleLogLevel: number;
  31257. private static _performance;
  31258. /**
  31259. * Sets the current performance log level
  31260. */
  31261. static PerformanceLogLevel: number;
  31262. private static _StartPerformanceCounterDisabled;
  31263. private static _EndPerformanceCounterDisabled;
  31264. private static _StartUserMark;
  31265. private static _EndUserMark;
  31266. private static _StartPerformanceConsole;
  31267. private static _EndPerformanceConsole;
  31268. /**
  31269. * Injects the @see CustomRequestHeaders into the given request
  31270. * @param request the request that should be used for injection
  31271. */
  31272. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31273. /**
  31274. * Starts a performance counter
  31275. */
  31276. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31277. /**
  31278. * Ends a specific performance coutner
  31279. */
  31280. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31281. /**
  31282. * Gets either window.performance.now() if supported or Date.now() else
  31283. */
  31284. static readonly Now: number;
  31285. /**
  31286. * This method will return the name of the class used to create the instance of the given object.
  31287. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31288. * @param object the object to get the class name from
  31289. * @param isType defines if the object is actually a type
  31290. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31291. */
  31292. static GetClassName(object: any, isType?: boolean): string;
  31293. /**
  31294. * Gets the first element of an array satisfying a given predicate
  31295. * @param array defines the array to browse
  31296. * @param predicate defines the predicate to use
  31297. * @returns null if not found or the element
  31298. */
  31299. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31300. /**
  31301. * This method will return the name of the full name of the class, including its owning module (if any).
  31302. * 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).
  31303. * @param object the object to get the class name from
  31304. * @param isType defines if the object is actually a type
  31305. * @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.
  31306. * @ignorenaming
  31307. */
  31308. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31309. /**
  31310. * Returns a promise that resolves after the given amount of time.
  31311. * @param delay Number of milliseconds to delay
  31312. * @returns Promise that resolves after the given amount of time
  31313. */
  31314. static DelayAsync(delay: number): Promise<void>;
  31315. /**
  31316. * Gets the current gradient from an array of IValueGradient
  31317. * @param ratio defines the current ratio to get
  31318. * @param gradients defines the array of IValueGradient
  31319. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31320. */
  31321. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31322. }
  31323. /**
  31324. * This class is used to track a performance counter which is number based.
  31325. * The user has access to many properties which give statistics of different nature.
  31326. *
  31327. * The implementer can track two kinds of Performance Counter: time and count.
  31328. * 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.
  31329. * 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.
  31330. */
  31331. export class PerfCounter {
  31332. /**
  31333. * Gets or sets a global boolean to turn on and off all the counters
  31334. */
  31335. static Enabled: boolean;
  31336. /**
  31337. * Returns the smallest value ever
  31338. */
  31339. readonly min: number;
  31340. /**
  31341. * Returns the biggest value ever
  31342. */
  31343. readonly max: number;
  31344. /**
  31345. * Returns the average value since the performance counter is running
  31346. */
  31347. readonly average: number;
  31348. /**
  31349. * Returns the average value of the last second the counter was monitored
  31350. */
  31351. readonly lastSecAverage: number;
  31352. /**
  31353. * Returns the current value
  31354. */
  31355. readonly current: number;
  31356. /**
  31357. * Gets the accumulated total
  31358. */
  31359. readonly total: number;
  31360. /**
  31361. * Gets the total value count
  31362. */
  31363. readonly count: number;
  31364. /**
  31365. * Creates a new counter
  31366. */
  31367. constructor();
  31368. /**
  31369. * Call this method to start monitoring a new frame.
  31370. * 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.
  31371. */
  31372. fetchNewFrame(): void;
  31373. /**
  31374. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31375. * @param newCount the count value to add to the monitored count
  31376. * @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.
  31377. */
  31378. addCount(newCount: number, fetchResult: boolean): void;
  31379. /**
  31380. * Start monitoring this performance counter
  31381. */
  31382. beginMonitoring(): void;
  31383. /**
  31384. * Compute the time lapsed since the previous beginMonitoring() call.
  31385. * @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
  31386. */
  31387. endMonitoring(newFrame?: boolean): void;
  31388. private _fetchResult;
  31389. private _startMonitoringTime;
  31390. private _min;
  31391. private _max;
  31392. private _average;
  31393. private _current;
  31394. private _totalValueCount;
  31395. private _totalAccumulated;
  31396. private _lastSecAverage;
  31397. private _lastSecAccumulated;
  31398. private _lastSecTime;
  31399. private _lastSecValueCount;
  31400. }
  31401. /**
  31402. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31403. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31404. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31405. * @param name The name of the class, case should be preserved
  31406. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31407. */
  31408. export function className(name: string, module?: string): (target: Object) => void;
  31409. /**
  31410. * An implementation of a loop for asynchronous functions.
  31411. */
  31412. export class AsyncLoop {
  31413. /**
  31414. * Defines the number of iterations for the loop
  31415. */
  31416. iterations: number;
  31417. /**
  31418. * Defines the current index of the loop.
  31419. */
  31420. index: number;
  31421. private _done;
  31422. private _fn;
  31423. private _successCallback;
  31424. /**
  31425. * Constructor.
  31426. * @param iterations the number of iterations.
  31427. * @param func the function to run each iteration
  31428. * @param successCallback the callback that will be called upon succesful execution
  31429. * @param offset starting offset.
  31430. */
  31431. constructor(
  31432. /**
  31433. * Defines the number of iterations for the loop
  31434. */
  31435. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31436. /**
  31437. * Execute the next iteration. Must be called after the last iteration was finished.
  31438. */
  31439. executeNext(): void;
  31440. /**
  31441. * Break the loop and run the success callback.
  31442. */
  31443. breakLoop(): void;
  31444. /**
  31445. * Create and run an async loop.
  31446. * @param iterations the number of iterations.
  31447. * @param fn the function to run each iteration
  31448. * @param successCallback the callback that will be called upon succesful execution
  31449. * @param offset starting offset.
  31450. * @returns the created async loop object
  31451. */
  31452. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31453. /**
  31454. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31455. * @param iterations total number of iterations
  31456. * @param syncedIterations number of synchronous iterations in each async iteration.
  31457. * @param fn the function to call each iteration.
  31458. * @param callback a success call back that will be called when iterating stops.
  31459. * @param breakFunction a break condition (optional)
  31460. * @param timeout timeout settings for the setTimeout function. default - 0.
  31461. * @returns the created async loop object
  31462. */
  31463. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31464. }
  31465. }
  31466. declare module "babylonjs/Collisions/collisionCoordinator" {
  31467. import { Nullable } from "babylonjs/types";
  31468. import { Scene } from "babylonjs/scene";
  31469. import { Vector3 } from "babylonjs/Maths/math";
  31470. import { Collider } from "babylonjs/Collisions/collider";
  31471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31472. /** @hidden */
  31473. export interface ICollisionCoordinator {
  31474. createCollider(): Collider;
  31475. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31476. init(scene: Scene): void;
  31477. }
  31478. /** @hidden */
  31479. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31480. private _scene;
  31481. private _scaledPosition;
  31482. private _scaledVelocity;
  31483. private _finalPosition;
  31484. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31485. createCollider(): Collider;
  31486. init(scene: Scene): void;
  31487. private _collideWithWorld;
  31488. }
  31489. }
  31490. declare module "babylonjs/Animations/animationGroup" {
  31491. import { Animatable } from "babylonjs/Animations/animatable";
  31492. import { Animation } from "babylonjs/Animations/animation";
  31493. import { Scene, IDisposable } from "babylonjs/scene";
  31494. import { Observable } from "babylonjs/Misc/observable";
  31495. import { Nullable } from "babylonjs/types";
  31496. /**
  31497. * This class defines the direct association between an animation and a target
  31498. */
  31499. export class TargetedAnimation {
  31500. /**
  31501. * Animation to perform
  31502. */
  31503. animation: Animation;
  31504. /**
  31505. * Target to animate
  31506. */
  31507. target: any;
  31508. }
  31509. /**
  31510. * Use this class to create coordinated animations on multiple targets
  31511. */
  31512. export class AnimationGroup implements IDisposable {
  31513. /** The name of the animation group */
  31514. name: string;
  31515. private _scene;
  31516. private _targetedAnimations;
  31517. private _animatables;
  31518. private _from;
  31519. private _to;
  31520. private _isStarted;
  31521. private _isPaused;
  31522. private _speedRatio;
  31523. /**
  31524. * Gets or sets the unique id of the node
  31525. */
  31526. uniqueId: number;
  31527. /**
  31528. * This observable will notify when one animation have ended
  31529. */
  31530. onAnimationEndObservable: Observable<TargetedAnimation>;
  31531. /**
  31532. * Observer raised when one animation loops
  31533. */
  31534. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31535. /**
  31536. * This observable will notify when all animations have ended.
  31537. */
  31538. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31539. /**
  31540. * This observable will notify when all animations have paused.
  31541. */
  31542. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31543. /**
  31544. * This observable will notify when all animations are playing.
  31545. */
  31546. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31547. /**
  31548. * Gets the first frame
  31549. */
  31550. readonly from: number;
  31551. /**
  31552. * Gets the last frame
  31553. */
  31554. readonly to: number;
  31555. /**
  31556. * Define if the animations are started
  31557. */
  31558. readonly isStarted: boolean;
  31559. /**
  31560. * Gets a value indicating that the current group is playing
  31561. */
  31562. readonly isPlaying: boolean;
  31563. /**
  31564. * Gets or sets the speed ratio to use for all animations
  31565. */
  31566. /**
  31567. * Gets or sets the speed ratio to use for all animations
  31568. */
  31569. speedRatio: number;
  31570. /**
  31571. * Gets the targeted animations for this animation group
  31572. */
  31573. readonly targetedAnimations: Array<TargetedAnimation>;
  31574. /**
  31575. * returning the list of animatables controlled by this animation group.
  31576. */
  31577. readonly animatables: Array<Animatable>;
  31578. /**
  31579. * Instantiates a new Animation Group.
  31580. * This helps managing several animations at once.
  31581. * @see http://doc.babylonjs.com/how_to/group
  31582. * @param name Defines the name of the group
  31583. * @param scene Defines the scene the group belongs to
  31584. */
  31585. constructor(
  31586. /** The name of the animation group */
  31587. name: string, scene?: Nullable<Scene>);
  31588. /**
  31589. * Add an animation (with its target) in the group
  31590. * @param animation defines the animation we want to add
  31591. * @param target defines the target of the animation
  31592. * @returns the TargetedAnimation object
  31593. */
  31594. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31595. /**
  31596. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31597. * It can add constant keys at begin or end
  31598. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31599. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31600. * @returns the animation group
  31601. */
  31602. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31603. /**
  31604. * Start all animations on given targets
  31605. * @param loop defines if animations must loop
  31606. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31607. * @param from defines the from key (optional)
  31608. * @param to defines the to key (optional)
  31609. * @returns the current animation group
  31610. */
  31611. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31612. /**
  31613. * Pause all animations
  31614. * @returns the animation group
  31615. */
  31616. pause(): AnimationGroup;
  31617. /**
  31618. * Play all animations to initial state
  31619. * This function will start() the animations if they were not started or will restart() them if they were paused
  31620. * @param loop defines if animations must loop
  31621. * @returns the animation group
  31622. */
  31623. play(loop?: boolean): AnimationGroup;
  31624. /**
  31625. * Reset all animations to initial state
  31626. * @returns the animation group
  31627. */
  31628. reset(): AnimationGroup;
  31629. /**
  31630. * Restart animations from key 0
  31631. * @returns the animation group
  31632. */
  31633. restart(): AnimationGroup;
  31634. /**
  31635. * Stop all animations
  31636. * @returns the animation group
  31637. */
  31638. stop(): AnimationGroup;
  31639. /**
  31640. * Set animation weight for all animatables
  31641. * @param weight defines the weight to use
  31642. * @return the animationGroup
  31643. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31644. */
  31645. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31646. /**
  31647. * Synchronize and normalize all animatables with a source animatable
  31648. * @param root defines the root animatable to synchronize with
  31649. * @return the animationGroup
  31650. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31651. */
  31652. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31653. /**
  31654. * Goes to a specific frame in this animation group
  31655. * @param frame the frame number to go to
  31656. * @return the animationGroup
  31657. */
  31658. goToFrame(frame: number): AnimationGroup;
  31659. /**
  31660. * Dispose all associated resources
  31661. */
  31662. dispose(): void;
  31663. private _checkAnimationGroupEnded;
  31664. /**
  31665. * Clone the current animation group and returns a copy
  31666. * @param newName defines the name of the new group
  31667. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31668. * @returns the new aniamtion group
  31669. */
  31670. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31671. /**
  31672. * Returns a new AnimationGroup object parsed from the source provided.
  31673. * @param parsedAnimationGroup defines the source
  31674. * @param scene defines the scene that will receive the animationGroup
  31675. * @returns a new AnimationGroup
  31676. */
  31677. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31678. /**
  31679. * Returns the string "AnimationGroup"
  31680. * @returns "AnimationGroup"
  31681. */
  31682. getClassName(): string;
  31683. /**
  31684. * Creates a detailled string about the object
  31685. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31686. * @returns a string representing the object
  31687. */
  31688. toString(fullDetails?: boolean): string;
  31689. }
  31690. }
  31691. declare module "babylonjs/scene" {
  31692. import { Nullable } from "babylonjs/types";
  31693. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31694. import { Observable } from "babylonjs/Misc/observable";
  31695. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31696. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31697. import { Geometry } from "babylonjs/Meshes/geometry";
  31698. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31699. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31701. import { Mesh } from "babylonjs/Meshes/mesh";
  31702. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31703. import { Bone } from "babylonjs/Bones/bone";
  31704. import { Skeleton } from "babylonjs/Bones/skeleton";
  31705. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31706. import { Camera } from "babylonjs/Cameras/camera";
  31707. import { AbstractScene } from "babylonjs/abstractScene";
  31708. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31710. import { Material } from "babylonjs/Materials/material";
  31711. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31712. import { Effect } from "babylonjs/Materials/effect";
  31713. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31714. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31715. import { Light } from "babylonjs/Lights/light";
  31716. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31717. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31718. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31719. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31720. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31721. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31723. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31724. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31725. import { Engine } from "babylonjs/Engines/engine";
  31726. import { Node } from "babylonjs/node";
  31727. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31728. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31729. import { Ray } from "babylonjs/Culling/ray";
  31730. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31731. import { Animation } from "babylonjs/Animations/animation";
  31732. import { Animatable } from "babylonjs/Animations/animatable";
  31733. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31734. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31735. import { Collider } from "babylonjs/Collisions/collider";
  31736. /**
  31737. * Define an interface for all classes that will hold resources
  31738. */
  31739. export interface IDisposable {
  31740. /**
  31741. * Releases all held resources
  31742. */
  31743. dispose(): void;
  31744. }
  31745. /** Interface defining initialization parameters for Scene class */
  31746. export interface SceneOptions {
  31747. /**
  31748. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31749. * It will improve performance when the number of geometries becomes important.
  31750. */
  31751. useGeometryUniqueIdsMap?: boolean;
  31752. /**
  31753. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31754. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31755. */
  31756. useMaterialMeshMap?: boolean;
  31757. /**
  31758. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31759. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31760. */
  31761. useClonedMeshhMap?: boolean;
  31762. }
  31763. /**
  31764. * Represents a scene to be rendered by the engine.
  31765. * @see http://doc.babylonjs.com/features/scene
  31766. */
  31767. export class Scene extends AbstractScene implements IAnimatable {
  31768. private static _uniqueIdCounter;
  31769. /** The fog is deactivated */
  31770. static readonly FOGMODE_NONE: number;
  31771. /** The fog density is following an exponential function */
  31772. static readonly FOGMODE_EXP: number;
  31773. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31774. static readonly FOGMODE_EXP2: number;
  31775. /** The fog density is following a linear function. */
  31776. static readonly FOGMODE_LINEAR: number;
  31777. /**
  31778. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31780. */
  31781. static MinDeltaTime: number;
  31782. /**
  31783. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31784. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31785. */
  31786. static MaxDeltaTime: number;
  31787. /**
  31788. * Factory used to create the default material.
  31789. * @param name The name of the material to create
  31790. * @param scene The scene to create the material for
  31791. * @returns The default material
  31792. */
  31793. static DefaultMaterialFactory(scene: Scene): Material;
  31794. /**
  31795. * Factory used to create the a collision coordinator.
  31796. * @returns The collision coordinator
  31797. */
  31798. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31799. /** @hidden */
  31800. readonly _isScene: boolean;
  31801. /**
  31802. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31803. */
  31804. autoClear: boolean;
  31805. /**
  31806. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31807. */
  31808. autoClearDepthAndStencil: boolean;
  31809. /**
  31810. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31811. */
  31812. clearColor: Color4;
  31813. /**
  31814. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31815. */
  31816. ambientColor: Color3;
  31817. /** @hidden */
  31818. _environmentBRDFTexture: BaseTexture;
  31819. /** @hidden */
  31820. protected _environmentTexture: Nullable<BaseTexture>;
  31821. /**
  31822. * Texture used in all pbr material as the reflection texture.
  31823. * As in the majority of the scene they are the same (exception for multi room and so on),
  31824. * this is easier to reference from here than from all the materials.
  31825. */
  31826. /**
  31827. * Texture used in all pbr material as the reflection texture.
  31828. * As in the majority of the scene they are the same (exception for multi room and so on),
  31829. * this is easier to set here than in all the materials.
  31830. */
  31831. environmentTexture: Nullable<BaseTexture>;
  31832. /** @hidden */
  31833. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31834. /**
  31835. * Default image processing configuration used either in the rendering
  31836. * Forward main pass or through the imageProcessingPostProcess if present.
  31837. * As in the majority of the scene they are the same (exception for multi camera),
  31838. * this is easier to reference from here than from all the materials and post process.
  31839. *
  31840. * No setter as we it is a shared configuration, you can set the values instead.
  31841. */
  31842. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31843. private _forceWireframe;
  31844. /**
  31845. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31846. */
  31847. forceWireframe: boolean;
  31848. private _forcePointsCloud;
  31849. /**
  31850. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31851. */
  31852. forcePointsCloud: boolean;
  31853. /**
  31854. * Gets or sets the active clipplane 1
  31855. */
  31856. clipPlane: Nullable<Plane>;
  31857. /**
  31858. * Gets or sets the active clipplane 2
  31859. */
  31860. clipPlane2: Nullable<Plane>;
  31861. /**
  31862. * Gets or sets the active clipplane 3
  31863. */
  31864. clipPlane3: Nullable<Plane>;
  31865. /**
  31866. * Gets or sets the active clipplane 4
  31867. */
  31868. clipPlane4: Nullable<Plane>;
  31869. /**
  31870. * Gets or sets a boolean indicating if animations are enabled
  31871. */
  31872. animationsEnabled: boolean;
  31873. private _animationPropertiesOverride;
  31874. /**
  31875. * Gets or sets the animation properties override
  31876. */
  31877. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31878. /**
  31879. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31880. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31881. */
  31882. useConstantAnimationDeltaTime: boolean;
  31883. /**
  31884. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31885. * Please note that it requires to run a ray cast through the scene on every frame
  31886. */
  31887. constantlyUpdateMeshUnderPointer: boolean;
  31888. /**
  31889. * Defines the HTML cursor to use when hovering over interactive elements
  31890. */
  31891. hoverCursor: string;
  31892. /**
  31893. * Defines the HTML default cursor to use (empty by default)
  31894. */
  31895. defaultCursor: string;
  31896. /**
  31897. * This is used to call preventDefault() on pointer down
  31898. * in order to block unwanted artifacts like system double clicks
  31899. */
  31900. preventDefaultOnPointerDown: boolean;
  31901. /**
  31902. * This is used to call preventDefault() on pointer up
  31903. * in order to block unwanted artifacts like system double clicks
  31904. */
  31905. preventDefaultOnPointerUp: boolean;
  31906. /**
  31907. * Gets or sets user defined metadata
  31908. */
  31909. metadata: any;
  31910. /**
  31911. * For internal use only. Please do not use.
  31912. */
  31913. reservedDataStore: any;
  31914. /**
  31915. * Gets the name of the plugin used to load this scene (null by default)
  31916. */
  31917. loadingPluginName: string;
  31918. /**
  31919. * Use this array to add regular expressions used to disable offline support for specific urls
  31920. */
  31921. disableOfflineSupportExceptionRules: RegExp[];
  31922. /**
  31923. * An event triggered when the scene is disposed.
  31924. */
  31925. onDisposeObservable: Observable<Scene>;
  31926. private _onDisposeObserver;
  31927. /** Sets a function to be executed when this scene is disposed. */
  31928. onDispose: () => void;
  31929. /**
  31930. * An event triggered before rendering the scene (right after animations and physics)
  31931. */
  31932. onBeforeRenderObservable: Observable<Scene>;
  31933. private _onBeforeRenderObserver;
  31934. /** Sets a function to be executed before rendering this scene */
  31935. beforeRender: Nullable<() => void>;
  31936. /**
  31937. * An event triggered after rendering the scene
  31938. */
  31939. onAfterRenderObservable: Observable<Scene>;
  31940. private _onAfterRenderObserver;
  31941. /** Sets a function to be executed after rendering this scene */
  31942. afterRender: Nullable<() => void>;
  31943. /**
  31944. * An event triggered before animating the scene
  31945. */
  31946. onBeforeAnimationsObservable: Observable<Scene>;
  31947. /**
  31948. * An event triggered after animations processing
  31949. */
  31950. onAfterAnimationsObservable: Observable<Scene>;
  31951. /**
  31952. * An event triggered before draw calls are ready to be sent
  31953. */
  31954. onBeforeDrawPhaseObservable: Observable<Scene>;
  31955. /**
  31956. * An event triggered after draw calls have been sent
  31957. */
  31958. onAfterDrawPhaseObservable: Observable<Scene>;
  31959. /**
  31960. * An event triggered when the scene is ready
  31961. */
  31962. onReadyObservable: Observable<Scene>;
  31963. /**
  31964. * An event triggered before rendering a camera
  31965. */
  31966. onBeforeCameraRenderObservable: Observable<Camera>;
  31967. private _onBeforeCameraRenderObserver;
  31968. /** Sets a function to be executed before rendering a camera*/
  31969. beforeCameraRender: () => void;
  31970. /**
  31971. * An event triggered after rendering a camera
  31972. */
  31973. onAfterCameraRenderObservable: Observable<Camera>;
  31974. private _onAfterCameraRenderObserver;
  31975. /** Sets a function to be executed after rendering a camera*/
  31976. afterCameraRender: () => void;
  31977. /**
  31978. * An event triggered when active meshes evaluation is about to start
  31979. */
  31980. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31981. /**
  31982. * An event triggered when active meshes evaluation is done
  31983. */
  31984. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31985. /**
  31986. * An event triggered when particles rendering is about to start
  31987. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31988. */
  31989. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31990. /**
  31991. * An event triggered when particles rendering is done
  31992. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31993. */
  31994. onAfterParticlesRenderingObservable: Observable<Scene>;
  31995. /**
  31996. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31997. */
  31998. onDataLoadedObservable: Observable<Scene>;
  31999. /**
  32000. * An event triggered when a camera is created
  32001. */
  32002. onNewCameraAddedObservable: Observable<Camera>;
  32003. /**
  32004. * An event triggered when a camera is removed
  32005. */
  32006. onCameraRemovedObservable: Observable<Camera>;
  32007. /**
  32008. * An event triggered when a light is created
  32009. */
  32010. onNewLightAddedObservable: Observable<Light>;
  32011. /**
  32012. * An event triggered when a light is removed
  32013. */
  32014. onLightRemovedObservable: Observable<Light>;
  32015. /**
  32016. * An event triggered when a geometry is created
  32017. */
  32018. onNewGeometryAddedObservable: Observable<Geometry>;
  32019. /**
  32020. * An event triggered when a geometry is removed
  32021. */
  32022. onGeometryRemovedObservable: Observable<Geometry>;
  32023. /**
  32024. * An event triggered when a transform node is created
  32025. */
  32026. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32027. /**
  32028. * An event triggered when a transform node is removed
  32029. */
  32030. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32031. /**
  32032. * An event triggered when a mesh is created
  32033. */
  32034. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32035. /**
  32036. * An event triggered when a mesh is removed
  32037. */
  32038. onMeshRemovedObservable: Observable<AbstractMesh>;
  32039. /**
  32040. * An event triggered when a material is created
  32041. */
  32042. onNewMaterialAddedObservable: Observable<Material>;
  32043. /**
  32044. * An event triggered when a material is removed
  32045. */
  32046. onMaterialRemovedObservable: Observable<Material>;
  32047. /**
  32048. * An event triggered when a texture is created
  32049. */
  32050. onNewTextureAddedObservable: Observable<BaseTexture>;
  32051. /**
  32052. * An event triggered when a texture is removed
  32053. */
  32054. onTextureRemovedObservable: Observable<BaseTexture>;
  32055. /**
  32056. * An event triggered when render targets are about to be rendered
  32057. * Can happen multiple times per frame.
  32058. */
  32059. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32060. /**
  32061. * An event triggered when render targets were rendered.
  32062. * Can happen multiple times per frame.
  32063. */
  32064. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32065. /**
  32066. * An event triggered before calculating deterministic simulation step
  32067. */
  32068. onBeforeStepObservable: Observable<Scene>;
  32069. /**
  32070. * An event triggered after calculating deterministic simulation step
  32071. */
  32072. onAfterStepObservable: Observable<Scene>;
  32073. /**
  32074. * An event triggered when the activeCamera property is updated
  32075. */
  32076. onActiveCameraChanged: Observable<Scene>;
  32077. /**
  32078. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32079. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32080. * 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)
  32081. */
  32082. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32083. /**
  32084. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32085. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32086. * 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)
  32087. */
  32088. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32089. /**
  32090. * This Observable will when a mesh has been imported into the scene.
  32091. */
  32092. onMeshImportedObservable: Observable<AbstractMesh>;
  32093. /**
  32094. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32095. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32096. */
  32097. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32098. /** @hidden */
  32099. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32100. /**
  32101. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32102. */
  32103. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32104. /**
  32105. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32106. */
  32107. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32108. /**
  32109. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32110. */
  32111. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32112. private _onPointerMove;
  32113. private _onPointerDown;
  32114. private _onPointerUp;
  32115. /** Callback called when a pointer move is detected */
  32116. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32117. /** Callback called when a pointer down is detected */
  32118. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32119. /** Callback called when a pointer up is detected */
  32120. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32121. /** Callback called when a pointer pick is detected */
  32122. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32123. /**
  32124. * 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).
  32125. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32126. */
  32127. onPrePointerObservable: Observable<PointerInfoPre>;
  32128. /**
  32129. * Observable event triggered each time an input event is received from the rendering canvas
  32130. */
  32131. onPointerObservable: Observable<PointerInfo>;
  32132. /**
  32133. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32134. */
  32135. readonly unTranslatedPointer: Vector2;
  32136. /** The distance in pixel that you have to move to prevent some events */
  32137. static DragMovementThreshold: number;
  32138. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32139. static LongPressDelay: number;
  32140. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32141. static DoubleClickDelay: number;
  32142. /** If you need to check double click without raising a single click at first click, enable this flag */
  32143. static ExclusiveDoubleClickMode: boolean;
  32144. private _initClickEvent;
  32145. private _initActionManager;
  32146. private _delayedSimpleClick;
  32147. private _delayedSimpleClickTimeout;
  32148. private _previousDelayedSimpleClickTimeout;
  32149. private _meshPickProceed;
  32150. private _previousButtonPressed;
  32151. private _currentPickResult;
  32152. private _previousPickResult;
  32153. private _totalPointersPressed;
  32154. private _doubleClickOccured;
  32155. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32156. cameraToUseForPointers: Nullable<Camera>;
  32157. private _pointerX;
  32158. private _pointerY;
  32159. private _unTranslatedPointerX;
  32160. private _unTranslatedPointerY;
  32161. private _startingPointerPosition;
  32162. private _previousStartingPointerPosition;
  32163. private _startingPointerTime;
  32164. private _previousStartingPointerTime;
  32165. private _pointerCaptures;
  32166. private _timeAccumulator;
  32167. private _currentStepId;
  32168. private _currentInternalStep;
  32169. /** @hidden */
  32170. _mirroredCameraPosition: Nullable<Vector3>;
  32171. /**
  32172. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32173. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32174. */
  32175. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32176. /**
  32177. * Observable event triggered each time an keyboard event is received from the hosting window
  32178. */
  32179. onKeyboardObservable: Observable<KeyboardInfo>;
  32180. private _onKeyDown;
  32181. private _onKeyUp;
  32182. private _onCanvasFocusObserver;
  32183. private _onCanvasBlurObserver;
  32184. private _useRightHandedSystem;
  32185. /**
  32186. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32187. */
  32188. useRightHandedSystem: boolean;
  32189. /**
  32190. * Sets the step Id used by deterministic lock step
  32191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32192. * @param newStepId defines the step Id
  32193. */
  32194. setStepId(newStepId: number): void;
  32195. /**
  32196. * Gets the step Id used by deterministic lock step
  32197. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32198. * @returns the step Id
  32199. */
  32200. getStepId(): number;
  32201. /**
  32202. * Gets the internal step used by deterministic lock step
  32203. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32204. * @returns the internal step
  32205. */
  32206. getInternalStep(): number;
  32207. private _fogEnabled;
  32208. /**
  32209. * Gets or sets a boolean indicating if fog is enabled on this scene
  32210. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32211. * (Default is true)
  32212. */
  32213. fogEnabled: boolean;
  32214. private _fogMode;
  32215. /**
  32216. * Gets or sets the fog mode to use
  32217. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32218. * | mode | value |
  32219. * | --- | --- |
  32220. * | FOGMODE_NONE | 0 |
  32221. * | FOGMODE_EXP | 1 |
  32222. * | FOGMODE_EXP2 | 2 |
  32223. * | FOGMODE_LINEAR | 3 |
  32224. */
  32225. fogMode: number;
  32226. /**
  32227. * Gets or sets the fog color to use
  32228. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32229. * (Default is Color3(0.2, 0.2, 0.3))
  32230. */
  32231. fogColor: Color3;
  32232. /**
  32233. * Gets or sets the fog density to use
  32234. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32235. * (Default is 0.1)
  32236. */
  32237. fogDensity: number;
  32238. /**
  32239. * Gets or sets the fog start distance to use
  32240. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32241. * (Default is 0)
  32242. */
  32243. fogStart: number;
  32244. /**
  32245. * Gets or sets the fog end distance to use
  32246. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32247. * (Default is 1000)
  32248. */
  32249. fogEnd: number;
  32250. private _shadowsEnabled;
  32251. /**
  32252. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32253. */
  32254. shadowsEnabled: boolean;
  32255. private _lightsEnabled;
  32256. /**
  32257. * Gets or sets a boolean indicating if lights are enabled on this scene
  32258. */
  32259. lightsEnabled: boolean;
  32260. /** All of the active cameras added to this scene. */
  32261. activeCameras: Camera[];
  32262. private _activeCamera;
  32263. /** Gets or sets the current active camera */
  32264. activeCamera: Nullable<Camera>;
  32265. private _defaultMaterial;
  32266. /** The default material used on meshes when no material is affected */
  32267. /** The default material used on meshes when no material is affected */
  32268. defaultMaterial: Material;
  32269. private _texturesEnabled;
  32270. /**
  32271. * Gets or sets a boolean indicating if textures are enabled on this scene
  32272. */
  32273. texturesEnabled: boolean;
  32274. /**
  32275. * Gets or sets a boolean indicating if particles are enabled on this scene
  32276. */
  32277. particlesEnabled: boolean;
  32278. /**
  32279. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32280. */
  32281. spritesEnabled: boolean;
  32282. private _skeletonsEnabled;
  32283. /**
  32284. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32285. */
  32286. skeletonsEnabled: boolean;
  32287. /**
  32288. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32289. */
  32290. lensFlaresEnabled: boolean;
  32291. /**
  32292. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32294. */
  32295. collisionsEnabled: boolean;
  32296. private _collisionCoordinator;
  32297. /** @hidden */
  32298. readonly collisionCoordinator: ICollisionCoordinator;
  32299. /**
  32300. * Defines the gravity applied to this scene (used only for collisions)
  32301. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32302. */
  32303. gravity: Vector3;
  32304. /**
  32305. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32306. */
  32307. postProcessesEnabled: boolean;
  32308. /**
  32309. * The list of postprocesses added to the scene
  32310. */
  32311. postProcesses: PostProcess[];
  32312. /**
  32313. * Gets the current postprocess manager
  32314. */
  32315. postProcessManager: PostProcessManager;
  32316. /**
  32317. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32318. */
  32319. renderTargetsEnabled: boolean;
  32320. /**
  32321. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32322. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32323. */
  32324. dumpNextRenderTargets: boolean;
  32325. /**
  32326. * The list of user defined render targets added to the scene
  32327. */
  32328. customRenderTargets: RenderTargetTexture[];
  32329. /**
  32330. * Defines if texture loading must be delayed
  32331. * If true, textures will only be loaded when they need to be rendered
  32332. */
  32333. useDelayedTextureLoading: boolean;
  32334. /**
  32335. * Gets the list of meshes imported to the scene through SceneLoader
  32336. */
  32337. importedMeshesFiles: String[];
  32338. /**
  32339. * Gets or sets a boolean indicating if probes are enabled on this scene
  32340. */
  32341. probesEnabled: boolean;
  32342. /**
  32343. * Gets or sets the current offline provider to use to store scene data
  32344. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32345. */
  32346. offlineProvider: IOfflineProvider;
  32347. /**
  32348. * Gets or sets the action manager associated with the scene
  32349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32350. */
  32351. actionManager: AbstractActionManager;
  32352. private _meshesForIntersections;
  32353. /**
  32354. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32355. */
  32356. proceduralTexturesEnabled: boolean;
  32357. private _engine;
  32358. private _totalVertices;
  32359. /** @hidden */
  32360. _activeIndices: PerfCounter;
  32361. /** @hidden */
  32362. _activeParticles: PerfCounter;
  32363. /** @hidden */
  32364. _activeBones: PerfCounter;
  32365. private _animationRatio;
  32366. /** @hidden */
  32367. _animationTimeLast: number;
  32368. /** @hidden */
  32369. _animationTime: number;
  32370. /**
  32371. * Gets or sets a general scale for animation speed
  32372. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32373. */
  32374. animationTimeScale: number;
  32375. /** @hidden */
  32376. _cachedMaterial: Nullable<Material>;
  32377. /** @hidden */
  32378. _cachedEffect: Nullable<Effect>;
  32379. /** @hidden */
  32380. _cachedVisibility: Nullable<number>;
  32381. private _renderId;
  32382. private _frameId;
  32383. private _executeWhenReadyTimeoutId;
  32384. private _intermediateRendering;
  32385. private _viewUpdateFlag;
  32386. private _projectionUpdateFlag;
  32387. private _alternateViewUpdateFlag;
  32388. private _alternateProjectionUpdateFlag;
  32389. /** @hidden */
  32390. _toBeDisposed: Nullable<IDisposable>[];
  32391. private _activeRequests;
  32392. /** @hidden */
  32393. _pendingData: any[];
  32394. private _isDisposed;
  32395. /**
  32396. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32397. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32398. */
  32399. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32400. private _activeMeshes;
  32401. private _processedMaterials;
  32402. private _renderTargets;
  32403. /** @hidden */
  32404. _activeParticleSystems: SmartArray<IParticleSystem>;
  32405. private _activeSkeletons;
  32406. private _softwareSkinnedMeshes;
  32407. private _renderingManager;
  32408. /** @hidden */
  32409. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32410. private _transformMatrix;
  32411. private _sceneUbo;
  32412. private _alternateSceneUbo;
  32413. private _viewMatrix;
  32414. private _projectionMatrix;
  32415. private _alternateViewMatrix;
  32416. private _alternateProjectionMatrix;
  32417. private _alternateTransformMatrix;
  32418. private _useAlternateCameraConfiguration;
  32419. private _alternateRendering;
  32420. private _wheelEventName;
  32421. /** @hidden */
  32422. _forcedViewPosition: Nullable<Vector3>;
  32423. /** @hidden */
  32424. readonly _isAlternateRenderingEnabled: boolean;
  32425. private _frustumPlanes;
  32426. /**
  32427. * Gets the list of frustum planes (built from the active camera)
  32428. */
  32429. readonly frustumPlanes: Plane[];
  32430. /**
  32431. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32432. * This is useful if there are more lights that the maximum simulteanous authorized
  32433. */
  32434. requireLightSorting: boolean;
  32435. /** @hidden */
  32436. readonly useMaterialMeshMap: boolean;
  32437. /** @hidden */
  32438. readonly useClonedMeshhMap: boolean;
  32439. private _pointerOverMesh;
  32440. private _pickedDownMesh;
  32441. private _pickedUpMesh;
  32442. private _externalData;
  32443. private _uid;
  32444. /**
  32445. * @hidden
  32446. * Backing store of defined scene components.
  32447. */
  32448. _components: ISceneComponent[];
  32449. /**
  32450. * @hidden
  32451. * Backing store of defined scene components.
  32452. */
  32453. _serializableComponents: ISceneSerializableComponent[];
  32454. /**
  32455. * List of components to register on the next registration step.
  32456. */
  32457. private _transientComponents;
  32458. /**
  32459. * Registers the transient components if needed.
  32460. */
  32461. private _registerTransientComponents;
  32462. /**
  32463. * @hidden
  32464. * Add a component to the scene.
  32465. * Note that the ccomponent could be registered on th next frame if this is called after
  32466. * the register component stage.
  32467. * @param component Defines the component to add to the scene
  32468. */
  32469. _addComponent(component: ISceneComponent): void;
  32470. /**
  32471. * @hidden
  32472. * Gets a component from the scene.
  32473. * @param name defines the name of the component to retrieve
  32474. * @returns the component or null if not present
  32475. */
  32476. _getComponent(name: string): Nullable<ISceneComponent>;
  32477. /**
  32478. * @hidden
  32479. * Defines the actions happening before camera updates.
  32480. */
  32481. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32482. /**
  32483. * @hidden
  32484. * Defines the actions happening before clear the canvas.
  32485. */
  32486. _beforeClearStage: Stage<SimpleStageAction>;
  32487. /**
  32488. * @hidden
  32489. * Defines the actions when collecting render targets for the frame.
  32490. */
  32491. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32492. /**
  32493. * @hidden
  32494. * Defines the actions happening for one camera in the frame.
  32495. */
  32496. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32497. /**
  32498. * @hidden
  32499. * Defines the actions happening during the per mesh ready checks.
  32500. */
  32501. _isReadyForMeshStage: Stage<MeshStageAction>;
  32502. /**
  32503. * @hidden
  32504. * Defines the actions happening before evaluate active mesh checks.
  32505. */
  32506. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32507. /**
  32508. * @hidden
  32509. * Defines the actions happening during the evaluate sub mesh checks.
  32510. */
  32511. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32512. /**
  32513. * @hidden
  32514. * Defines the actions happening during the active mesh stage.
  32515. */
  32516. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32517. /**
  32518. * @hidden
  32519. * Defines the actions happening during the per camera render target step.
  32520. */
  32521. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32522. /**
  32523. * @hidden
  32524. * Defines the actions happening just before the active camera is drawing.
  32525. */
  32526. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32527. /**
  32528. * @hidden
  32529. * Defines the actions happening just before a render target is drawing.
  32530. */
  32531. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32532. /**
  32533. * @hidden
  32534. * Defines the actions happening just before a rendering group is drawing.
  32535. */
  32536. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32537. /**
  32538. * @hidden
  32539. * Defines the actions happening just before a mesh is drawing.
  32540. */
  32541. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32542. /**
  32543. * @hidden
  32544. * Defines the actions happening just after a mesh has been drawn.
  32545. */
  32546. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32547. /**
  32548. * @hidden
  32549. * Defines the actions happening just after a rendering group has been drawn.
  32550. */
  32551. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32552. /**
  32553. * @hidden
  32554. * Defines the actions happening just after the active camera has been drawn.
  32555. */
  32556. _afterCameraDrawStage: Stage<CameraStageAction>;
  32557. /**
  32558. * @hidden
  32559. * Defines the actions happening just after a render target has been drawn.
  32560. */
  32561. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32562. /**
  32563. * @hidden
  32564. * Defines the actions happening just after rendering all cameras and computing intersections.
  32565. */
  32566. _afterRenderStage: Stage<SimpleStageAction>;
  32567. /**
  32568. * @hidden
  32569. * Defines the actions happening when a pointer move event happens.
  32570. */
  32571. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32572. /**
  32573. * @hidden
  32574. * Defines the actions happening when a pointer down event happens.
  32575. */
  32576. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32577. /**
  32578. * @hidden
  32579. * Defines the actions happening when a pointer up event happens.
  32580. */
  32581. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32582. /**
  32583. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32584. */
  32585. private geometriesByUniqueId;
  32586. /**
  32587. * Creates a new Scene
  32588. * @param engine defines the engine to use to render this scene
  32589. * @param options defines the scene options
  32590. */
  32591. constructor(engine: Engine, options?: SceneOptions);
  32592. private _defaultMeshCandidates;
  32593. /**
  32594. * @hidden
  32595. */
  32596. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32597. private _defaultSubMeshCandidates;
  32598. /**
  32599. * @hidden
  32600. */
  32601. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32602. /**
  32603. * Sets the default candidate providers for the scene.
  32604. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32605. * and getCollidingSubMeshCandidates to their default function
  32606. */
  32607. setDefaultCandidateProviders(): void;
  32608. /**
  32609. * Gets the mesh that is currently under the pointer
  32610. */
  32611. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32612. /**
  32613. * Gets or sets the current on-screen X position of the pointer
  32614. */
  32615. pointerX: number;
  32616. /**
  32617. * Gets or sets the current on-screen Y position of the pointer
  32618. */
  32619. pointerY: number;
  32620. /**
  32621. * Gets the cached material (ie. the latest rendered one)
  32622. * @returns the cached material
  32623. */
  32624. getCachedMaterial(): Nullable<Material>;
  32625. /**
  32626. * Gets the cached effect (ie. the latest rendered one)
  32627. * @returns the cached effect
  32628. */
  32629. getCachedEffect(): Nullable<Effect>;
  32630. /**
  32631. * Gets the cached visibility state (ie. the latest rendered one)
  32632. * @returns the cached visibility state
  32633. */
  32634. getCachedVisibility(): Nullable<number>;
  32635. /**
  32636. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32637. * @param material defines the current material
  32638. * @param effect defines the current effect
  32639. * @param visibility defines the current visibility state
  32640. * @returns true if one parameter is not cached
  32641. */
  32642. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32643. /**
  32644. * Gets the engine associated with the scene
  32645. * @returns an Engine
  32646. */
  32647. getEngine(): Engine;
  32648. /**
  32649. * Gets the total number of vertices rendered per frame
  32650. * @returns the total number of vertices rendered per frame
  32651. */
  32652. getTotalVertices(): number;
  32653. /**
  32654. * Gets the performance counter for total vertices
  32655. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32656. */
  32657. readonly totalVerticesPerfCounter: PerfCounter;
  32658. /**
  32659. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32660. * @returns the total number of active indices rendered per frame
  32661. */
  32662. getActiveIndices(): number;
  32663. /**
  32664. * Gets the performance counter for active indices
  32665. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32666. */
  32667. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32668. /**
  32669. * Gets the total number of active particles rendered per frame
  32670. * @returns the total number of active particles rendered per frame
  32671. */
  32672. getActiveParticles(): number;
  32673. /**
  32674. * Gets the performance counter for active particles
  32675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32676. */
  32677. readonly activeParticlesPerfCounter: PerfCounter;
  32678. /**
  32679. * Gets the total number of active bones rendered per frame
  32680. * @returns the total number of active bones rendered per frame
  32681. */
  32682. getActiveBones(): number;
  32683. /**
  32684. * Gets the performance counter for active bones
  32685. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32686. */
  32687. readonly activeBonesPerfCounter: PerfCounter;
  32688. /**
  32689. * Gets the array of active meshes
  32690. * @returns an array of AbstractMesh
  32691. */
  32692. getActiveMeshes(): SmartArray<AbstractMesh>;
  32693. /**
  32694. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32695. * @returns a number
  32696. */
  32697. getAnimationRatio(): number;
  32698. /**
  32699. * Gets an unique Id for the current render phase
  32700. * @returns a number
  32701. */
  32702. getRenderId(): number;
  32703. /**
  32704. * Gets an unique Id for the current frame
  32705. * @returns a number
  32706. */
  32707. getFrameId(): number;
  32708. /** Call this function if you want to manually increment the render Id*/
  32709. incrementRenderId(): void;
  32710. private _updatePointerPosition;
  32711. private _createUbo;
  32712. private _createAlternateUbo;
  32713. private _setRayOnPointerInfo;
  32714. /**
  32715. * Use this method to simulate a pointer move on a mesh
  32716. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32717. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32718. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32719. * @returns the current scene
  32720. */
  32721. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32722. private _processPointerMove;
  32723. private _checkPrePointerObservable;
  32724. /**
  32725. * Use this method to simulate a pointer down on a mesh
  32726. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32727. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32728. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32729. * @returns the current scene
  32730. */
  32731. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32732. private _processPointerDown;
  32733. /**
  32734. * Use this method to simulate a pointer up on a mesh
  32735. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32736. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32737. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32738. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32739. * @returns the current scene
  32740. */
  32741. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32742. private _processPointerUp;
  32743. /**
  32744. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32745. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32746. * @returns true if the pointer was captured
  32747. */
  32748. isPointerCaptured(pointerId?: number): boolean;
  32749. /** @hidden */
  32750. _isPointerSwiping(): boolean;
  32751. /**
  32752. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32753. * @param attachUp defines if you want to attach events to pointerup
  32754. * @param attachDown defines if you want to attach events to pointerdown
  32755. * @param attachMove defines if you want to attach events to pointermove
  32756. */
  32757. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32758. /** Detaches all event handlers*/
  32759. detachControl(): void;
  32760. /**
  32761. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32762. * Delay loaded resources are not taking in account
  32763. * @return true if all required resources are ready
  32764. */
  32765. isReady(): boolean;
  32766. /** Resets all cached information relative to material (including effect and visibility) */
  32767. resetCachedMaterial(): void;
  32768. /**
  32769. * Registers a function to be called before every frame render
  32770. * @param func defines the function to register
  32771. */
  32772. registerBeforeRender(func: () => void): void;
  32773. /**
  32774. * Unregisters a function called before every frame render
  32775. * @param func defines the function to unregister
  32776. */
  32777. unregisterBeforeRender(func: () => void): void;
  32778. /**
  32779. * Registers a function to be called after every frame render
  32780. * @param func defines the function to register
  32781. */
  32782. registerAfterRender(func: () => void): void;
  32783. /**
  32784. * Unregisters a function called after every frame render
  32785. * @param func defines the function to unregister
  32786. */
  32787. unregisterAfterRender(func: () => void): void;
  32788. private _executeOnceBeforeRender;
  32789. /**
  32790. * The provided function will run before render once and will be disposed afterwards.
  32791. * A timeout delay can be provided so that the function will be executed in N ms.
  32792. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32793. * @param func The function to be executed.
  32794. * @param timeout optional delay in ms
  32795. */
  32796. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32797. /** @hidden */
  32798. _addPendingData(data: any): void;
  32799. /** @hidden */
  32800. _removePendingData(data: any): void;
  32801. /**
  32802. * Returns the number of items waiting to be loaded
  32803. * @returns the number of items waiting to be loaded
  32804. */
  32805. getWaitingItemsCount(): number;
  32806. /**
  32807. * Returns a boolean indicating if the scene is still loading data
  32808. */
  32809. readonly isLoading: boolean;
  32810. /**
  32811. * Registers a function to be executed when the scene is ready
  32812. * @param {Function} func - the function to be executed
  32813. */
  32814. executeWhenReady(func: () => void): void;
  32815. /**
  32816. * Returns a promise that resolves when the scene is ready
  32817. * @returns A promise that resolves when the scene is ready
  32818. */
  32819. whenReadyAsync(): Promise<void>;
  32820. /** @hidden */
  32821. _checkIsReady(): void;
  32822. /**
  32823. * Gets all animatable attached to the scene
  32824. */
  32825. readonly animatables: Animatable[];
  32826. /**
  32827. * Resets the last animation time frame.
  32828. * Useful to override when animations start running when loading a scene for the first time.
  32829. */
  32830. resetLastAnimationTimeFrame(): void;
  32831. /** @hidden */
  32832. _switchToAlternateCameraConfiguration(active: boolean): void;
  32833. /**
  32834. * Gets the current view matrix
  32835. * @returns a Matrix
  32836. */
  32837. getViewMatrix(): Matrix;
  32838. /**
  32839. * Gets the current projection matrix
  32840. * @returns a Matrix
  32841. */
  32842. getProjectionMatrix(): Matrix;
  32843. /**
  32844. * Gets the current transform matrix
  32845. * @returns a Matrix made of View * Projection
  32846. */
  32847. getTransformMatrix(): Matrix;
  32848. /**
  32849. * Sets the current transform matrix
  32850. * @param view defines the View matrix to use
  32851. * @param projection defines the Projection matrix to use
  32852. */
  32853. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32854. /** @hidden */
  32855. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32856. /**
  32857. * Gets the uniform buffer used to store scene data
  32858. * @returns a UniformBuffer
  32859. */
  32860. getSceneUniformBuffer(): UniformBuffer;
  32861. /**
  32862. * Gets an unique (relatively to the current scene) Id
  32863. * @returns an unique number for the scene
  32864. */
  32865. getUniqueId(): number;
  32866. /**
  32867. * Add a mesh to the list of scene's meshes
  32868. * @param newMesh defines the mesh to add
  32869. * @param recursive if all child meshes should also be added to the scene
  32870. */
  32871. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32872. /**
  32873. * Remove a mesh for the list of scene's meshes
  32874. * @param toRemove defines the mesh to remove
  32875. * @param recursive if all child meshes should also be removed from the scene
  32876. * @returns the index where the mesh was in the mesh list
  32877. */
  32878. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32879. /**
  32880. * Add a transform node to the list of scene's transform nodes
  32881. * @param newTransformNode defines the transform node to add
  32882. */
  32883. addTransformNode(newTransformNode: TransformNode): void;
  32884. /**
  32885. * Remove a transform node for the list of scene's transform nodes
  32886. * @param toRemove defines the transform node to remove
  32887. * @returns the index where the transform node was in the transform node list
  32888. */
  32889. removeTransformNode(toRemove: TransformNode): number;
  32890. /**
  32891. * Remove a skeleton for the list of scene's skeletons
  32892. * @param toRemove defines the skeleton to remove
  32893. * @returns the index where the skeleton was in the skeleton list
  32894. */
  32895. removeSkeleton(toRemove: Skeleton): number;
  32896. /**
  32897. * Remove a morph target for the list of scene's morph targets
  32898. * @param toRemove defines the morph target to remove
  32899. * @returns the index where the morph target was in the morph target list
  32900. */
  32901. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32902. /**
  32903. * Remove a light for the list of scene's lights
  32904. * @param toRemove defines the light to remove
  32905. * @returns the index where the light was in the light list
  32906. */
  32907. removeLight(toRemove: Light): number;
  32908. /**
  32909. * Remove a camera for the list of scene's cameras
  32910. * @param toRemove defines the camera to remove
  32911. * @returns the index where the camera was in the camera list
  32912. */
  32913. removeCamera(toRemove: Camera): number;
  32914. /**
  32915. * Remove a particle system for the list of scene's particle systems
  32916. * @param toRemove defines the particle system to remove
  32917. * @returns the index where the particle system was in the particle system list
  32918. */
  32919. removeParticleSystem(toRemove: IParticleSystem): number;
  32920. /**
  32921. * Remove a animation for the list of scene's animations
  32922. * @param toRemove defines the animation to remove
  32923. * @returns the index where the animation was in the animation list
  32924. */
  32925. removeAnimation(toRemove: Animation): number;
  32926. /**
  32927. * Removes the given animation group from this scene.
  32928. * @param toRemove The animation group to remove
  32929. * @returns The index of the removed animation group
  32930. */
  32931. removeAnimationGroup(toRemove: AnimationGroup): number;
  32932. /**
  32933. * Removes the given multi-material from this scene.
  32934. * @param toRemove The multi-material to remove
  32935. * @returns The index of the removed multi-material
  32936. */
  32937. removeMultiMaterial(toRemove: MultiMaterial): number;
  32938. /**
  32939. * Removes the given material from this scene.
  32940. * @param toRemove The material to remove
  32941. * @returns The index of the removed material
  32942. */
  32943. removeMaterial(toRemove: Material): number;
  32944. /**
  32945. * Removes the given action manager from this scene.
  32946. * @param toRemove The action manager to remove
  32947. * @returns The index of the removed action manager
  32948. */
  32949. removeActionManager(toRemove: AbstractActionManager): number;
  32950. /**
  32951. * Removes the given texture from this scene.
  32952. * @param toRemove The texture to remove
  32953. * @returns The index of the removed texture
  32954. */
  32955. removeTexture(toRemove: BaseTexture): number;
  32956. /**
  32957. * Adds the given light to this scene
  32958. * @param newLight The light to add
  32959. */
  32960. addLight(newLight: Light): void;
  32961. /**
  32962. * Sorts the list list based on light priorities
  32963. */
  32964. sortLightsByPriority(): void;
  32965. /**
  32966. * Adds the given camera to this scene
  32967. * @param newCamera The camera to add
  32968. */
  32969. addCamera(newCamera: Camera): void;
  32970. /**
  32971. * Adds the given skeleton to this scene
  32972. * @param newSkeleton The skeleton to add
  32973. */
  32974. addSkeleton(newSkeleton: Skeleton): void;
  32975. /**
  32976. * Adds the given particle system to this scene
  32977. * @param newParticleSystem The particle system to add
  32978. */
  32979. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32980. /**
  32981. * Adds the given animation to this scene
  32982. * @param newAnimation The animation to add
  32983. */
  32984. addAnimation(newAnimation: Animation): void;
  32985. /**
  32986. * Adds the given animation group to this scene.
  32987. * @param newAnimationGroup The animation group to add
  32988. */
  32989. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32990. /**
  32991. * Adds the given multi-material to this scene
  32992. * @param newMultiMaterial The multi-material to add
  32993. */
  32994. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32995. /**
  32996. * Adds the given material to this scene
  32997. * @param newMaterial The material to add
  32998. */
  32999. addMaterial(newMaterial: Material): void;
  33000. /**
  33001. * Adds the given morph target to this scene
  33002. * @param newMorphTargetManager The morph target to add
  33003. */
  33004. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33005. /**
  33006. * Adds the given geometry to this scene
  33007. * @param newGeometry The geometry to add
  33008. */
  33009. addGeometry(newGeometry: Geometry): void;
  33010. /**
  33011. * Adds the given action manager to this scene
  33012. * @param newActionManager The action manager to add
  33013. */
  33014. addActionManager(newActionManager: AbstractActionManager): void;
  33015. /**
  33016. * Adds the given texture to this scene.
  33017. * @param newTexture The texture to add
  33018. */
  33019. addTexture(newTexture: BaseTexture): void;
  33020. /**
  33021. * Switch active camera
  33022. * @param newCamera defines the new active camera
  33023. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33024. */
  33025. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33026. /**
  33027. * sets the active camera of the scene using its ID
  33028. * @param id defines the camera's ID
  33029. * @return the new active camera or null if none found.
  33030. */
  33031. setActiveCameraByID(id: string): Nullable<Camera>;
  33032. /**
  33033. * sets the active camera of the scene using its name
  33034. * @param name defines the camera's name
  33035. * @returns the new active camera or null if none found.
  33036. */
  33037. setActiveCameraByName(name: string): Nullable<Camera>;
  33038. /**
  33039. * get an animation group using its name
  33040. * @param name defines the material's name
  33041. * @return the animation group or null if none found.
  33042. */
  33043. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33044. /**
  33045. * get a material using its id
  33046. * @param id defines the material's ID
  33047. * @return the material or null if none found.
  33048. */
  33049. getMaterialByID(id: string): Nullable<Material>;
  33050. /**
  33051. * Gets a material using its name
  33052. * @param name defines the material's name
  33053. * @return the material or null if none found.
  33054. */
  33055. getMaterialByName(name: string): Nullable<Material>;
  33056. /**
  33057. * Gets a camera using its id
  33058. * @param id defines the id to look for
  33059. * @returns the camera or null if not found
  33060. */
  33061. getCameraByID(id: string): Nullable<Camera>;
  33062. /**
  33063. * Gets a camera using its unique id
  33064. * @param uniqueId defines the unique id to look for
  33065. * @returns the camera or null if not found
  33066. */
  33067. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33068. /**
  33069. * Gets a camera using its name
  33070. * @param name defines the camera's name
  33071. * @return the camera or null if none found.
  33072. */
  33073. getCameraByName(name: string): Nullable<Camera>;
  33074. /**
  33075. * Gets a bone using its id
  33076. * @param id defines the bone's id
  33077. * @return the bone or null if not found
  33078. */
  33079. getBoneByID(id: string): Nullable<Bone>;
  33080. /**
  33081. * Gets a bone using its id
  33082. * @param name defines the bone's name
  33083. * @return the bone or null if not found
  33084. */
  33085. getBoneByName(name: string): Nullable<Bone>;
  33086. /**
  33087. * Gets a light node using its name
  33088. * @param name defines the the light's name
  33089. * @return the light or null if none found.
  33090. */
  33091. getLightByName(name: string): Nullable<Light>;
  33092. /**
  33093. * Gets a light node using its id
  33094. * @param id defines the light's id
  33095. * @return the light or null if none found.
  33096. */
  33097. getLightByID(id: string): Nullable<Light>;
  33098. /**
  33099. * Gets a light node using its scene-generated unique ID
  33100. * @param uniqueId defines the light's unique id
  33101. * @return the light or null if none found.
  33102. */
  33103. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33104. /**
  33105. * Gets a particle system by id
  33106. * @param id defines the particle system id
  33107. * @return the corresponding system or null if none found
  33108. */
  33109. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33110. /**
  33111. * Gets a geometry using its ID
  33112. * @param id defines the geometry's id
  33113. * @return the geometry or null if none found.
  33114. */
  33115. getGeometryByID(id: string): Nullable<Geometry>;
  33116. private _getGeometryByUniqueID;
  33117. /**
  33118. * Add a new geometry to this scene
  33119. * @param geometry defines the geometry to be added to the scene.
  33120. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33121. * @return a boolean defining if the geometry was added or not
  33122. */
  33123. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33124. /**
  33125. * Removes an existing geometry
  33126. * @param geometry defines the geometry to be removed from the scene
  33127. * @return a boolean defining if the geometry was removed or not
  33128. */
  33129. removeGeometry(geometry: Geometry): boolean;
  33130. /**
  33131. * Gets the list of geometries attached to the scene
  33132. * @returns an array of Geometry
  33133. */
  33134. getGeometries(): Geometry[];
  33135. /**
  33136. * Gets the first added mesh found of a given ID
  33137. * @param id defines the id to search for
  33138. * @return the mesh found or null if not found at all
  33139. */
  33140. getMeshByID(id: string): Nullable<AbstractMesh>;
  33141. /**
  33142. * Gets a list of meshes using their id
  33143. * @param id defines the id to search for
  33144. * @returns a list of meshes
  33145. */
  33146. getMeshesByID(id: string): Array<AbstractMesh>;
  33147. /**
  33148. * Gets the first added transform node found of a given ID
  33149. * @param id defines the id to search for
  33150. * @return the found transform node or null if not found at all.
  33151. */
  33152. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33153. /**
  33154. * Gets a list of transform nodes using their id
  33155. * @param id defines the id to search for
  33156. * @returns a list of transform nodes
  33157. */
  33158. getTransformNodesByID(id: string): Array<TransformNode>;
  33159. /**
  33160. * Gets a mesh with its auto-generated unique id
  33161. * @param uniqueId defines the unique id to search for
  33162. * @return the found mesh or null if not found at all.
  33163. */
  33164. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33165. /**
  33166. * Gets a the last added mesh using a given id
  33167. * @param id defines the id to search for
  33168. * @return the found mesh or null if not found at all.
  33169. */
  33170. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33171. /**
  33172. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33173. * @param id defines the id to search for
  33174. * @return the found node or null if not found at all
  33175. */
  33176. getLastEntryByID(id: string): Nullable<Node>;
  33177. /**
  33178. * Gets a node (Mesh, Camera, Light) using a given id
  33179. * @param id defines the id to search for
  33180. * @return the found node or null if not found at all
  33181. */
  33182. getNodeByID(id: string): Nullable<Node>;
  33183. /**
  33184. * Gets a node (Mesh, Camera, Light) using a given name
  33185. * @param name defines the name to search for
  33186. * @return the found node or null if not found at all.
  33187. */
  33188. getNodeByName(name: string): Nullable<Node>;
  33189. /**
  33190. * Gets a mesh using a given name
  33191. * @param name defines the name to search for
  33192. * @return the found mesh or null if not found at all.
  33193. */
  33194. getMeshByName(name: string): Nullable<AbstractMesh>;
  33195. /**
  33196. * Gets a transform node using a given name
  33197. * @param name defines the name to search for
  33198. * @return the found transform node or null if not found at all.
  33199. */
  33200. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33201. /**
  33202. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33203. * @param id defines the id to search for
  33204. * @return the found skeleton or null if not found at all.
  33205. */
  33206. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33207. /**
  33208. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33209. * @param id defines the id to search for
  33210. * @return the found skeleton or null if not found at all.
  33211. */
  33212. getSkeletonById(id: string): Nullable<Skeleton>;
  33213. /**
  33214. * Gets a skeleton using a given name
  33215. * @param name defines the name to search for
  33216. * @return the found skeleton or null if not found at all.
  33217. */
  33218. getSkeletonByName(name: string): Nullable<Skeleton>;
  33219. /**
  33220. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33221. * @param id defines the id to search for
  33222. * @return the found morph target manager or null if not found at all.
  33223. */
  33224. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33225. /**
  33226. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33227. * @param id defines the id to search for
  33228. * @return the found morph target or null if not found at all.
  33229. */
  33230. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33231. /**
  33232. * Gets a boolean indicating if the given mesh is active
  33233. * @param mesh defines the mesh to look for
  33234. * @returns true if the mesh is in the active list
  33235. */
  33236. isActiveMesh(mesh: AbstractMesh): boolean;
  33237. /**
  33238. * Return a unique id as a string which can serve as an identifier for the scene
  33239. */
  33240. readonly uid: string;
  33241. /**
  33242. * Add an externaly attached data from its key.
  33243. * This method call will fail and return false, if such key already exists.
  33244. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33245. * @param key the unique key that identifies the data
  33246. * @param data the data object to associate to the key for this Engine instance
  33247. * @return true if no such key were already present and the data was added successfully, false otherwise
  33248. */
  33249. addExternalData<T>(key: string, data: T): boolean;
  33250. /**
  33251. * Get an externaly attached data from its key
  33252. * @param key the unique key that identifies the data
  33253. * @return the associated data, if present (can be null), or undefined if not present
  33254. */
  33255. getExternalData<T>(key: string): Nullable<T>;
  33256. /**
  33257. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33258. * @param key the unique key that identifies the data
  33259. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33260. * @return the associated data, can be null if the factory returned null.
  33261. */
  33262. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33263. /**
  33264. * Remove an externaly attached data from the Engine instance
  33265. * @param key the unique key that identifies the data
  33266. * @return true if the data was successfully removed, false if it doesn't exist
  33267. */
  33268. removeExternalData(key: string): boolean;
  33269. private _evaluateSubMesh;
  33270. /**
  33271. * Clear the processed materials smart array preventing retention point in material dispose.
  33272. */
  33273. freeProcessedMaterials(): void;
  33274. private _preventFreeActiveMeshesAndRenderingGroups;
  33275. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33276. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33277. * when disposing several meshes in a row or a hierarchy of meshes.
  33278. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33279. */
  33280. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33281. /**
  33282. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33283. */
  33284. freeActiveMeshes(): void;
  33285. /**
  33286. * Clear the info related to rendering groups preventing retention points during dispose.
  33287. */
  33288. freeRenderingGroups(): void;
  33289. /** @hidden */
  33290. _isInIntermediateRendering(): boolean;
  33291. /**
  33292. * Lambda returning the list of potentially active meshes.
  33293. */
  33294. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33295. /**
  33296. * Lambda returning the list of potentially active sub meshes.
  33297. */
  33298. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33299. /**
  33300. * Lambda returning the list of potentially intersecting sub meshes.
  33301. */
  33302. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33303. /**
  33304. * Lambda returning the list of potentially colliding sub meshes.
  33305. */
  33306. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33307. private _activeMeshesFrozen;
  33308. /**
  33309. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33310. * @returns the current scene
  33311. */
  33312. freezeActiveMeshes(): Scene;
  33313. /**
  33314. * Use this function to restart evaluating active meshes on every frame
  33315. * @returns the current scene
  33316. */
  33317. unfreezeActiveMeshes(): Scene;
  33318. private _evaluateActiveMeshes;
  33319. private _activeMesh;
  33320. /**
  33321. * Update the transform matrix to update from the current active camera
  33322. * @param force defines a boolean used to force the update even if cache is up to date
  33323. */
  33324. updateTransformMatrix(force?: boolean): void;
  33325. /**
  33326. * 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)
  33327. * @param alternateCamera defines the camera to use
  33328. */
  33329. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33330. /** @hidden */
  33331. _allowPostProcessClearColor: boolean;
  33332. private _renderForCamera;
  33333. private _processSubCameras;
  33334. private _checkIntersections;
  33335. /** @hidden */
  33336. _advancePhysicsEngineStep(step: number): void;
  33337. /**
  33338. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33339. */
  33340. getDeterministicFrameTime: () => number;
  33341. /** @hidden */
  33342. _animate(): void;
  33343. /**
  33344. * Render the scene
  33345. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33346. */
  33347. render(updateCameras?: boolean): void;
  33348. /**
  33349. * Freeze all materials
  33350. * A frozen material will not be updatable but should be faster to render
  33351. */
  33352. freezeMaterials(): void;
  33353. /**
  33354. * Unfreeze all materials
  33355. * A frozen material will not be updatable but should be faster to render
  33356. */
  33357. unfreezeMaterials(): void;
  33358. /**
  33359. * Releases all held ressources
  33360. */
  33361. dispose(): void;
  33362. /**
  33363. * Gets if the scene is already disposed
  33364. */
  33365. readonly isDisposed: boolean;
  33366. /**
  33367. * Call this function to reduce memory footprint of the scene.
  33368. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33369. */
  33370. clearCachedVertexData(): void;
  33371. /**
  33372. * This function will remove the local cached buffer data from texture.
  33373. * It will save memory but will prevent the texture from being rebuilt
  33374. */
  33375. cleanCachedTextureBuffer(): void;
  33376. /**
  33377. * Get the world extend vectors with an optional filter
  33378. *
  33379. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33380. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33381. */
  33382. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33383. min: Vector3;
  33384. max: Vector3;
  33385. };
  33386. /**
  33387. * Creates a ray that can be used to pick in the scene
  33388. * @param x defines the x coordinate of the origin (on-screen)
  33389. * @param y defines the y coordinate of the origin (on-screen)
  33390. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33391. * @param camera defines the camera to use for the picking
  33392. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33393. * @returns a Ray
  33394. */
  33395. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33396. /**
  33397. * Creates a ray that can be used to pick in the scene
  33398. * @param x defines the x coordinate of the origin (on-screen)
  33399. * @param y defines the y coordinate of the origin (on-screen)
  33400. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33401. * @param result defines the ray where to store the picking ray
  33402. * @param camera defines the camera to use for the picking
  33403. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33404. * @returns the current scene
  33405. */
  33406. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33407. /**
  33408. * Creates a ray that can be used to pick in the scene
  33409. * @param x defines the x coordinate of the origin (on-screen)
  33410. * @param y defines the y coordinate of the origin (on-screen)
  33411. * @param camera defines the camera to use for the picking
  33412. * @returns a Ray
  33413. */
  33414. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33415. /**
  33416. * Creates a ray that can be used to pick in the scene
  33417. * @param x defines the x coordinate of the origin (on-screen)
  33418. * @param y defines the y coordinate of the origin (on-screen)
  33419. * @param result defines the ray where to store the picking ray
  33420. * @param camera defines the camera to use for the picking
  33421. * @returns the current scene
  33422. */
  33423. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33424. /** Launch a ray to try to pick a mesh in the scene
  33425. * @param x position on screen
  33426. * @param y position on screen
  33427. * @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
  33428. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33429. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33430. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33431. * @returns a PickingInfo
  33432. */
  33433. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33434. /** Use the given ray to pick a mesh in the scene
  33435. * @param ray The ray to use to pick meshes
  33436. * @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
  33437. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33438. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33439. * @returns a PickingInfo
  33440. */
  33441. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33442. /**
  33443. * Launch a ray to try to pick a mesh in the scene
  33444. * @param x X position on screen
  33445. * @param y Y position on screen
  33446. * @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
  33447. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33448. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33449. * @returns an array of PickingInfo
  33450. */
  33451. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33452. /**
  33453. * Launch a ray to try to pick a mesh in the scene
  33454. * @param ray Ray to use
  33455. * @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
  33456. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33457. * @returns an array of PickingInfo
  33458. */
  33459. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33460. /**
  33461. * Force the value of meshUnderPointer
  33462. * @param mesh defines the mesh to use
  33463. */
  33464. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33465. /**
  33466. * Gets the mesh under the pointer
  33467. * @returns a Mesh or null if no mesh is under the pointer
  33468. */
  33469. getPointerOverMesh(): Nullable<AbstractMesh>;
  33470. /** @hidden */
  33471. _rebuildGeometries(): void;
  33472. /** @hidden */
  33473. _rebuildTextures(): void;
  33474. private _getByTags;
  33475. /**
  33476. * Get a list of meshes by tags
  33477. * @param tagsQuery defines the tags query to use
  33478. * @param forEach defines a predicate used to filter results
  33479. * @returns an array of Mesh
  33480. */
  33481. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33482. /**
  33483. * Get a list of cameras by tags
  33484. * @param tagsQuery defines the tags query to use
  33485. * @param forEach defines a predicate used to filter results
  33486. * @returns an array of Camera
  33487. */
  33488. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33489. /**
  33490. * Get a list of lights by tags
  33491. * @param tagsQuery defines the tags query to use
  33492. * @param forEach defines a predicate used to filter results
  33493. * @returns an array of Light
  33494. */
  33495. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33496. /**
  33497. * Get a list of materials by tags
  33498. * @param tagsQuery defines the tags query to use
  33499. * @param forEach defines a predicate used to filter results
  33500. * @returns an array of Material
  33501. */
  33502. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33503. /**
  33504. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33505. * This allowed control for front to back rendering or reversly depending of the special needs.
  33506. *
  33507. * @param renderingGroupId The rendering group id corresponding to its index
  33508. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33509. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33510. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33511. */
  33512. 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;
  33513. /**
  33514. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33515. *
  33516. * @param renderingGroupId The rendering group id corresponding to its index
  33517. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33518. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33519. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33520. */
  33521. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33522. /**
  33523. * Gets the current auto clear configuration for one rendering group of the rendering
  33524. * manager.
  33525. * @param index the rendering group index to get the information for
  33526. * @returns The auto clear setup for the requested rendering group
  33527. */
  33528. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33529. private _blockMaterialDirtyMechanism;
  33530. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33531. blockMaterialDirtyMechanism: boolean;
  33532. /**
  33533. * Will flag all materials as dirty to trigger new shader compilation
  33534. * @param flag defines the flag used to specify which material part must be marked as dirty
  33535. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33536. */
  33537. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33538. /** @hidden */
  33539. _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;
  33540. /** @hidden */
  33541. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33542. }
  33543. }
  33544. declare module "babylonjs/assetContainer" {
  33545. import { AbstractScene } from "babylonjs/abstractScene";
  33546. import { Scene } from "babylonjs/scene";
  33547. import { Mesh } from "babylonjs/Meshes/mesh";
  33548. /**
  33549. * Set of assets to keep when moving a scene into an asset container.
  33550. */
  33551. export class KeepAssets extends AbstractScene {
  33552. }
  33553. /**
  33554. * Container with a set of assets that can be added or removed from a scene.
  33555. */
  33556. export class AssetContainer extends AbstractScene {
  33557. /**
  33558. * The scene the AssetContainer belongs to.
  33559. */
  33560. scene: Scene;
  33561. /**
  33562. * Instantiates an AssetContainer.
  33563. * @param scene The scene the AssetContainer belongs to.
  33564. */
  33565. constructor(scene: Scene);
  33566. /**
  33567. * Adds all the assets from the container to the scene.
  33568. */
  33569. addAllToScene(): void;
  33570. /**
  33571. * Removes all the assets in the container from the scene
  33572. */
  33573. removeAllFromScene(): void;
  33574. /**
  33575. * Disposes all the assets in the container
  33576. */
  33577. dispose(): void;
  33578. private _moveAssets;
  33579. /**
  33580. * Removes all the assets contained in the scene and adds them to the container.
  33581. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33582. */
  33583. moveAllFromScene(keepAssets?: KeepAssets): void;
  33584. /**
  33585. * 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.
  33586. * @returns the root mesh
  33587. */
  33588. createRootMesh(): Mesh;
  33589. }
  33590. }
  33591. declare module "babylonjs/abstractScene" {
  33592. import { Scene } from "babylonjs/scene";
  33593. import { Nullable } from "babylonjs/types";
  33594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33595. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33596. import { Geometry } from "babylonjs/Meshes/geometry";
  33597. import { Skeleton } from "babylonjs/Bones/skeleton";
  33598. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33599. import { AssetContainer } from "babylonjs/assetContainer";
  33600. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33601. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33602. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33603. import { Material } from "babylonjs/Materials/material";
  33604. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33605. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33606. import { Camera } from "babylonjs/Cameras/camera";
  33607. import { Light } from "babylonjs/Lights/light";
  33608. import { Node } from "babylonjs/node";
  33609. import { Animation } from "babylonjs/Animations/animation";
  33610. /**
  33611. * Defines how the parser contract is defined.
  33612. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33613. */
  33614. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33615. /**
  33616. * Defines how the individual parser contract is defined.
  33617. * These parser can parse an individual asset
  33618. */
  33619. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33620. /**
  33621. * Base class of the scene acting as a container for the different elements composing a scene.
  33622. * This class is dynamically extended by the different components of the scene increasing
  33623. * flexibility and reducing coupling
  33624. */
  33625. export abstract class AbstractScene {
  33626. /**
  33627. * Stores the list of available parsers in the application.
  33628. */
  33629. private static _BabylonFileParsers;
  33630. /**
  33631. * Stores the list of available individual parsers in the application.
  33632. */
  33633. private static _IndividualBabylonFileParsers;
  33634. /**
  33635. * Adds a parser in the list of available ones
  33636. * @param name Defines the name of the parser
  33637. * @param parser Defines the parser to add
  33638. */
  33639. static AddParser(name: string, parser: BabylonFileParser): void;
  33640. /**
  33641. * Gets a general parser from the list of avaialble ones
  33642. * @param name Defines the name of the parser
  33643. * @returns the requested parser or null
  33644. */
  33645. static GetParser(name: string): Nullable<BabylonFileParser>;
  33646. /**
  33647. * Adds n individual parser in the list of available ones
  33648. * @param name Defines the name of the parser
  33649. * @param parser Defines the parser to add
  33650. */
  33651. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33652. /**
  33653. * Gets an individual parser from the list of avaialble ones
  33654. * @param name Defines the name of the parser
  33655. * @returns the requested parser or null
  33656. */
  33657. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33658. /**
  33659. * Parser json data and populate both a scene and its associated container object
  33660. * @param jsonData Defines the data to parse
  33661. * @param scene Defines the scene to parse the data for
  33662. * @param container Defines the container attached to the parsing sequence
  33663. * @param rootUrl Defines the root url of the data
  33664. */
  33665. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33666. /**
  33667. * Gets the list of root nodes (ie. nodes with no parent)
  33668. */
  33669. rootNodes: Node[];
  33670. /** All of the cameras added to this scene
  33671. * @see http://doc.babylonjs.com/babylon101/cameras
  33672. */
  33673. cameras: Camera[];
  33674. /**
  33675. * All of the lights added to this scene
  33676. * @see http://doc.babylonjs.com/babylon101/lights
  33677. */
  33678. lights: Light[];
  33679. /**
  33680. * All of the (abstract) meshes added to this scene
  33681. */
  33682. meshes: AbstractMesh[];
  33683. /**
  33684. * The list of skeletons added to the scene
  33685. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33686. */
  33687. skeletons: Skeleton[];
  33688. /**
  33689. * All of the particle systems added to this scene
  33690. * @see http://doc.babylonjs.com/babylon101/particles
  33691. */
  33692. particleSystems: IParticleSystem[];
  33693. /**
  33694. * Gets a list of Animations associated with the scene
  33695. */
  33696. animations: Animation[];
  33697. /**
  33698. * All of the animation groups added to this scene
  33699. * @see http://doc.babylonjs.com/how_to/group
  33700. */
  33701. animationGroups: AnimationGroup[];
  33702. /**
  33703. * All of the multi-materials added to this scene
  33704. * @see http://doc.babylonjs.com/how_to/multi_materials
  33705. */
  33706. multiMaterials: MultiMaterial[];
  33707. /**
  33708. * All of the materials added to this scene
  33709. * In the context of a Scene, it is not supposed to be modified manually.
  33710. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33711. * Note also that the order of the Material wihin the array is not significant and might change.
  33712. * @see http://doc.babylonjs.com/babylon101/materials
  33713. */
  33714. materials: Material[];
  33715. /**
  33716. * The list of morph target managers added to the scene
  33717. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33718. */
  33719. morphTargetManagers: MorphTargetManager[];
  33720. /**
  33721. * The list of geometries used in the scene.
  33722. */
  33723. geometries: Geometry[];
  33724. /**
  33725. * All of the tranform nodes added to this scene
  33726. * In the context of a Scene, it is not supposed to be modified manually.
  33727. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33728. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33729. * @see http://doc.babylonjs.com/how_to/transformnode
  33730. */
  33731. transformNodes: TransformNode[];
  33732. /**
  33733. * ActionManagers available on the scene.
  33734. */
  33735. actionManagers: AbstractActionManager[];
  33736. /**
  33737. * Textures to keep.
  33738. */
  33739. textures: BaseTexture[];
  33740. }
  33741. }
  33742. declare module "babylonjs/Audio/sound" {
  33743. import { Observable } from "babylonjs/Misc/observable";
  33744. import { Vector3 } from "babylonjs/Maths/math";
  33745. import { Nullable } from "babylonjs/types";
  33746. import { Scene } from "babylonjs/scene";
  33747. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33748. /**
  33749. * Defines a sound that can be played in the application.
  33750. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33752. */
  33753. export class Sound {
  33754. /**
  33755. * The name of the sound in the scene.
  33756. */
  33757. name: string;
  33758. /**
  33759. * Does the sound autoplay once loaded.
  33760. */
  33761. autoplay: boolean;
  33762. /**
  33763. * Does the sound loop after it finishes playing once.
  33764. */
  33765. loop: boolean;
  33766. /**
  33767. * Does the sound use a custom attenuation curve to simulate the falloff
  33768. * happening when the source gets further away from the camera.
  33769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33770. */
  33771. useCustomAttenuation: boolean;
  33772. /**
  33773. * The sound track id this sound belongs to.
  33774. */
  33775. soundTrackId: number;
  33776. /**
  33777. * Is this sound currently played.
  33778. */
  33779. isPlaying: boolean;
  33780. /**
  33781. * Is this sound currently paused.
  33782. */
  33783. isPaused: boolean;
  33784. /**
  33785. * Does this sound enables spatial sound.
  33786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33787. */
  33788. spatialSound: boolean;
  33789. /**
  33790. * Define the reference distance the sound should be heard perfectly.
  33791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33792. */
  33793. refDistance: number;
  33794. /**
  33795. * Define the roll off factor of spatial sounds.
  33796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33797. */
  33798. rolloffFactor: number;
  33799. /**
  33800. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33802. */
  33803. maxDistance: number;
  33804. /**
  33805. * Define the distance attenuation model the sound will follow.
  33806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33807. */
  33808. distanceModel: string;
  33809. /**
  33810. * @hidden
  33811. * Back Compat
  33812. **/
  33813. onended: () => any;
  33814. /**
  33815. * Observable event when the current playing sound finishes.
  33816. */
  33817. onEndedObservable: Observable<Sound>;
  33818. private _panningModel;
  33819. private _playbackRate;
  33820. private _streaming;
  33821. private _startTime;
  33822. private _startOffset;
  33823. private _position;
  33824. /** @hidden */
  33825. _positionInEmitterSpace: boolean;
  33826. private _localDirection;
  33827. private _volume;
  33828. private _isReadyToPlay;
  33829. private _isDirectional;
  33830. private _readyToPlayCallback;
  33831. private _audioBuffer;
  33832. private _soundSource;
  33833. private _streamingSource;
  33834. private _soundPanner;
  33835. private _soundGain;
  33836. private _inputAudioNode;
  33837. private _outputAudioNode;
  33838. private _coneInnerAngle;
  33839. private _coneOuterAngle;
  33840. private _coneOuterGain;
  33841. private _scene;
  33842. private _connectedTransformNode;
  33843. private _customAttenuationFunction;
  33844. private _registerFunc;
  33845. private _isOutputConnected;
  33846. private _htmlAudioElement;
  33847. private _urlType;
  33848. /** @hidden */
  33849. static _SceneComponentInitialization: (scene: Scene) => void;
  33850. /**
  33851. * Create a sound and attach it to a scene
  33852. * @param name Name of your sound
  33853. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33854. * @param scene defines the scene the sound belongs to
  33855. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33856. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33857. */
  33858. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33859. /**
  33860. * Release the sound and its associated resources
  33861. */
  33862. dispose(): void;
  33863. /**
  33864. * Gets if the sounds is ready to be played or not.
  33865. * @returns true if ready, otherwise false
  33866. */
  33867. isReady(): boolean;
  33868. private _soundLoaded;
  33869. /**
  33870. * Sets the data of the sound from an audiobuffer
  33871. * @param audioBuffer The audioBuffer containing the data
  33872. */
  33873. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33874. /**
  33875. * Updates the current sounds options such as maxdistance, loop...
  33876. * @param options A JSON object containing values named as the object properties
  33877. */
  33878. updateOptions(options: any): void;
  33879. private _createSpatialParameters;
  33880. private _updateSpatialParameters;
  33881. /**
  33882. * Switch the panning model to HRTF:
  33883. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33885. */
  33886. switchPanningModelToHRTF(): void;
  33887. /**
  33888. * Switch the panning model to Equal Power:
  33889. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33891. */
  33892. switchPanningModelToEqualPower(): void;
  33893. private _switchPanningModel;
  33894. /**
  33895. * Connect this sound to a sound track audio node like gain...
  33896. * @param soundTrackAudioNode the sound track audio node to connect to
  33897. */
  33898. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33899. /**
  33900. * Transform this sound into a directional source
  33901. * @param coneInnerAngle Size of the inner cone in degree
  33902. * @param coneOuterAngle Size of the outer cone in degree
  33903. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33904. */
  33905. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33906. /**
  33907. * Gets or sets the inner angle for the directional cone.
  33908. */
  33909. /**
  33910. * Gets or sets the inner angle for the directional cone.
  33911. */
  33912. directionalConeInnerAngle: number;
  33913. /**
  33914. * Gets or sets the outer angle for the directional cone.
  33915. */
  33916. /**
  33917. * Gets or sets the outer angle for the directional cone.
  33918. */
  33919. directionalConeOuterAngle: number;
  33920. /**
  33921. * Sets the position of the emitter if spatial sound is enabled
  33922. * @param newPosition Defines the new posisiton
  33923. */
  33924. setPosition(newPosition: Vector3): void;
  33925. /**
  33926. * Sets the local direction of the emitter if spatial sound is enabled
  33927. * @param newLocalDirection Defines the new local direction
  33928. */
  33929. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33930. private _updateDirection;
  33931. /** @hidden */
  33932. updateDistanceFromListener(): void;
  33933. /**
  33934. * Sets a new custom attenuation function for the sound.
  33935. * @param callback Defines the function used for the attenuation
  33936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33937. */
  33938. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33939. /**
  33940. * Play the sound
  33941. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33942. * @param offset (optional) Start the sound setting it at a specific time
  33943. */
  33944. play(time?: number, offset?: number): void;
  33945. private _onended;
  33946. /**
  33947. * Stop the sound
  33948. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33949. */
  33950. stop(time?: number): void;
  33951. /**
  33952. * Put the sound in pause
  33953. */
  33954. pause(): void;
  33955. /**
  33956. * Sets a dedicated volume for this sounds
  33957. * @param newVolume Define the new volume of the sound
  33958. * @param time Define in how long the sound should be at this value
  33959. */
  33960. setVolume(newVolume: number, time?: number): void;
  33961. /**
  33962. * Set the sound play back rate
  33963. * @param newPlaybackRate Define the playback rate the sound should be played at
  33964. */
  33965. setPlaybackRate(newPlaybackRate: number): void;
  33966. /**
  33967. * Gets the volume of the sound.
  33968. * @returns the volume of the sound
  33969. */
  33970. getVolume(): number;
  33971. /**
  33972. * Attach the sound to a dedicated mesh
  33973. * @param transformNode The transform node to connect the sound with
  33974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33975. */
  33976. attachToMesh(transformNode: TransformNode): void;
  33977. /**
  33978. * Detach the sound from the previously attached mesh
  33979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33980. */
  33981. detachFromMesh(): void;
  33982. private _onRegisterAfterWorldMatrixUpdate;
  33983. /**
  33984. * Clone the current sound in the scene.
  33985. * @returns the new sound clone
  33986. */
  33987. clone(): Nullable<Sound>;
  33988. /**
  33989. * Gets the current underlying audio buffer containing the data
  33990. * @returns the audio buffer
  33991. */
  33992. getAudioBuffer(): Nullable<AudioBuffer>;
  33993. /**
  33994. * Serializes the Sound in a JSON representation
  33995. * @returns the JSON representation of the sound
  33996. */
  33997. serialize(): any;
  33998. /**
  33999. * Parse a JSON representation of a sound to innstantiate in a given scene
  34000. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34001. * @param scene Define the scene the new parsed sound should be created in
  34002. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34003. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34004. * @returns the newly parsed sound
  34005. */
  34006. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34007. }
  34008. }
  34009. declare module "babylonjs/Actions/directAudioActions" {
  34010. import { Action } from "babylonjs/Actions/action";
  34011. import { Condition } from "babylonjs/Actions/condition";
  34012. import { Sound } from "babylonjs/Audio/sound";
  34013. /**
  34014. * This defines an action helpful to play a defined sound on a triggered action.
  34015. */
  34016. export class PlaySoundAction extends Action {
  34017. private _sound;
  34018. /**
  34019. * Instantiate the action
  34020. * @param triggerOptions defines the trigger options
  34021. * @param sound defines the sound to play
  34022. * @param condition defines the trigger related conditions
  34023. */
  34024. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34025. /** @hidden */
  34026. _prepare(): void;
  34027. /**
  34028. * Execute the action and play the sound.
  34029. */
  34030. execute(): void;
  34031. /**
  34032. * Serializes the actions and its related information.
  34033. * @param parent defines the object to serialize in
  34034. * @returns the serialized object
  34035. */
  34036. serialize(parent: any): any;
  34037. }
  34038. /**
  34039. * This defines an action helpful to stop a defined sound on a triggered action.
  34040. */
  34041. export class StopSoundAction extends Action {
  34042. private _sound;
  34043. /**
  34044. * Instantiate the action
  34045. * @param triggerOptions defines the trigger options
  34046. * @param sound defines the sound to stop
  34047. * @param condition defines the trigger related conditions
  34048. */
  34049. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34050. /** @hidden */
  34051. _prepare(): void;
  34052. /**
  34053. * Execute the action and stop the sound.
  34054. */
  34055. execute(): void;
  34056. /**
  34057. * Serializes the actions and its related information.
  34058. * @param parent defines the object to serialize in
  34059. * @returns the serialized object
  34060. */
  34061. serialize(parent: any): any;
  34062. }
  34063. }
  34064. declare module "babylonjs/Actions/interpolateValueAction" {
  34065. import { Action } from "babylonjs/Actions/action";
  34066. import { Condition } from "babylonjs/Actions/condition";
  34067. import { Observable } from "babylonjs/Misc/observable";
  34068. /**
  34069. * This defines an action responsible to change the value of a property
  34070. * by interpolating between its current value and the newly set one once triggered.
  34071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34072. */
  34073. export class InterpolateValueAction extends Action {
  34074. /**
  34075. * Defines the path of the property where the value should be interpolated
  34076. */
  34077. propertyPath: string;
  34078. /**
  34079. * Defines the target value at the end of the interpolation.
  34080. */
  34081. value: any;
  34082. /**
  34083. * Defines the time it will take for the property to interpolate to the value.
  34084. */
  34085. duration: number;
  34086. /**
  34087. * Defines if the other scene animations should be stopped when the action has been triggered
  34088. */
  34089. stopOtherAnimations?: boolean;
  34090. /**
  34091. * Defines a callback raised once the interpolation animation has been done.
  34092. */
  34093. onInterpolationDone?: () => void;
  34094. /**
  34095. * Observable triggered once the interpolation animation has been done.
  34096. */
  34097. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34098. private _target;
  34099. private _effectiveTarget;
  34100. private _property;
  34101. /**
  34102. * Instantiate the action
  34103. * @param triggerOptions defines the trigger options
  34104. * @param target defines the object containing the value to interpolate
  34105. * @param propertyPath defines the path to the property in the target object
  34106. * @param value defines the target value at the end of the interpolation
  34107. * @param duration deines the time it will take for the property to interpolate to the value.
  34108. * @param condition defines the trigger related conditions
  34109. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34110. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34111. */
  34112. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34113. /** @hidden */
  34114. _prepare(): void;
  34115. /**
  34116. * Execute the action starts the value interpolation.
  34117. */
  34118. execute(): void;
  34119. /**
  34120. * Serializes the actions and its related information.
  34121. * @param parent defines the object to serialize in
  34122. * @returns the serialized object
  34123. */
  34124. serialize(parent: any): any;
  34125. }
  34126. }
  34127. declare module "babylonjs/Actions/index" {
  34128. export * from "babylonjs/Actions/action";
  34129. export * from "babylonjs/Actions/actionEvent";
  34130. export * from "babylonjs/Actions/actionManager";
  34131. export * from "babylonjs/Actions/condition";
  34132. export * from "babylonjs/Actions/directActions";
  34133. export * from "babylonjs/Actions/directAudioActions";
  34134. export * from "babylonjs/Actions/interpolateValueAction";
  34135. }
  34136. declare module "babylonjs/Animations/index" {
  34137. export * from "babylonjs/Animations/animatable";
  34138. export * from "babylonjs/Animations/animation";
  34139. export * from "babylonjs/Animations/animationGroup";
  34140. export * from "babylonjs/Animations/animationPropertiesOverride";
  34141. export * from "babylonjs/Animations/easing";
  34142. export * from "babylonjs/Animations/runtimeAnimation";
  34143. export * from "babylonjs/Animations/animationEvent";
  34144. export * from "babylonjs/Animations/animationGroup";
  34145. export * from "babylonjs/Animations/animationKey";
  34146. export * from "babylonjs/Animations/animationRange";
  34147. }
  34148. declare module "babylonjs/Audio/soundTrack" {
  34149. import { Sound } from "babylonjs/Audio/sound";
  34150. import { Analyser } from "babylonjs/Audio/analyser";
  34151. import { Scene } from "babylonjs/scene";
  34152. /**
  34153. * Options allowed during the creation of a sound track.
  34154. */
  34155. export interface ISoundTrackOptions {
  34156. /**
  34157. * The volume the sound track should take during creation
  34158. */
  34159. volume?: number;
  34160. /**
  34161. * Define if the sound track is the main sound track of the scene
  34162. */
  34163. mainTrack?: boolean;
  34164. }
  34165. /**
  34166. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34167. * It will be also used in a future release to apply effects on a specific track.
  34168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34169. */
  34170. export class SoundTrack {
  34171. /**
  34172. * The unique identifier of the sound track in the scene.
  34173. */
  34174. id: number;
  34175. /**
  34176. * The list of sounds included in the sound track.
  34177. */
  34178. soundCollection: Array<Sound>;
  34179. private _outputAudioNode;
  34180. private _scene;
  34181. private _isMainTrack;
  34182. private _connectedAnalyser;
  34183. private _options;
  34184. private _isInitialized;
  34185. /**
  34186. * Creates a new sound track.
  34187. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34188. * @param scene Define the scene the sound track belongs to
  34189. * @param options
  34190. */
  34191. constructor(scene: Scene, options?: ISoundTrackOptions);
  34192. private _initializeSoundTrackAudioGraph;
  34193. /**
  34194. * Release the sound track and its associated resources
  34195. */
  34196. dispose(): void;
  34197. /**
  34198. * Adds a sound to this sound track
  34199. * @param sound define the cound to add
  34200. * @ignoreNaming
  34201. */
  34202. AddSound(sound: Sound): void;
  34203. /**
  34204. * Removes a sound to this sound track
  34205. * @param sound define the cound to remove
  34206. * @ignoreNaming
  34207. */
  34208. RemoveSound(sound: Sound): void;
  34209. /**
  34210. * Set a global volume for the full sound track.
  34211. * @param newVolume Define the new volume of the sound track
  34212. */
  34213. setVolume(newVolume: number): void;
  34214. /**
  34215. * Switch the panning model to HRTF:
  34216. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34218. */
  34219. switchPanningModelToHRTF(): void;
  34220. /**
  34221. * Switch the panning model to Equal Power:
  34222. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34224. */
  34225. switchPanningModelToEqualPower(): void;
  34226. /**
  34227. * Connect the sound track to an audio analyser allowing some amazing
  34228. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34230. * @param analyser The analyser to connect to the engine
  34231. */
  34232. connectToAnalyser(analyser: Analyser): void;
  34233. }
  34234. }
  34235. declare module "babylonjs/Audio/audioSceneComponent" {
  34236. import { Sound } from "babylonjs/Audio/sound";
  34237. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34238. import { Nullable } from "babylonjs/types";
  34239. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34240. import { Scene } from "babylonjs/scene";
  34241. import { AbstractScene } from "babylonjs/abstractScene";
  34242. module "babylonjs/abstractScene" {
  34243. interface AbstractScene {
  34244. /**
  34245. * The list of sounds used in the scene.
  34246. */
  34247. sounds: Nullable<Array<Sound>>;
  34248. }
  34249. }
  34250. module "babylonjs/scene" {
  34251. interface Scene {
  34252. /**
  34253. * @hidden
  34254. * Backing field
  34255. */
  34256. _mainSoundTrack: SoundTrack;
  34257. /**
  34258. * The main sound track played by the scene.
  34259. * It cotains your primary collection of sounds.
  34260. */
  34261. mainSoundTrack: SoundTrack;
  34262. /**
  34263. * The list of sound tracks added to the scene
  34264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34265. */
  34266. soundTracks: Nullable<Array<SoundTrack>>;
  34267. /**
  34268. * Gets a sound using a given name
  34269. * @param name defines the name to search for
  34270. * @return the found sound or null if not found at all.
  34271. */
  34272. getSoundByName(name: string): Nullable<Sound>;
  34273. /**
  34274. * Gets or sets if audio support is enabled
  34275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34276. */
  34277. audioEnabled: boolean;
  34278. /**
  34279. * Gets or sets if audio will be output to headphones
  34280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34281. */
  34282. headphone: boolean;
  34283. }
  34284. }
  34285. /**
  34286. * Defines the sound scene component responsible to manage any sounds
  34287. * in a given scene.
  34288. */
  34289. export class AudioSceneComponent implements ISceneSerializableComponent {
  34290. /**
  34291. * The component name helpfull to identify the component in the list of scene components.
  34292. */
  34293. readonly name: string;
  34294. /**
  34295. * The scene the component belongs to.
  34296. */
  34297. scene: Scene;
  34298. private _audioEnabled;
  34299. /**
  34300. * Gets whether audio is enabled or not.
  34301. * Please use related enable/disable method to switch state.
  34302. */
  34303. readonly audioEnabled: boolean;
  34304. private _headphone;
  34305. /**
  34306. * Gets whether audio is outputing to headphone or not.
  34307. * Please use the according Switch methods to change output.
  34308. */
  34309. readonly headphone: boolean;
  34310. /**
  34311. * Creates a new instance of the component for the given scene
  34312. * @param scene Defines the scene to register the component in
  34313. */
  34314. constructor(scene: Scene);
  34315. /**
  34316. * Registers the component in a given scene
  34317. */
  34318. register(): void;
  34319. /**
  34320. * Rebuilds the elements related to this component in case of
  34321. * context lost for instance.
  34322. */
  34323. rebuild(): void;
  34324. /**
  34325. * Serializes the component data to the specified json object
  34326. * @param serializationObject The object to serialize to
  34327. */
  34328. serialize(serializationObject: any): void;
  34329. /**
  34330. * Adds all the element from the container to the scene
  34331. * @param container the container holding the elements
  34332. */
  34333. addFromContainer(container: AbstractScene): void;
  34334. /**
  34335. * Removes all the elements in the container from the scene
  34336. * @param container contains the elements to remove
  34337. */
  34338. removeFromContainer(container: AbstractScene): void;
  34339. /**
  34340. * Disposes the component and the associated ressources.
  34341. */
  34342. dispose(): void;
  34343. /**
  34344. * Disables audio in the associated scene.
  34345. */
  34346. disableAudio(): void;
  34347. /**
  34348. * Enables audio in the associated scene.
  34349. */
  34350. enableAudio(): void;
  34351. /**
  34352. * Switch audio to headphone output.
  34353. */
  34354. switchAudioModeForHeadphones(): void;
  34355. /**
  34356. * Switch audio to normal speakers.
  34357. */
  34358. switchAudioModeForNormalSpeakers(): void;
  34359. private _afterRender;
  34360. }
  34361. }
  34362. declare module "babylonjs/Audio/weightedsound" {
  34363. import { Sound } from "babylonjs/Audio/sound";
  34364. /**
  34365. * Wraps one or more Sound objects and selects one with random weight for playback.
  34366. */
  34367. export class WeightedSound {
  34368. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34369. loop: boolean;
  34370. private _coneInnerAngle;
  34371. private _coneOuterAngle;
  34372. private _volume;
  34373. /** A Sound is currently playing. */
  34374. isPlaying: boolean;
  34375. /** A Sound is currently paused. */
  34376. isPaused: boolean;
  34377. private _sounds;
  34378. private _weights;
  34379. private _currentIndex?;
  34380. /**
  34381. * Creates a new WeightedSound from the list of sounds given.
  34382. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34383. * @param sounds Array of Sounds that will be selected from.
  34384. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34385. */
  34386. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34387. /**
  34388. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34389. */
  34390. /**
  34391. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34392. */
  34393. directionalConeInnerAngle: number;
  34394. /**
  34395. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34396. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34397. */
  34398. /**
  34399. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34400. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34401. */
  34402. directionalConeOuterAngle: number;
  34403. /**
  34404. * Playback volume.
  34405. */
  34406. /**
  34407. * Playback volume.
  34408. */
  34409. volume: number;
  34410. private _onended;
  34411. /**
  34412. * Suspend playback
  34413. */
  34414. pause(): void;
  34415. /**
  34416. * Stop playback
  34417. */
  34418. stop(): void;
  34419. /**
  34420. * Start playback.
  34421. * @param startOffset Position the clip head at a specific time in seconds.
  34422. */
  34423. play(startOffset?: number): void;
  34424. }
  34425. }
  34426. declare module "babylonjs/Audio/index" {
  34427. export * from "babylonjs/Audio/analyser";
  34428. export * from "babylonjs/Audio/audioEngine";
  34429. export * from "babylonjs/Audio/audioSceneComponent";
  34430. export * from "babylonjs/Audio/sound";
  34431. export * from "babylonjs/Audio/soundTrack";
  34432. export * from "babylonjs/Audio/weightedsound";
  34433. }
  34434. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34435. import { Behavior } from "babylonjs/Behaviors/behavior";
  34436. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34437. import { BackEase } from "babylonjs/Animations/easing";
  34438. /**
  34439. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34440. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34441. */
  34442. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34443. /**
  34444. * Gets the name of the behavior.
  34445. */
  34446. readonly name: string;
  34447. /**
  34448. * The easing function used by animations
  34449. */
  34450. static EasingFunction: BackEase;
  34451. /**
  34452. * The easing mode used by animations
  34453. */
  34454. static EasingMode: number;
  34455. /**
  34456. * The duration of the animation, in milliseconds
  34457. */
  34458. transitionDuration: number;
  34459. /**
  34460. * Length of the distance animated by the transition when lower radius is reached
  34461. */
  34462. lowerRadiusTransitionRange: number;
  34463. /**
  34464. * Length of the distance animated by the transition when upper radius is reached
  34465. */
  34466. upperRadiusTransitionRange: number;
  34467. private _autoTransitionRange;
  34468. /**
  34469. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34470. */
  34471. /**
  34472. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34473. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34474. */
  34475. autoTransitionRange: boolean;
  34476. private _attachedCamera;
  34477. private _onAfterCheckInputsObserver;
  34478. private _onMeshTargetChangedObserver;
  34479. /**
  34480. * Initializes the behavior.
  34481. */
  34482. init(): void;
  34483. /**
  34484. * Attaches the behavior to its arc rotate camera.
  34485. * @param camera Defines the camera to attach the behavior to
  34486. */
  34487. attach(camera: ArcRotateCamera): void;
  34488. /**
  34489. * Detaches the behavior from its current arc rotate camera.
  34490. */
  34491. detach(): void;
  34492. private _radiusIsAnimating;
  34493. private _radiusBounceTransition;
  34494. private _animatables;
  34495. private _cachedWheelPrecision;
  34496. /**
  34497. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34498. * @param radiusLimit The limit to check against.
  34499. * @return Bool to indicate if at limit.
  34500. */
  34501. private _isRadiusAtLimit;
  34502. /**
  34503. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34504. * @param radiusDelta The delta by which to animate to. Can be negative.
  34505. */
  34506. private _applyBoundRadiusAnimation;
  34507. /**
  34508. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34509. */
  34510. protected _clearAnimationLocks(): void;
  34511. /**
  34512. * Stops and removes all animations that have been applied to the camera
  34513. */
  34514. stopAllAnimations(): void;
  34515. }
  34516. }
  34517. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34518. import { Behavior } from "babylonjs/Behaviors/behavior";
  34519. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34520. import { ExponentialEase } from "babylonjs/Animations/easing";
  34521. import { Nullable } from "babylonjs/types";
  34522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34523. import { Vector3 } from "babylonjs/Maths/math";
  34524. /**
  34525. * 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.
  34526. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34527. */
  34528. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34529. /**
  34530. * Gets the name of the behavior.
  34531. */
  34532. readonly name: string;
  34533. private _mode;
  34534. private _radiusScale;
  34535. private _positionScale;
  34536. private _defaultElevation;
  34537. private _elevationReturnTime;
  34538. private _elevationReturnWaitTime;
  34539. private _zoomStopsAnimation;
  34540. private _framingTime;
  34541. /**
  34542. * The easing function used by animations
  34543. */
  34544. static EasingFunction: ExponentialEase;
  34545. /**
  34546. * The easing mode used by animations
  34547. */
  34548. static EasingMode: number;
  34549. /**
  34550. * Sets the current mode used by the behavior
  34551. */
  34552. /**
  34553. * Gets current mode used by the behavior.
  34554. */
  34555. mode: number;
  34556. /**
  34557. * Sets the scale applied to the radius (1 by default)
  34558. */
  34559. /**
  34560. * Gets the scale applied to the radius
  34561. */
  34562. radiusScale: number;
  34563. /**
  34564. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34565. */
  34566. /**
  34567. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34568. */
  34569. positionScale: number;
  34570. /**
  34571. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34572. * behaviour is triggered, in radians.
  34573. */
  34574. /**
  34575. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34576. * behaviour is triggered, in radians.
  34577. */
  34578. defaultElevation: number;
  34579. /**
  34580. * Sets the time (in milliseconds) taken to return to the default beta position.
  34581. * Negative value indicates camera should not return to default.
  34582. */
  34583. /**
  34584. * Gets the time (in milliseconds) taken to return to the default beta position.
  34585. * Negative value indicates camera should not return to default.
  34586. */
  34587. elevationReturnTime: number;
  34588. /**
  34589. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34590. */
  34591. /**
  34592. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34593. */
  34594. elevationReturnWaitTime: number;
  34595. /**
  34596. * Sets the flag that indicates if user zooming should stop animation.
  34597. */
  34598. /**
  34599. * Gets the flag that indicates if user zooming should stop animation.
  34600. */
  34601. zoomStopsAnimation: boolean;
  34602. /**
  34603. * Sets the transition time when framing the mesh, in milliseconds
  34604. */
  34605. /**
  34606. * Gets the transition time when framing the mesh, in milliseconds
  34607. */
  34608. framingTime: number;
  34609. /**
  34610. * Define if the behavior should automatically change the configured
  34611. * camera limits and sensibilities.
  34612. */
  34613. autoCorrectCameraLimitsAndSensibility: boolean;
  34614. private _onPrePointerObservableObserver;
  34615. private _onAfterCheckInputsObserver;
  34616. private _onMeshTargetChangedObserver;
  34617. private _attachedCamera;
  34618. private _isPointerDown;
  34619. private _lastInteractionTime;
  34620. /**
  34621. * Initializes the behavior.
  34622. */
  34623. init(): void;
  34624. /**
  34625. * Attaches the behavior to its arc rotate camera.
  34626. * @param camera Defines the camera to attach the behavior to
  34627. */
  34628. attach(camera: ArcRotateCamera): void;
  34629. /**
  34630. * Detaches the behavior from its current arc rotate camera.
  34631. */
  34632. detach(): void;
  34633. private _animatables;
  34634. private _betaIsAnimating;
  34635. private _betaTransition;
  34636. private _radiusTransition;
  34637. private _vectorTransition;
  34638. /**
  34639. * Targets the given mesh and updates zoom level accordingly.
  34640. * @param mesh The mesh to target.
  34641. * @param radius Optional. If a cached radius position already exists, overrides default.
  34642. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34643. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34644. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34645. */
  34646. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34647. /**
  34648. * Targets the given mesh with its children and updates zoom level accordingly.
  34649. * @param mesh The mesh to target.
  34650. * @param radius Optional. If a cached radius position already exists, overrides default.
  34651. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34652. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34653. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34654. */
  34655. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34656. /**
  34657. * Targets the given meshes with their children and updates zoom level accordingly.
  34658. * @param meshes The mesh to target.
  34659. * @param radius Optional. If a cached radius position already exists, overrides default.
  34660. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34661. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34662. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34663. */
  34664. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34665. /**
  34666. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34667. * @param minimumWorld Determines the smaller position of the bounding box extend
  34668. * @param maximumWorld Determines the bigger position of the bounding box extend
  34669. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34670. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34671. */
  34672. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34673. /**
  34674. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34675. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34676. * frustum width.
  34677. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34678. * to fully enclose the mesh in the viewing frustum.
  34679. */
  34680. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34681. /**
  34682. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34683. * is automatically returned to its default position (expected to be above ground plane).
  34684. */
  34685. private _maintainCameraAboveGround;
  34686. /**
  34687. * Returns the frustum slope based on the canvas ratio and camera FOV
  34688. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34689. */
  34690. private _getFrustumSlope;
  34691. /**
  34692. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34693. */
  34694. private _clearAnimationLocks;
  34695. /**
  34696. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34697. */
  34698. private _applyUserInteraction;
  34699. /**
  34700. * Stops and removes all animations that have been applied to the camera
  34701. */
  34702. stopAllAnimations(): void;
  34703. /**
  34704. * Gets a value indicating if the user is moving the camera
  34705. */
  34706. readonly isUserIsMoving: boolean;
  34707. /**
  34708. * The camera can move all the way towards the mesh.
  34709. */
  34710. static IgnoreBoundsSizeMode: number;
  34711. /**
  34712. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34713. */
  34714. static FitFrustumSidesMode: number;
  34715. }
  34716. }
  34717. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34718. import { Nullable } from "babylonjs/types";
  34719. import { Camera } from "babylonjs/Cameras/camera";
  34720. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34721. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34722. /**
  34723. * Base class for Camera Pointer Inputs.
  34724. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34725. * for example usage.
  34726. */
  34727. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34728. /**
  34729. * Defines the camera the input is attached to.
  34730. */
  34731. abstract camera: Camera;
  34732. /**
  34733. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34734. */
  34735. protected _altKey: boolean;
  34736. protected _ctrlKey: boolean;
  34737. protected _metaKey: boolean;
  34738. protected _shiftKey: boolean;
  34739. /**
  34740. * Which mouse buttons were pressed at time of last mouse event.
  34741. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34742. */
  34743. protected _buttonsPressed: number;
  34744. /**
  34745. * Defines the buttons associated with the input to handle camera move.
  34746. */
  34747. buttons: number[];
  34748. /**
  34749. * Attach the input controls to a specific dom element to get the input from.
  34750. * @param element Defines the element the controls should be listened from
  34751. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34752. */
  34753. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34754. /**
  34755. * Detach the current controls from the specified dom element.
  34756. * @param element Defines the element to stop listening the inputs from
  34757. */
  34758. detachControl(element: Nullable<HTMLElement>): void;
  34759. /**
  34760. * Gets the class name of the current input.
  34761. * @returns the class name
  34762. */
  34763. getClassName(): string;
  34764. /**
  34765. * Get the friendly name associated with the input class.
  34766. * @returns the input friendly name
  34767. */
  34768. getSimpleName(): string;
  34769. /**
  34770. * Called on pointer POINTERDOUBLETAP event.
  34771. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34772. */
  34773. protected onDoubleTap(type: string): void;
  34774. /**
  34775. * Called on pointer POINTERMOVE event if only a single touch is active.
  34776. * Override this method to provide functionality.
  34777. */
  34778. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34779. /**
  34780. * Called on pointer POINTERMOVE event if multiple touches are active.
  34781. * Override this method to provide functionality.
  34782. */
  34783. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34784. /**
  34785. * Called on JS contextmenu event.
  34786. * Override this method to provide functionality.
  34787. */
  34788. protected onContextMenu(evt: PointerEvent): void;
  34789. /**
  34790. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34791. * press.
  34792. * Override this method to provide functionality.
  34793. */
  34794. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34795. /**
  34796. * Called each time a new POINTERUP event occurs. Ie, for each button
  34797. * release.
  34798. * Override this method to provide functionality.
  34799. */
  34800. protected onButtonUp(evt: PointerEvent): void;
  34801. /**
  34802. * Called when window becomes inactive.
  34803. * Override this method to provide functionality.
  34804. */
  34805. protected onLostFocus(): void;
  34806. private _pointerInput;
  34807. private _observer;
  34808. private _onLostFocus;
  34809. }
  34810. }
  34811. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34812. import { Nullable } from "babylonjs/types";
  34813. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34814. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34815. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34816. /**
  34817. * Manage the pointers inputs to control an arc rotate camera.
  34818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34819. */
  34820. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34821. /**
  34822. * Defines the camera the input is attached to.
  34823. */
  34824. camera: ArcRotateCamera;
  34825. /**
  34826. * Gets the class name of the current input.
  34827. * @returns the class name
  34828. */
  34829. getClassName(): string;
  34830. /**
  34831. * Defines the buttons associated with the input to handle camera move.
  34832. */
  34833. buttons: number[];
  34834. /**
  34835. * Defines the pointer angular sensibility along the X axis or how fast is
  34836. * the camera rotating.
  34837. */
  34838. angularSensibilityX: number;
  34839. /**
  34840. * Defines the pointer angular sensibility along the Y axis or how fast is
  34841. * the camera rotating.
  34842. */
  34843. angularSensibilityY: number;
  34844. /**
  34845. * Defines the pointer pinch precision or how fast is the camera zooming.
  34846. */
  34847. pinchPrecision: number;
  34848. /**
  34849. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34850. * from 0.
  34851. * It defines the percentage of current camera.radius to use as delta when
  34852. * pinch zoom is used.
  34853. */
  34854. pinchDeltaPercentage: number;
  34855. /**
  34856. * Defines the pointer panning sensibility or how fast is the camera moving.
  34857. */
  34858. panningSensibility: number;
  34859. /**
  34860. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34861. */
  34862. multiTouchPanning: boolean;
  34863. /**
  34864. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34865. * zoom (pinch) through multitouch.
  34866. */
  34867. multiTouchPanAndZoom: boolean;
  34868. /**
  34869. * Revers pinch action direction.
  34870. */
  34871. pinchInwards: boolean;
  34872. private _isPanClick;
  34873. private _twoFingerActivityCount;
  34874. private _isPinching;
  34875. /**
  34876. * Called on pointer POINTERMOVE event if only a single touch is active.
  34877. */
  34878. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34879. /**
  34880. * Called on pointer POINTERDOUBLETAP event.
  34881. */
  34882. protected onDoubleTap(type: string): void;
  34883. /**
  34884. * Called on pointer POINTERMOVE event if multiple touches are active.
  34885. */
  34886. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34887. /**
  34888. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34889. * press.
  34890. */
  34891. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34892. /**
  34893. * Called each time a new POINTERUP event occurs. Ie, for each button
  34894. * release.
  34895. */
  34896. protected onButtonUp(evt: PointerEvent): void;
  34897. /**
  34898. * Called when window becomes inactive.
  34899. */
  34900. protected onLostFocus(): void;
  34901. }
  34902. }
  34903. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34904. import { Nullable } from "babylonjs/types";
  34905. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34906. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34907. /**
  34908. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34910. */
  34911. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34912. /**
  34913. * Defines the camera the input is attached to.
  34914. */
  34915. camera: ArcRotateCamera;
  34916. /**
  34917. * Defines the list of key codes associated with the up action (increase alpha)
  34918. */
  34919. keysUp: number[];
  34920. /**
  34921. * Defines the list of key codes associated with the down action (decrease alpha)
  34922. */
  34923. keysDown: number[];
  34924. /**
  34925. * Defines the list of key codes associated with the left action (increase beta)
  34926. */
  34927. keysLeft: number[];
  34928. /**
  34929. * Defines the list of key codes associated with the right action (decrease beta)
  34930. */
  34931. keysRight: number[];
  34932. /**
  34933. * Defines the list of key codes associated with the reset action.
  34934. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34935. */
  34936. keysReset: number[];
  34937. /**
  34938. * Defines the panning sensibility of the inputs.
  34939. * (How fast is the camera paning)
  34940. */
  34941. panningSensibility: number;
  34942. /**
  34943. * Defines the zooming sensibility of the inputs.
  34944. * (How fast is the camera zooming)
  34945. */
  34946. zoomingSensibility: number;
  34947. /**
  34948. * Defines wether maintaining the alt key down switch the movement mode from
  34949. * orientation to zoom.
  34950. */
  34951. useAltToZoom: boolean;
  34952. /**
  34953. * Rotation speed of the camera
  34954. */
  34955. angularSpeed: number;
  34956. private _keys;
  34957. private _ctrlPressed;
  34958. private _altPressed;
  34959. private _onCanvasBlurObserver;
  34960. private _onKeyboardObserver;
  34961. private _engine;
  34962. private _scene;
  34963. /**
  34964. * Attach the input controls to a specific dom element to get the input from.
  34965. * @param element Defines the element the controls should be listened from
  34966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34967. */
  34968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34969. /**
  34970. * Detach the current controls from the specified dom element.
  34971. * @param element Defines the element to stop listening the inputs from
  34972. */
  34973. detachControl(element: Nullable<HTMLElement>): void;
  34974. /**
  34975. * Update the current camera state depending on the inputs that have been used this frame.
  34976. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34977. */
  34978. checkInputs(): void;
  34979. /**
  34980. * Gets the class name of the current intput.
  34981. * @returns the class name
  34982. */
  34983. getClassName(): string;
  34984. /**
  34985. * Get the friendly name associated with the input class.
  34986. * @returns the input friendly name
  34987. */
  34988. getSimpleName(): string;
  34989. }
  34990. }
  34991. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  34992. import { Nullable } from "babylonjs/types";
  34993. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34994. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34995. /**
  34996. * Manage the mouse wheel inputs to control an arc rotate camera.
  34997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34998. */
  34999. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35000. /**
  35001. * Defines the camera the input is attached to.
  35002. */
  35003. camera: ArcRotateCamera;
  35004. /**
  35005. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35006. */
  35007. wheelPrecision: number;
  35008. /**
  35009. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35010. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35011. */
  35012. wheelDeltaPercentage: number;
  35013. private _wheel;
  35014. private _observer;
  35015. /**
  35016. * Attach the input controls to a specific dom element to get the input from.
  35017. * @param element Defines the element the controls should be listened from
  35018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35019. */
  35020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35021. /**
  35022. * Detach the current controls from the specified dom element.
  35023. * @param element Defines the element to stop listening the inputs from
  35024. */
  35025. detachControl(element: Nullable<HTMLElement>): void;
  35026. /**
  35027. * Gets the class name of the current intput.
  35028. * @returns the class name
  35029. */
  35030. getClassName(): string;
  35031. /**
  35032. * Get the friendly name associated with the input class.
  35033. * @returns the input friendly name
  35034. */
  35035. getSimpleName(): string;
  35036. }
  35037. }
  35038. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35039. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35040. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35041. /**
  35042. * Default Inputs manager for the ArcRotateCamera.
  35043. * It groups all the default supported inputs for ease of use.
  35044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35045. */
  35046. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35047. /**
  35048. * Instantiates a new ArcRotateCameraInputsManager.
  35049. * @param camera Defines the camera the inputs belong to
  35050. */
  35051. constructor(camera: ArcRotateCamera);
  35052. /**
  35053. * Add mouse wheel input support to the input manager.
  35054. * @returns the current input manager
  35055. */
  35056. addMouseWheel(): ArcRotateCameraInputsManager;
  35057. /**
  35058. * Add pointers input support to the input manager.
  35059. * @returns the current input manager
  35060. */
  35061. addPointers(): ArcRotateCameraInputsManager;
  35062. /**
  35063. * Add keyboard input support to the input manager.
  35064. * @returns the current input manager
  35065. */
  35066. addKeyboard(): ArcRotateCameraInputsManager;
  35067. }
  35068. }
  35069. declare module "babylonjs/Cameras/arcRotateCamera" {
  35070. import { Observable } from "babylonjs/Misc/observable";
  35071. import { Nullable } from "babylonjs/types";
  35072. import { Scene } from "babylonjs/scene";
  35073. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35075. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35076. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35077. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35078. import { Camera } from "babylonjs/Cameras/camera";
  35079. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35080. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35081. import { Collider } from "babylonjs/Collisions/collider";
  35082. /**
  35083. * This represents an orbital type of camera.
  35084. *
  35085. * 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.
  35086. * 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.
  35087. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35088. */
  35089. export class ArcRotateCamera extends TargetCamera {
  35090. /**
  35091. * Defines the rotation angle of the camera along the longitudinal axis.
  35092. */
  35093. alpha: number;
  35094. /**
  35095. * Defines the rotation angle of the camera along the latitudinal axis.
  35096. */
  35097. beta: number;
  35098. /**
  35099. * Defines the radius of the camera from it s target point.
  35100. */
  35101. radius: number;
  35102. protected _target: Vector3;
  35103. protected _targetHost: Nullable<AbstractMesh>;
  35104. /**
  35105. * Defines the target point of the camera.
  35106. * The camera looks towards it form the radius distance.
  35107. */
  35108. target: Vector3;
  35109. /**
  35110. * Define the current local position of the camera in the scene
  35111. */
  35112. position: Vector3;
  35113. /**
  35114. * Current inertia value on the longitudinal axis.
  35115. * The bigger this number the longer it will take for the camera to stop.
  35116. */
  35117. inertialAlphaOffset: number;
  35118. /**
  35119. * Current inertia value on the latitudinal axis.
  35120. * The bigger this number the longer it will take for the camera to stop.
  35121. */
  35122. inertialBetaOffset: number;
  35123. /**
  35124. * Current inertia value on the radius axis.
  35125. * The bigger this number the longer it will take for the camera to stop.
  35126. */
  35127. inertialRadiusOffset: number;
  35128. /**
  35129. * Minimum allowed angle on the longitudinal axis.
  35130. * This can help limiting how the Camera is able to move in the scene.
  35131. */
  35132. lowerAlphaLimit: Nullable<number>;
  35133. /**
  35134. * Maximum allowed angle on the longitudinal axis.
  35135. * This can help limiting how the Camera is able to move in the scene.
  35136. */
  35137. upperAlphaLimit: Nullable<number>;
  35138. /**
  35139. * Minimum allowed angle on the latitudinal axis.
  35140. * This can help limiting how the Camera is able to move in the scene.
  35141. */
  35142. lowerBetaLimit: number;
  35143. /**
  35144. * Maximum allowed angle on the latitudinal axis.
  35145. * This can help limiting how the Camera is able to move in the scene.
  35146. */
  35147. upperBetaLimit: number;
  35148. /**
  35149. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35150. * This can help limiting how the Camera is able to move in the scene.
  35151. */
  35152. lowerRadiusLimit: Nullable<number>;
  35153. /**
  35154. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35155. * This can help limiting how the Camera is able to move in the scene.
  35156. */
  35157. upperRadiusLimit: Nullable<number>;
  35158. /**
  35159. * Defines the current inertia value used during panning of the camera along the X axis.
  35160. */
  35161. inertialPanningX: number;
  35162. /**
  35163. * Defines the current inertia value used during panning of the camera along the Y axis.
  35164. */
  35165. inertialPanningY: number;
  35166. /**
  35167. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35168. * Basically if your fingers moves away from more than this distance you will be considered
  35169. * in pinch mode.
  35170. */
  35171. pinchToPanMaxDistance: number;
  35172. /**
  35173. * Defines the maximum distance the camera can pan.
  35174. * This could help keeping the cammera always in your scene.
  35175. */
  35176. panningDistanceLimit: Nullable<number>;
  35177. /**
  35178. * Defines the target of the camera before paning.
  35179. */
  35180. panningOriginTarget: Vector3;
  35181. /**
  35182. * Defines the value of the inertia used during panning.
  35183. * 0 would mean stop inertia and one would mean no decelleration at all.
  35184. */
  35185. panningInertia: number;
  35186. /**
  35187. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35188. */
  35189. angularSensibilityX: number;
  35190. /**
  35191. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35192. */
  35193. angularSensibilityY: number;
  35194. /**
  35195. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35196. */
  35197. pinchPrecision: number;
  35198. /**
  35199. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35200. * It will be used instead of pinchDeltaPrecision if different from 0.
  35201. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35202. */
  35203. pinchDeltaPercentage: number;
  35204. /**
  35205. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35206. */
  35207. panningSensibility: number;
  35208. /**
  35209. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35210. */
  35211. keysUp: number[];
  35212. /**
  35213. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35214. */
  35215. keysDown: number[];
  35216. /**
  35217. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35218. */
  35219. keysLeft: number[];
  35220. /**
  35221. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35222. */
  35223. keysRight: number[];
  35224. /**
  35225. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35226. */
  35227. wheelPrecision: number;
  35228. /**
  35229. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35230. * It will be used instead of pinchDeltaPrecision if different from 0.
  35231. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35232. */
  35233. wheelDeltaPercentage: number;
  35234. /**
  35235. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35236. */
  35237. zoomOnFactor: number;
  35238. /**
  35239. * Defines a screen offset for the camera position.
  35240. */
  35241. targetScreenOffset: Vector2;
  35242. /**
  35243. * Allows the camera to be completely reversed.
  35244. * If false the camera can not arrive upside down.
  35245. */
  35246. allowUpsideDown: boolean;
  35247. /**
  35248. * Define if double tap/click is used to restore the previously saved state of the camera.
  35249. */
  35250. useInputToRestoreState: boolean;
  35251. /** @hidden */
  35252. _viewMatrix: Matrix;
  35253. /** @hidden */
  35254. _useCtrlForPanning: boolean;
  35255. /** @hidden */
  35256. _panningMouseButton: number;
  35257. /**
  35258. * Defines the input associated to the camera.
  35259. */
  35260. inputs: ArcRotateCameraInputsManager;
  35261. /** @hidden */
  35262. _reset: () => void;
  35263. /**
  35264. * Defines the allowed panning axis.
  35265. */
  35266. panningAxis: Vector3;
  35267. protected _localDirection: Vector3;
  35268. protected _transformedDirection: Vector3;
  35269. private _bouncingBehavior;
  35270. /**
  35271. * Gets the bouncing behavior of the camera if it has been enabled.
  35272. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35273. */
  35274. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35275. /**
  35276. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35277. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35278. */
  35279. useBouncingBehavior: boolean;
  35280. private _framingBehavior;
  35281. /**
  35282. * Gets the framing behavior of the camera if it has been enabled.
  35283. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35284. */
  35285. readonly framingBehavior: Nullable<FramingBehavior>;
  35286. /**
  35287. * Defines if the framing behavior of the camera is enabled on the camera.
  35288. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35289. */
  35290. useFramingBehavior: boolean;
  35291. private _autoRotationBehavior;
  35292. /**
  35293. * Gets the auto rotation behavior of the camera if it has been enabled.
  35294. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35295. */
  35296. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35297. /**
  35298. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35299. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35300. */
  35301. useAutoRotationBehavior: boolean;
  35302. /**
  35303. * Observable triggered when the mesh target has been changed on the camera.
  35304. */
  35305. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35306. /**
  35307. * Event raised when the camera is colliding with a mesh.
  35308. */
  35309. onCollide: (collidedMesh: AbstractMesh) => void;
  35310. /**
  35311. * Defines whether the camera should check collision with the objects oh the scene.
  35312. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35313. */
  35314. checkCollisions: boolean;
  35315. /**
  35316. * Defines the collision radius of the camera.
  35317. * This simulates a sphere around the camera.
  35318. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35319. */
  35320. collisionRadius: Vector3;
  35321. protected _collider: Collider;
  35322. protected _previousPosition: Vector3;
  35323. protected _collisionVelocity: Vector3;
  35324. protected _newPosition: Vector3;
  35325. protected _previousAlpha: number;
  35326. protected _previousBeta: number;
  35327. protected _previousRadius: number;
  35328. protected _collisionTriggered: boolean;
  35329. protected _targetBoundingCenter: Nullable<Vector3>;
  35330. private _computationVector;
  35331. private _tempAxisVector;
  35332. private _tempAxisRotationMatrix;
  35333. /**
  35334. * Instantiates a new ArcRotateCamera in a given scene
  35335. * @param name Defines the name of the camera
  35336. * @param alpha Defines the camera rotation along the logitudinal axis
  35337. * @param beta Defines the camera rotation along the latitudinal axis
  35338. * @param radius Defines the camera distance from its target
  35339. * @param target Defines the camera target
  35340. * @param scene Defines the scene the camera belongs to
  35341. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35342. */
  35343. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35344. /** @hidden */
  35345. _initCache(): void;
  35346. /** @hidden */
  35347. _updateCache(ignoreParentClass?: boolean): void;
  35348. protected _getTargetPosition(): Vector3;
  35349. private _storedAlpha;
  35350. private _storedBeta;
  35351. private _storedRadius;
  35352. private _storedTarget;
  35353. /**
  35354. * Stores the current state of the camera (alpha, beta, radius and target)
  35355. * @returns the camera itself
  35356. */
  35357. storeState(): Camera;
  35358. /**
  35359. * @hidden
  35360. * Restored camera state. You must call storeState() first
  35361. */
  35362. _restoreStateValues(): boolean;
  35363. /** @hidden */
  35364. _isSynchronizedViewMatrix(): boolean;
  35365. /**
  35366. * Attached controls to the current camera.
  35367. * @param element Defines the element the controls should be listened from
  35368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35369. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35370. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35371. */
  35372. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35373. /**
  35374. * Detach the current controls from the camera.
  35375. * The camera will stop reacting to inputs.
  35376. * @param element Defines the element to stop listening the inputs from
  35377. */
  35378. detachControl(element: HTMLElement): void;
  35379. /** @hidden */
  35380. _checkInputs(): void;
  35381. protected _checkLimits(): void;
  35382. /**
  35383. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35384. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35385. */
  35386. rebuildAnglesAndRadius(updateView?: boolean): void;
  35387. /**
  35388. * Use a position to define the current camera related information like aplha, beta and radius
  35389. * @param position Defines the position to set the camera at
  35390. */
  35391. setPosition(position: Vector3): void;
  35392. /**
  35393. * Defines the target the camera should look at.
  35394. * This will automatically adapt alpha beta and radius to fit within the new target.
  35395. * @param target Defines the new target as a Vector or a mesh
  35396. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35397. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35398. */
  35399. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35400. /** @hidden */
  35401. _getViewMatrix(): Matrix;
  35402. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35403. /**
  35404. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35405. * @param meshes Defines the mesh to zoom on
  35406. * @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)
  35407. */
  35408. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35409. /**
  35410. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35411. * The target will be changed but the radius
  35412. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35413. * @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)
  35414. */
  35415. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35416. min: Vector3;
  35417. max: Vector3;
  35418. distance: number;
  35419. }, doNotUpdateMaxZ?: boolean): void;
  35420. /**
  35421. * @override
  35422. * Override Camera.createRigCamera
  35423. */
  35424. createRigCamera(name: string, cameraIndex: number): Camera;
  35425. /**
  35426. * @hidden
  35427. * @override
  35428. * Override Camera._updateRigCameras
  35429. */
  35430. _updateRigCameras(): void;
  35431. /**
  35432. * Destroy the camera and release the current resources hold by it.
  35433. */
  35434. dispose(): void;
  35435. /**
  35436. * Gets the current object class name.
  35437. * @return the class name
  35438. */
  35439. getClassName(): string;
  35440. }
  35441. }
  35442. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35443. import { Behavior } from "babylonjs/Behaviors/behavior";
  35444. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35445. /**
  35446. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35447. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35448. */
  35449. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35450. /**
  35451. * Gets the name of the behavior.
  35452. */
  35453. readonly name: string;
  35454. private _zoomStopsAnimation;
  35455. private _idleRotationSpeed;
  35456. private _idleRotationWaitTime;
  35457. private _idleRotationSpinupTime;
  35458. /**
  35459. * Sets the flag that indicates if user zooming should stop animation.
  35460. */
  35461. /**
  35462. * Gets the flag that indicates if user zooming should stop animation.
  35463. */
  35464. zoomStopsAnimation: boolean;
  35465. /**
  35466. * Sets the default speed at which the camera rotates around the model.
  35467. */
  35468. /**
  35469. * Gets the default speed at which the camera rotates around the model.
  35470. */
  35471. idleRotationSpeed: number;
  35472. /**
  35473. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35474. */
  35475. /**
  35476. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35477. */
  35478. idleRotationWaitTime: number;
  35479. /**
  35480. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35481. */
  35482. /**
  35483. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35484. */
  35485. idleRotationSpinupTime: number;
  35486. /**
  35487. * Gets a value indicating if the camera is currently rotating because of this behavior
  35488. */
  35489. readonly rotationInProgress: boolean;
  35490. private _onPrePointerObservableObserver;
  35491. private _onAfterCheckInputsObserver;
  35492. private _attachedCamera;
  35493. private _isPointerDown;
  35494. private _lastFrameTime;
  35495. private _lastInteractionTime;
  35496. private _cameraRotationSpeed;
  35497. /**
  35498. * Initializes the behavior.
  35499. */
  35500. init(): void;
  35501. /**
  35502. * Attaches the behavior to its arc rotate camera.
  35503. * @param camera Defines the camera to attach the behavior to
  35504. */
  35505. attach(camera: ArcRotateCamera): void;
  35506. /**
  35507. * Detaches the behavior from its current arc rotate camera.
  35508. */
  35509. detach(): void;
  35510. /**
  35511. * Returns true if user is scrolling.
  35512. * @return true if user is scrolling.
  35513. */
  35514. private _userIsZooming;
  35515. private _lastFrameRadius;
  35516. private _shouldAnimationStopForInteraction;
  35517. /**
  35518. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35519. */
  35520. private _applyUserInteraction;
  35521. private _userIsMoving;
  35522. }
  35523. }
  35524. declare module "babylonjs/Behaviors/Cameras/index" {
  35525. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35526. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35527. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35528. }
  35529. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35530. import { Mesh } from "babylonjs/Meshes/mesh";
  35531. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35532. import { Behavior } from "babylonjs/Behaviors/behavior";
  35533. /**
  35534. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35535. */
  35536. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35537. private ui;
  35538. /**
  35539. * The name of the behavior
  35540. */
  35541. name: string;
  35542. /**
  35543. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35544. */
  35545. distanceAwayFromFace: number;
  35546. /**
  35547. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35548. */
  35549. distanceAwayFromBottomOfFace: number;
  35550. private _faceVectors;
  35551. private _target;
  35552. private _scene;
  35553. private _onRenderObserver;
  35554. private _tmpMatrix;
  35555. private _tmpVector;
  35556. /**
  35557. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35558. * @param ui The transform node that should be attched to the mesh
  35559. */
  35560. constructor(ui: TransformNode);
  35561. /**
  35562. * Initializes the behavior
  35563. */
  35564. init(): void;
  35565. private _closestFace;
  35566. private _zeroVector;
  35567. private _lookAtTmpMatrix;
  35568. private _lookAtToRef;
  35569. /**
  35570. * Attaches the AttachToBoxBehavior to the passed in mesh
  35571. * @param target The mesh that the specified node will be attached to
  35572. */
  35573. attach(target: Mesh): void;
  35574. /**
  35575. * Detaches the behavior from the mesh
  35576. */
  35577. detach(): void;
  35578. }
  35579. }
  35580. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35581. import { Behavior } from "babylonjs/Behaviors/behavior";
  35582. import { Mesh } from "babylonjs/Meshes/mesh";
  35583. /**
  35584. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35585. */
  35586. export class FadeInOutBehavior implements Behavior<Mesh> {
  35587. /**
  35588. * Time in milliseconds to delay before fading in (Default: 0)
  35589. */
  35590. delay: number;
  35591. /**
  35592. * Time in milliseconds for the mesh to fade in (Default: 300)
  35593. */
  35594. fadeInTime: number;
  35595. private _millisecondsPerFrame;
  35596. private _hovered;
  35597. private _hoverValue;
  35598. private _ownerNode;
  35599. /**
  35600. * Instatiates the FadeInOutBehavior
  35601. */
  35602. constructor();
  35603. /**
  35604. * The name of the behavior
  35605. */
  35606. readonly name: string;
  35607. /**
  35608. * Initializes the behavior
  35609. */
  35610. init(): void;
  35611. /**
  35612. * Attaches the fade behavior on the passed in mesh
  35613. * @param ownerNode The mesh that will be faded in/out once attached
  35614. */
  35615. attach(ownerNode: Mesh): void;
  35616. /**
  35617. * Detaches the behavior from the mesh
  35618. */
  35619. detach(): void;
  35620. /**
  35621. * Triggers the mesh to begin fading in or out
  35622. * @param value if the object should fade in or out (true to fade in)
  35623. */
  35624. fadeIn(value: boolean): void;
  35625. private _update;
  35626. private _setAllVisibility;
  35627. }
  35628. }
  35629. declare module "babylonjs/Misc/pivotTools" {
  35630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35631. /**
  35632. * Class containing a set of static utilities functions for managing Pivots
  35633. * @hidden
  35634. */
  35635. export class PivotTools {
  35636. private static _PivotCached;
  35637. private static _OldPivotPoint;
  35638. private static _PivotTranslation;
  35639. private static _PivotTmpVector;
  35640. /** @hidden */
  35641. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35642. /** @hidden */
  35643. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35644. }
  35645. }
  35646. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35647. import { Scene } from "babylonjs/scene";
  35648. import { Vector4, Plane } from "babylonjs/Maths/math";
  35649. import { Mesh } from "babylonjs/Meshes/mesh";
  35650. /**
  35651. * Class containing static functions to help procedurally build meshes
  35652. */
  35653. export class PlaneBuilder {
  35654. /**
  35655. * Creates a plane mesh
  35656. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35657. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35658. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35660. * * If you create a double-sided mesh, you can choose what parts of 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
  35661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35662. * @param name defines the name of the mesh
  35663. * @param options defines the options used to create the mesh
  35664. * @param scene defines the hosting scene
  35665. * @returns the plane mesh
  35666. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35667. */
  35668. static CreatePlane(name: string, options: {
  35669. size?: number;
  35670. width?: number;
  35671. height?: number;
  35672. sideOrientation?: number;
  35673. frontUVs?: Vector4;
  35674. backUVs?: Vector4;
  35675. updatable?: boolean;
  35676. sourcePlane?: Plane;
  35677. }, scene: Scene): Mesh;
  35678. }
  35679. }
  35680. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35681. import { Behavior } from "babylonjs/Behaviors/behavior";
  35682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35683. import { Observable } from "babylonjs/Misc/observable";
  35684. import { Vector3 } from "babylonjs/Maths/math";
  35685. import { Ray } from "babylonjs/Culling/ray";
  35686. import "babylonjs/Meshes/Builders/planeBuilder";
  35687. /**
  35688. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35689. */
  35690. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35691. private static _AnyMouseID;
  35692. private _attachedNode;
  35693. private _dragPlane;
  35694. private _scene;
  35695. private _pointerObserver;
  35696. private _beforeRenderObserver;
  35697. private static _planeScene;
  35698. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35699. /**
  35700. * 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)
  35701. */
  35702. maxDragAngle: number;
  35703. /**
  35704. * @hidden
  35705. */
  35706. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35707. /**
  35708. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35709. */
  35710. currentDraggingPointerID: number;
  35711. /**
  35712. * The last position where the pointer hit the drag plane in world space
  35713. */
  35714. lastDragPosition: Vector3;
  35715. /**
  35716. * If the behavior is currently in a dragging state
  35717. */
  35718. dragging: boolean;
  35719. /**
  35720. * 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)
  35721. */
  35722. dragDeltaRatio: number;
  35723. /**
  35724. * If the drag plane orientation should be updated during the dragging (Default: true)
  35725. */
  35726. updateDragPlane: boolean;
  35727. private _debugMode;
  35728. private _moving;
  35729. /**
  35730. * Fires each time the attached mesh is dragged with the pointer
  35731. * * delta between last drag position and current drag position in world space
  35732. * * dragDistance along the drag axis
  35733. * * dragPlaneNormal normal of the current drag plane used during the drag
  35734. * * dragPlanePoint in world space where the drag intersects the drag plane
  35735. */
  35736. onDragObservable: Observable<{
  35737. delta: Vector3;
  35738. dragPlanePoint: Vector3;
  35739. dragPlaneNormal: Vector3;
  35740. dragDistance: number;
  35741. pointerId: number;
  35742. }>;
  35743. /**
  35744. * Fires each time a drag begins (eg. mouse down on mesh)
  35745. */
  35746. onDragStartObservable: Observable<{
  35747. dragPlanePoint: Vector3;
  35748. pointerId: number;
  35749. }>;
  35750. /**
  35751. * Fires each time a drag ends (eg. mouse release after drag)
  35752. */
  35753. onDragEndObservable: Observable<{
  35754. dragPlanePoint: Vector3;
  35755. pointerId: number;
  35756. }>;
  35757. /**
  35758. * If the attached mesh should be moved when dragged
  35759. */
  35760. moveAttached: boolean;
  35761. /**
  35762. * If the drag behavior will react to drag events (Default: true)
  35763. */
  35764. enabled: boolean;
  35765. /**
  35766. * If camera controls should be detached during the drag
  35767. */
  35768. detachCameraControls: boolean;
  35769. /**
  35770. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35771. */
  35772. useObjectOrienationForDragging: boolean;
  35773. private _options;
  35774. /**
  35775. * Creates a pointer drag behavior that can be attached to a mesh
  35776. * @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)
  35777. */
  35778. constructor(options?: {
  35779. dragAxis?: Vector3;
  35780. dragPlaneNormal?: Vector3;
  35781. });
  35782. /**
  35783. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35784. */
  35785. validateDrag: (targetPosition: Vector3) => boolean;
  35786. /**
  35787. * The name of the behavior
  35788. */
  35789. readonly name: string;
  35790. /**
  35791. * Initializes the behavior
  35792. */
  35793. init(): void;
  35794. private _tmpVector;
  35795. private _alternatePickedPoint;
  35796. private _worldDragAxis;
  35797. private _targetPosition;
  35798. private _attachedElement;
  35799. /**
  35800. * Attaches the drag behavior the passed in mesh
  35801. * @param ownerNode The mesh that will be dragged around once attached
  35802. */
  35803. attach(ownerNode: AbstractMesh): void;
  35804. /**
  35805. * Force relase the drag action by code.
  35806. */
  35807. releaseDrag(): void;
  35808. private _startDragRay;
  35809. private _lastPointerRay;
  35810. /**
  35811. * Simulates the start of a pointer drag event on the behavior
  35812. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35813. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35814. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35815. */
  35816. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35817. private _startDrag;
  35818. private _dragDelta;
  35819. private _moveDrag;
  35820. private _pickWithRayOnDragPlane;
  35821. private _pointA;
  35822. private _pointB;
  35823. private _pointC;
  35824. private _lineA;
  35825. private _lineB;
  35826. private _localAxis;
  35827. private _lookAt;
  35828. private _updateDragPlanePosition;
  35829. /**
  35830. * Detaches the behavior from the mesh
  35831. */
  35832. detach(): void;
  35833. }
  35834. }
  35835. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35836. import { Mesh } from "babylonjs/Meshes/mesh";
  35837. import { Behavior } from "babylonjs/Behaviors/behavior";
  35838. /**
  35839. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35840. */
  35841. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35842. private _dragBehaviorA;
  35843. private _dragBehaviorB;
  35844. private _startDistance;
  35845. private _initialScale;
  35846. private _targetScale;
  35847. private _ownerNode;
  35848. private _sceneRenderObserver;
  35849. /**
  35850. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35851. */
  35852. constructor();
  35853. /**
  35854. * The name of the behavior
  35855. */
  35856. readonly name: string;
  35857. /**
  35858. * Initializes the behavior
  35859. */
  35860. init(): void;
  35861. private _getCurrentDistance;
  35862. /**
  35863. * Attaches the scale behavior the passed in mesh
  35864. * @param ownerNode The mesh that will be scaled around once attached
  35865. */
  35866. attach(ownerNode: Mesh): void;
  35867. /**
  35868. * Detaches the behavior from the mesh
  35869. */
  35870. detach(): void;
  35871. }
  35872. }
  35873. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35874. import { Behavior } from "babylonjs/Behaviors/behavior";
  35875. import { Mesh } from "babylonjs/Meshes/mesh";
  35876. import { Observable } from "babylonjs/Misc/observable";
  35877. /**
  35878. * 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
  35879. */
  35880. export class SixDofDragBehavior implements Behavior<Mesh> {
  35881. private static _virtualScene;
  35882. private _ownerNode;
  35883. private _sceneRenderObserver;
  35884. private _scene;
  35885. private _targetPosition;
  35886. private _virtualOriginMesh;
  35887. private _virtualDragMesh;
  35888. private _pointerObserver;
  35889. private _moving;
  35890. private _startingOrientation;
  35891. /**
  35892. * 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)
  35893. */
  35894. private zDragFactor;
  35895. /**
  35896. * If the object should rotate to face the drag origin
  35897. */
  35898. rotateDraggedObject: boolean;
  35899. /**
  35900. * If the behavior is currently in a dragging state
  35901. */
  35902. dragging: boolean;
  35903. /**
  35904. * 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)
  35905. */
  35906. dragDeltaRatio: number;
  35907. /**
  35908. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35909. */
  35910. currentDraggingPointerID: number;
  35911. /**
  35912. * If camera controls should be detached during the drag
  35913. */
  35914. detachCameraControls: boolean;
  35915. /**
  35916. * Fires each time a drag starts
  35917. */
  35918. onDragStartObservable: Observable<{}>;
  35919. /**
  35920. * Fires each time a drag ends (eg. mouse release after drag)
  35921. */
  35922. onDragEndObservable: Observable<{}>;
  35923. /**
  35924. * 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
  35925. */
  35926. constructor();
  35927. /**
  35928. * The name of the behavior
  35929. */
  35930. readonly name: string;
  35931. /**
  35932. * Initializes the behavior
  35933. */
  35934. init(): void;
  35935. /**
  35936. * Attaches the scale behavior the passed in mesh
  35937. * @param ownerNode The mesh that will be scaled around once attached
  35938. */
  35939. attach(ownerNode: Mesh): void;
  35940. /**
  35941. * Detaches the behavior from the mesh
  35942. */
  35943. detach(): void;
  35944. }
  35945. }
  35946. declare module "babylonjs/Behaviors/Meshes/index" {
  35947. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35948. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35949. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35950. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35951. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35952. }
  35953. declare module "babylonjs/Behaviors/index" {
  35954. export * from "babylonjs/Behaviors/behavior";
  35955. export * from "babylonjs/Behaviors/Cameras/index";
  35956. export * from "babylonjs/Behaviors/Meshes/index";
  35957. }
  35958. declare module "babylonjs/Bones/boneIKController" {
  35959. import { Bone } from "babylonjs/Bones/bone";
  35960. import { Vector3 } from "babylonjs/Maths/math";
  35961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35962. import { Nullable } from "babylonjs/types";
  35963. /**
  35964. * Class used to apply inverse kinematics to bones
  35965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35966. */
  35967. export class BoneIKController {
  35968. private static _tmpVecs;
  35969. private static _tmpQuat;
  35970. private static _tmpMats;
  35971. /**
  35972. * Gets or sets the target mesh
  35973. */
  35974. targetMesh: AbstractMesh;
  35975. /** Gets or sets the mesh used as pole */
  35976. poleTargetMesh: AbstractMesh;
  35977. /**
  35978. * Gets or sets the bone used as pole
  35979. */
  35980. poleTargetBone: Nullable<Bone>;
  35981. /**
  35982. * Gets or sets the target position
  35983. */
  35984. targetPosition: Vector3;
  35985. /**
  35986. * Gets or sets the pole target position
  35987. */
  35988. poleTargetPosition: Vector3;
  35989. /**
  35990. * Gets or sets the pole target local offset
  35991. */
  35992. poleTargetLocalOffset: Vector3;
  35993. /**
  35994. * Gets or sets the pole angle
  35995. */
  35996. poleAngle: number;
  35997. /**
  35998. * Gets or sets the mesh associated with the controller
  35999. */
  36000. mesh: AbstractMesh;
  36001. /**
  36002. * 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)
  36003. */
  36004. slerpAmount: number;
  36005. private _bone1Quat;
  36006. private _bone1Mat;
  36007. private _bone2Ang;
  36008. private _bone1;
  36009. private _bone2;
  36010. private _bone1Length;
  36011. private _bone2Length;
  36012. private _maxAngle;
  36013. private _maxReach;
  36014. private _rightHandedSystem;
  36015. private _bendAxis;
  36016. private _slerping;
  36017. private _adjustRoll;
  36018. /**
  36019. * Gets or sets maximum allowed angle
  36020. */
  36021. maxAngle: number;
  36022. /**
  36023. * Creates a new BoneIKController
  36024. * @param mesh defines the mesh to control
  36025. * @param bone defines the bone to control
  36026. * @param options defines options to set up the controller
  36027. */
  36028. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36029. targetMesh?: AbstractMesh;
  36030. poleTargetMesh?: AbstractMesh;
  36031. poleTargetBone?: Bone;
  36032. poleTargetLocalOffset?: Vector3;
  36033. poleAngle?: number;
  36034. bendAxis?: Vector3;
  36035. maxAngle?: number;
  36036. slerpAmount?: number;
  36037. });
  36038. private _setMaxAngle;
  36039. /**
  36040. * Force the controller to update the bones
  36041. */
  36042. update(): void;
  36043. }
  36044. }
  36045. declare module "babylonjs/Bones/boneLookController" {
  36046. import { Vector3, Space } from "babylonjs/Maths/math";
  36047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36048. import { Bone } from "babylonjs/Bones/bone";
  36049. /**
  36050. * Class used to make a bone look toward a point in space
  36051. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36052. */
  36053. export class BoneLookController {
  36054. private static _tmpVecs;
  36055. private static _tmpQuat;
  36056. private static _tmpMats;
  36057. /**
  36058. * The target Vector3 that the bone will look at
  36059. */
  36060. target: Vector3;
  36061. /**
  36062. * The mesh that the bone is attached to
  36063. */
  36064. mesh: AbstractMesh;
  36065. /**
  36066. * The bone that will be looking to the target
  36067. */
  36068. bone: Bone;
  36069. /**
  36070. * The up axis of the coordinate system that is used when the bone is rotated
  36071. */
  36072. upAxis: Vector3;
  36073. /**
  36074. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36075. */
  36076. upAxisSpace: Space;
  36077. /**
  36078. * Used to make an adjustment to the yaw of the bone
  36079. */
  36080. adjustYaw: number;
  36081. /**
  36082. * Used to make an adjustment to the pitch of the bone
  36083. */
  36084. adjustPitch: number;
  36085. /**
  36086. * Used to make an adjustment to the roll of the bone
  36087. */
  36088. adjustRoll: number;
  36089. /**
  36090. * 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)
  36091. */
  36092. slerpAmount: number;
  36093. private _minYaw;
  36094. private _maxYaw;
  36095. private _minPitch;
  36096. private _maxPitch;
  36097. private _minYawSin;
  36098. private _minYawCos;
  36099. private _maxYawSin;
  36100. private _maxYawCos;
  36101. private _midYawConstraint;
  36102. private _minPitchTan;
  36103. private _maxPitchTan;
  36104. private _boneQuat;
  36105. private _slerping;
  36106. private _transformYawPitch;
  36107. private _transformYawPitchInv;
  36108. private _firstFrameSkipped;
  36109. private _yawRange;
  36110. private _fowardAxis;
  36111. /**
  36112. * Gets or sets the minimum yaw angle that the bone can look to
  36113. */
  36114. minYaw: number;
  36115. /**
  36116. * Gets or sets the maximum yaw angle that the bone can look to
  36117. */
  36118. maxYaw: number;
  36119. /**
  36120. * Gets or sets the minimum pitch angle that the bone can look to
  36121. */
  36122. minPitch: number;
  36123. /**
  36124. * Gets or sets the maximum pitch angle that the bone can look to
  36125. */
  36126. maxPitch: number;
  36127. /**
  36128. * Create a BoneLookController
  36129. * @param mesh the mesh that the bone belongs to
  36130. * @param bone the bone that will be looking to the target
  36131. * @param target the target Vector3 to look at
  36132. * @param options optional settings:
  36133. * * maxYaw: the maximum angle the bone will yaw to
  36134. * * minYaw: the minimum angle the bone will yaw to
  36135. * * maxPitch: the maximum angle the bone will pitch to
  36136. * * minPitch: the minimum angle the bone will yaw to
  36137. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36138. * * upAxis: the up axis of the coordinate system
  36139. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36140. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36141. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36142. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36143. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36144. * * adjustRoll: used to make an adjustment to the roll of the bone
  36145. **/
  36146. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36147. maxYaw?: number;
  36148. minYaw?: number;
  36149. maxPitch?: number;
  36150. minPitch?: number;
  36151. slerpAmount?: number;
  36152. upAxis?: Vector3;
  36153. upAxisSpace?: Space;
  36154. yawAxis?: Vector3;
  36155. pitchAxis?: Vector3;
  36156. adjustYaw?: number;
  36157. adjustPitch?: number;
  36158. adjustRoll?: number;
  36159. });
  36160. /**
  36161. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36162. */
  36163. update(): void;
  36164. private _getAngleDiff;
  36165. private _getAngleBetween;
  36166. private _isAngleBetween;
  36167. }
  36168. }
  36169. declare module "babylonjs/Bones/index" {
  36170. export * from "babylonjs/Bones/bone";
  36171. export * from "babylonjs/Bones/boneIKController";
  36172. export * from "babylonjs/Bones/boneLookController";
  36173. export * from "babylonjs/Bones/skeleton";
  36174. }
  36175. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36176. import { Nullable } from "babylonjs/types";
  36177. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36178. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36179. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36180. /**
  36181. * Manage the gamepad inputs to control an arc rotate camera.
  36182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36183. */
  36184. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36185. /**
  36186. * Defines the camera the input is attached to.
  36187. */
  36188. camera: ArcRotateCamera;
  36189. /**
  36190. * Defines the gamepad the input is gathering event from.
  36191. */
  36192. gamepad: Nullable<Gamepad>;
  36193. /**
  36194. * Defines the gamepad rotation sensiblity.
  36195. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36196. */
  36197. gamepadRotationSensibility: number;
  36198. /**
  36199. * Defines the gamepad move sensiblity.
  36200. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36201. */
  36202. gamepadMoveSensibility: number;
  36203. private _onGamepadConnectedObserver;
  36204. private _onGamepadDisconnectedObserver;
  36205. /**
  36206. * Attach the input controls to a specific dom element to get the input from.
  36207. * @param element Defines the element the controls should be listened from
  36208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36209. */
  36210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36211. /**
  36212. * Detach the current controls from the specified dom element.
  36213. * @param element Defines the element to stop listening the inputs from
  36214. */
  36215. detachControl(element: Nullable<HTMLElement>): void;
  36216. /**
  36217. * Update the current camera state depending on the inputs that have been used this frame.
  36218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36219. */
  36220. checkInputs(): void;
  36221. /**
  36222. * Gets the class name of the current intput.
  36223. * @returns the class name
  36224. */
  36225. getClassName(): string;
  36226. /**
  36227. * Get the friendly name associated with the input class.
  36228. * @returns the input friendly name
  36229. */
  36230. getSimpleName(): string;
  36231. }
  36232. }
  36233. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36234. import { Nullable } from "babylonjs/types";
  36235. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36236. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36237. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36238. interface ArcRotateCameraInputsManager {
  36239. /**
  36240. * Add orientation input support to the input manager.
  36241. * @returns the current input manager
  36242. */
  36243. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36244. }
  36245. }
  36246. /**
  36247. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36248. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36249. */
  36250. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36251. /**
  36252. * Defines the camera the input is attached to.
  36253. */
  36254. camera: ArcRotateCamera;
  36255. /**
  36256. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36257. */
  36258. alphaCorrection: number;
  36259. /**
  36260. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36261. */
  36262. gammaCorrection: number;
  36263. private _alpha;
  36264. private _gamma;
  36265. private _dirty;
  36266. private _deviceOrientationHandler;
  36267. /**
  36268. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36269. */
  36270. constructor();
  36271. /**
  36272. * Attach the input controls to a specific dom element to get the input from.
  36273. * @param element Defines the element the controls should be listened from
  36274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36275. */
  36276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36277. /** @hidden */
  36278. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36279. /**
  36280. * Update the current camera state depending on the inputs that have been used this frame.
  36281. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36282. */
  36283. checkInputs(): void;
  36284. /**
  36285. * Detach the current controls from the specified dom element.
  36286. * @param element Defines the element to stop listening the inputs from
  36287. */
  36288. detachControl(element: Nullable<HTMLElement>): void;
  36289. /**
  36290. * Gets the class name of the current intput.
  36291. * @returns the class name
  36292. */
  36293. getClassName(): string;
  36294. /**
  36295. * Get the friendly name associated with the input class.
  36296. * @returns the input friendly name
  36297. */
  36298. getSimpleName(): string;
  36299. }
  36300. }
  36301. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36302. import { Nullable } from "babylonjs/types";
  36303. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36304. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36305. /**
  36306. * Listen to mouse events to control the camera.
  36307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36308. */
  36309. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36310. /**
  36311. * Defines the camera the input is attached to.
  36312. */
  36313. camera: FlyCamera;
  36314. /**
  36315. * Defines if touch is enabled. (Default is true.)
  36316. */
  36317. touchEnabled: boolean;
  36318. /**
  36319. * Defines the buttons associated with the input to handle camera rotation.
  36320. */
  36321. buttons: number[];
  36322. /**
  36323. * Assign buttons for Yaw control.
  36324. */
  36325. buttonsYaw: number[];
  36326. /**
  36327. * Assign buttons for Pitch control.
  36328. */
  36329. buttonsPitch: number[];
  36330. /**
  36331. * Assign buttons for Roll control.
  36332. */
  36333. buttonsRoll: number[];
  36334. /**
  36335. * Detect if any button is being pressed while mouse is moved.
  36336. * -1 = Mouse locked.
  36337. * 0 = Left button.
  36338. * 1 = Middle Button.
  36339. * 2 = Right Button.
  36340. */
  36341. activeButton: number;
  36342. /**
  36343. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36344. * Higher values reduce its sensitivity.
  36345. */
  36346. angularSensibility: number;
  36347. private _mousemoveCallback;
  36348. private _observer;
  36349. private _rollObserver;
  36350. private previousPosition;
  36351. private noPreventDefault;
  36352. private element;
  36353. /**
  36354. * Listen to mouse events to control the camera.
  36355. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36356. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36357. */
  36358. constructor(touchEnabled?: boolean);
  36359. /**
  36360. * Attach the mouse control to the HTML DOM element.
  36361. * @param element Defines the element that listens to the input events.
  36362. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36363. */
  36364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36365. /**
  36366. * Detach the current controls from the specified dom element.
  36367. * @param element Defines the element to stop listening the inputs from
  36368. */
  36369. detachControl(element: Nullable<HTMLElement>): void;
  36370. /**
  36371. * Gets the class name of the current input.
  36372. * @returns the class name.
  36373. */
  36374. getClassName(): string;
  36375. /**
  36376. * Get the friendly name associated with the input class.
  36377. * @returns the input's friendly name.
  36378. */
  36379. getSimpleName(): string;
  36380. private _pointerInput;
  36381. private _onMouseMove;
  36382. /**
  36383. * Rotate camera by mouse offset.
  36384. */
  36385. private rotateCamera;
  36386. }
  36387. }
  36388. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36389. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36390. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36391. /**
  36392. * Default Inputs manager for the FlyCamera.
  36393. * It groups all the default supported inputs for ease of use.
  36394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36395. */
  36396. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36397. /**
  36398. * Instantiates a new FlyCameraInputsManager.
  36399. * @param camera Defines the camera the inputs belong to.
  36400. */
  36401. constructor(camera: FlyCamera);
  36402. /**
  36403. * Add keyboard input support to the input manager.
  36404. * @returns the new FlyCameraKeyboardMoveInput().
  36405. */
  36406. addKeyboard(): FlyCameraInputsManager;
  36407. /**
  36408. * Add mouse input support to the input manager.
  36409. * @param touchEnabled Enable touch screen support.
  36410. * @returns the new FlyCameraMouseInput().
  36411. */
  36412. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36413. }
  36414. }
  36415. declare module "babylonjs/Cameras/flyCamera" {
  36416. import { Scene } from "babylonjs/scene";
  36417. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36419. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36420. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36421. /**
  36422. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36423. * such as in a 3D Space Shooter or a Flight Simulator.
  36424. */
  36425. export class FlyCamera extends TargetCamera {
  36426. /**
  36427. * Define the collision ellipsoid of the camera.
  36428. * This is helpful for simulating a camera body, like a player's body.
  36429. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36430. */
  36431. ellipsoid: Vector3;
  36432. /**
  36433. * Define an offset for the position of the ellipsoid around the camera.
  36434. * This can be helpful if the camera is attached away from the player's body center,
  36435. * such as at its head.
  36436. */
  36437. ellipsoidOffset: Vector3;
  36438. /**
  36439. * Enable or disable collisions of the camera with the rest of the scene objects.
  36440. */
  36441. checkCollisions: boolean;
  36442. /**
  36443. * Enable or disable gravity on the camera.
  36444. */
  36445. applyGravity: boolean;
  36446. /**
  36447. * Define the current direction the camera is moving to.
  36448. */
  36449. cameraDirection: Vector3;
  36450. /**
  36451. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36452. * This overrides and empties cameraRotation.
  36453. */
  36454. rotationQuaternion: Quaternion;
  36455. /**
  36456. * Track Roll to maintain the wanted Rolling when looking around.
  36457. */
  36458. _trackRoll: number;
  36459. /**
  36460. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36461. */
  36462. rollCorrect: number;
  36463. /**
  36464. * Mimic a banked turn, Rolling the camera when Yawing.
  36465. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36466. */
  36467. bankedTurn: boolean;
  36468. /**
  36469. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36470. */
  36471. bankedTurnLimit: number;
  36472. /**
  36473. * Value of 0 disables the banked Roll.
  36474. * Value of 1 is equal to the Yaw angle in radians.
  36475. */
  36476. bankedTurnMultiplier: number;
  36477. /**
  36478. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36479. */
  36480. inputs: FlyCameraInputsManager;
  36481. /**
  36482. * Gets the input sensibility for mouse input.
  36483. * Higher values reduce sensitivity.
  36484. */
  36485. /**
  36486. * Sets the input sensibility for a mouse input.
  36487. * Higher values reduce sensitivity.
  36488. */
  36489. angularSensibility: number;
  36490. /**
  36491. * Get the keys for camera movement forward.
  36492. */
  36493. /**
  36494. * Set the keys for camera movement forward.
  36495. */
  36496. keysForward: number[];
  36497. /**
  36498. * Get the keys for camera movement backward.
  36499. */
  36500. keysBackward: number[];
  36501. /**
  36502. * Get the keys for camera movement up.
  36503. */
  36504. /**
  36505. * Set the keys for camera movement up.
  36506. */
  36507. keysUp: number[];
  36508. /**
  36509. * Get the keys for camera movement down.
  36510. */
  36511. /**
  36512. * Set the keys for camera movement down.
  36513. */
  36514. keysDown: number[];
  36515. /**
  36516. * Get the keys for camera movement left.
  36517. */
  36518. /**
  36519. * Set the keys for camera movement left.
  36520. */
  36521. keysLeft: number[];
  36522. /**
  36523. * Set the keys for camera movement right.
  36524. */
  36525. /**
  36526. * Set the keys for camera movement right.
  36527. */
  36528. keysRight: number[];
  36529. /**
  36530. * Event raised when the camera collides with a mesh in the scene.
  36531. */
  36532. onCollide: (collidedMesh: AbstractMesh) => void;
  36533. private _collider;
  36534. private _needMoveForGravity;
  36535. private _oldPosition;
  36536. private _diffPosition;
  36537. private _newPosition;
  36538. /** @hidden */
  36539. _localDirection: Vector3;
  36540. /** @hidden */
  36541. _transformedDirection: Vector3;
  36542. /**
  36543. * Instantiates a FlyCamera.
  36544. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36545. * such as in a 3D Space Shooter or a Flight Simulator.
  36546. * @param name Define the name of the camera in the scene.
  36547. * @param position Define the starting position of the camera in the scene.
  36548. * @param scene Define the scene the camera belongs to.
  36549. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36550. */
  36551. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36552. /**
  36553. * Attach a control to the HTML DOM element.
  36554. * @param element Defines the element that listens to the input events.
  36555. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36556. */
  36557. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36558. /**
  36559. * Detach a control from the HTML DOM element.
  36560. * The camera will stop reacting to that input.
  36561. * @param element Defines the element that listens to the input events.
  36562. */
  36563. detachControl(element: HTMLElement): void;
  36564. private _collisionMask;
  36565. /**
  36566. * Get the mask that the camera ignores in collision events.
  36567. */
  36568. /**
  36569. * Set the mask that the camera ignores in collision events.
  36570. */
  36571. collisionMask: number;
  36572. /** @hidden */
  36573. _collideWithWorld(displacement: Vector3): void;
  36574. /** @hidden */
  36575. private _onCollisionPositionChange;
  36576. /** @hidden */
  36577. _checkInputs(): void;
  36578. /** @hidden */
  36579. _decideIfNeedsToMove(): boolean;
  36580. /** @hidden */
  36581. _updatePosition(): void;
  36582. /**
  36583. * Restore the Roll to its target value at the rate specified.
  36584. * @param rate - Higher means slower restoring.
  36585. * @hidden
  36586. */
  36587. restoreRoll(rate: number): void;
  36588. /**
  36589. * Destroy the camera and release the current resources held by it.
  36590. */
  36591. dispose(): void;
  36592. /**
  36593. * Get the current object class name.
  36594. * @returns the class name.
  36595. */
  36596. getClassName(): string;
  36597. }
  36598. }
  36599. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36600. import { Nullable } from "babylonjs/types";
  36601. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36602. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36603. /**
  36604. * Listen to keyboard events to control the camera.
  36605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36606. */
  36607. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36608. /**
  36609. * Defines the camera the input is attached to.
  36610. */
  36611. camera: FlyCamera;
  36612. /**
  36613. * The list of keyboard keys used to control the forward move of the camera.
  36614. */
  36615. keysForward: number[];
  36616. /**
  36617. * The list of keyboard keys used to control the backward move of the camera.
  36618. */
  36619. keysBackward: number[];
  36620. /**
  36621. * The list of keyboard keys used to control the forward move of the camera.
  36622. */
  36623. keysUp: number[];
  36624. /**
  36625. * The list of keyboard keys used to control the backward move of the camera.
  36626. */
  36627. keysDown: number[];
  36628. /**
  36629. * The list of keyboard keys used to control the right strafe move of the camera.
  36630. */
  36631. keysRight: number[];
  36632. /**
  36633. * The list of keyboard keys used to control the left strafe move of the camera.
  36634. */
  36635. keysLeft: number[];
  36636. private _keys;
  36637. private _onCanvasBlurObserver;
  36638. private _onKeyboardObserver;
  36639. private _engine;
  36640. private _scene;
  36641. /**
  36642. * Attach the input controls to a specific dom element to get the input from.
  36643. * @param element Defines the element the controls should be listened from
  36644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36645. */
  36646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36647. /**
  36648. * Detach the current controls from the specified dom element.
  36649. * @param element Defines the element to stop listening the inputs from
  36650. */
  36651. detachControl(element: Nullable<HTMLElement>): void;
  36652. /**
  36653. * Gets the class name of the current intput.
  36654. * @returns the class name
  36655. */
  36656. getClassName(): string;
  36657. /** @hidden */
  36658. _onLostFocus(e: FocusEvent): void;
  36659. /**
  36660. * Get the friendly name associated with the input class.
  36661. * @returns the input friendly name
  36662. */
  36663. getSimpleName(): string;
  36664. /**
  36665. * Update the current camera state depending on the inputs that have been used this frame.
  36666. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36667. */
  36668. checkInputs(): void;
  36669. }
  36670. }
  36671. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36672. import { Nullable } from "babylonjs/types";
  36673. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36674. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36675. /**
  36676. * Manage the mouse wheel inputs to control a follow camera.
  36677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36678. */
  36679. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36680. /**
  36681. * Defines the camera the input is attached to.
  36682. */
  36683. camera: FollowCamera;
  36684. /**
  36685. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36686. */
  36687. axisControlRadius: boolean;
  36688. /**
  36689. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36690. */
  36691. axisControlHeight: boolean;
  36692. /**
  36693. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36694. */
  36695. axisControlRotation: boolean;
  36696. /**
  36697. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36698. * relation to mouseWheel events.
  36699. */
  36700. wheelPrecision: number;
  36701. /**
  36702. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36703. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36704. */
  36705. wheelDeltaPercentage: number;
  36706. private _wheel;
  36707. private _observer;
  36708. /**
  36709. * Attach the input controls to a specific dom element to get the input from.
  36710. * @param element Defines the element the controls should be listened from
  36711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36712. */
  36713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36714. /**
  36715. * Detach the current controls from the specified dom element.
  36716. * @param element Defines the element to stop listening the inputs from
  36717. */
  36718. detachControl(element: Nullable<HTMLElement>): void;
  36719. /**
  36720. * Gets the class name of the current intput.
  36721. * @returns the class name
  36722. */
  36723. getClassName(): string;
  36724. /**
  36725. * Get the friendly name associated with the input class.
  36726. * @returns the input friendly name
  36727. */
  36728. getSimpleName(): string;
  36729. }
  36730. }
  36731. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36732. import { Nullable } from "babylonjs/types";
  36733. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36734. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36735. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36736. /**
  36737. * Manage the pointers inputs to control an follow camera.
  36738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36739. */
  36740. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36741. /**
  36742. * Defines the camera the input is attached to.
  36743. */
  36744. camera: FollowCamera;
  36745. /**
  36746. * Gets the class name of the current input.
  36747. * @returns the class name
  36748. */
  36749. getClassName(): string;
  36750. /**
  36751. * Defines the pointer angular sensibility along the X axis or how fast is
  36752. * the camera rotating.
  36753. * A negative number will reverse the axis direction.
  36754. */
  36755. angularSensibilityX: number;
  36756. /**
  36757. * Defines the pointer angular sensibility along the Y axis or how fast is
  36758. * the camera rotating.
  36759. * A negative number will reverse the axis direction.
  36760. */
  36761. angularSensibilityY: number;
  36762. /**
  36763. * Defines the pointer pinch precision or how fast is the camera zooming.
  36764. * A negative number will reverse the axis direction.
  36765. */
  36766. pinchPrecision: number;
  36767. /**
  36768. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36769. * from 0.
  36770. * It defines the percentage of current camera.radius to use as delta when
  36771. * pinch zoom is used.
  36772. */
  36773. pinchDeltaPercentage: number;
  36774. /**
  36775. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36776. */
  36777. axisXControlRadius: boolean;
  36778. /**
  36779. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36780. */
  36781. axisXControlHeight: boolean;
  36782. /**
  36783. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36784. */
  36785. axisXControlRotation: boolean;
  36786. /**
  36787. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36788. */
  36789. axisYControlRadius: boolean;
  36790. /**
  36791. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36792. */
  36793. axisYControlHeight: boolean;
  36794. /**
  36795. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36796. */
  36797. axisYControlRotation: boolean;
  36798. /**
  36799. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36800. */
  36801. axisPinchControlRadius: boolean;
  36802. /**
  36803. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36804. */
  36805. axisPinchControlHeight: boolean;
  36806. /**
  36807. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36808. */
  36809. axisPinchControlRotation: boolean;
  36810. /**
  36811. * Log error messages if basic misconfiguration has occurred.
  36812. */
  36813. warningEnable: boolean;
  36814. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36815. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36816. private _warningCounter;
  36817. private _warning;
  36818. }
  36819. }
  36820. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36821. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36822. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36823. /**
  36824. * Default Inputs manager for the FollowCamera.
  36825. * It groups all the default supported inputs for ease of use.
  36826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36827. */
  36828. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36829. /**
  36830. * Instantiates a new FollowCameraInputsManager.
  36831. * @param camera Defines the camera the inputs belong to
  36832. */
  36833. constructor(camera: FollowCamera);
  36834. /**
  36835. * Add keyboard input support to the input manager.
  36836. * @returns the current input manager
  36837. */
  36838. addKeyboard(): FollowCameraInputsManager;
  36839. /**
  36840. * Add mouse wheel input support to the input manager.
  36841. * @returns the current input manager
  36842. */
  36843. addMouseWheel(): FollowCameraInputsManager;
  36844. /**
  36845. * Add pointers input support to the input manager.
  36846. * @returns the current input manager
  36847. */
  36848. addPointers(): FollowCameraInputsManager;
  36849. /**
  36850. * Add orientation input support to the input manager.
  36851. * @returns the current input manager
  36852. */
  36853. addVRDeviceOrientation(): FollowCameraInputsManager;
  36854. }
  36855. }
  36856. declare module "babylonjs/Cameras/followCamera" {
  36857. import { Nullable } from "babylonjs/types";
  36858. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36859. import { Scene } from "babylonjs/scene";
  36860. import { Vector3 } from "babylonjs/Maths/math";
  36861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36862. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  36863. /**
  36864. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36865. * an arc rotate version arcFollowCamera are available.
  36866. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36867. */
  36868. export class FollowCamera extends TargetCamera {
  36869. /**
  36870. * Distance the follow camera should follow an object at
  36871. */
  36872. radius: number;
  36873. /**
  36874. * Minimum allowed distance of the camera to the axis of rotation
  36875. * (The camera can not get closer).
  36876. * This can help limiting how the Camera is able to move in the scene.
  36877. */
  36878. lowerRadiusLimit: Nullable<number>;
  36879. /**
  36880. * Maximum allowed distance of the camera to the axis of rotation
  36881. * (The camera can not get further).
  36882. * This can help limiting how the Camera is able to move in the scene.
  36883. */
  36884. upperRadiusLimit: Nullable<number>;
  36885. /**
  36886. * Define a rotation offset between the camera and the object it follows
  36887. */
  36888. rotationOffset: number;
  36889. /**
  36890. * Minimum allowed angle to camera position relative to target object.
  36891. * This can help limiting how the Camera is able to move in the scene.
  36892. */
  36893. lowerRotationOffsetLimit: Nullable<number>;
  36894. /**
  36895. * Maximum allowed angle to camera position relative to target object.
  36896. * This can help limiting how the Camera is able to move in the scene.
  36897. */
  36898. upperRotationOffsetLimit: Nullable<number>;
  36899. /**
  36900. * Define a height offset between the camera and the object it follows.
  36901. * It can help following an object from the top (like a car chaing a plane)
  36902. */
  36903. heightOffset: number;
  36904. /**
  36905. * Minimum allowed height of camera position relative to target object.
  36906. * This can help limiting how the Camera is able to move in the scene.
  36907. */
  36908. lowerHeightOffsetLimit: Nullable<number>;
  36909. /**
  36910. * Maximum allowed height of camera position relative to target object.
  36911. * This can help limiting how the Camera is able to move in the scene.
  36912. */
  36913. upperHeightOffsetLimit: Nullable<number>;
  36914. /**
  36915. * Define how fast the camera can accelerate to follow it s target.
  36916. */
  36917. cameraAcceleration: number;
  36918. /**
  36919. * Define the speed limit of the camera following an object.
  36920. */
  36921. maxCameraSpeed: number;
  36922. /**
  36923. * Define the target of the camera.
  36924. */
  36925. lockedTarget: Nullable<AbstractMesh>;
  36926. /**
  36927. * Defines the input associated with the camera.
  36928. */
  36929. inputs: FollowCameraInputsManager;
  36930. /**
  36931. * Instantiates the follow camera.
  36932. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36933. * @param name Define the name of the camera in the scene
  36934. * @param position Define the position of the camera
  36935. * @param scene Define the scene the camera belong to
  36936. * @param lockedTarget Define the target of the camera
  36937. */
  36938. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36939. private _follow;
  36940. /**
  36941. * Attached controls to the current camera.
  36942. * @param element Defines the element the controls should be listened from
  36943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36944. */
  36945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36946. /**
  36947. * Detach the current controls from the camera.
  36948. * The camera will stop reacting to inputs.
  36949. * @param element Defines the element to stop listening the inputs from
  36950. */
  36951. detachControl(element: HTMLElement): void;
  36952. /** @hidden */
  36953. _checkInputs(): void;
  36954. private _checkLimits;
  36955. /**
  36956. * Gets the camera class name.
  36957. * @returns the class name
  36958. */
  36959. getClassName(): string;
  36960. }
  36961. /**
  36962. * Arc Rotate version of the follow camera.
  36963. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36964. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36965. */
  36966. export class ArcFollowCamera extends TargetCamera {
  36967. /** The longitudinal angle of the camera */
  36968. alpha: number;
  36969. /** The latitudinal angle of the camera */
  36970. beta: number;
  36971. /** The radius of the camera from its target */
  36972. radius: number;
  36973. /** Define the camera target (the messh it should follow) */
  36974. target: Nullable<AbstractMesh>;
  36975. private _cartesianCoordinates;
  36976. /**
  36977. * Instantiates a new ArcFollowCamera
  36978. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36979. * @param name Define the name of the camera
  36980. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36981. * @param beta Define the rotation angle of the camera around the elevation axis
  36982. * @param radius Define the radius of the camera from its target point
  36983. * @param target Define the target of the camera
  36984. * @param scene Define the scene the camera belongs to
  36985. */
  36986. constructor(name: string,
  36987. /** The longitudinal angle of the camera */
  36988. alpha: number,
  36989. /** The latitudinal angle of the camera */
  36990. beta: number,
  36991. /** The radius of the camera from its target */
  36992. radius: number,
  36993. /** Define the camera target (the messh it should follow) */
  36994. target: Nullable<AbstractMesh>, scene: Scene);
  36995. private _follow;
  36996. /** @hidden */
  36997. _checkInputs(): void;
  36998. /**
  36999. * Returns the class name of the object.
  37000. * It is mostly used internally for serialization purposes.
  37001. */
  37002. getClassName(): string;
  37003. }
  37004. }
  37005. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37006. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37007. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37008. import { Nullable } from "babylonjs/types";
  37009. /**
  37010. * Manage the keyboard inputs to control the movement of a follow camera.
  37011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37012. */
  37013. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37014. /**
  37015. * Defines the camera the input is attached to.
  37016. */
  37017. camera: FollowCamera;
  37018. /**
  37019. * Defines the list of key codes associated with the up action (increase heightOffset)
  37020. */
  37021. keysHeightOffsetIncr: number[];
  37022. /**
  37023. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37024. */
  37025. keysHeightOffsetDecr: number[];
  37026. /**
  37027. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37028. */
  37029. keysHeightOffsetModifierAlt: boolean;
  37030. /**
  37031. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37032. */
  37033. keysHeightOffsetModifierCtrl: boolean;
  37034. /**
  37035. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37036. */
  37037. keysHeightOffsetModifierShift: boolean;
  37038. /**
  37039. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37040. */
  37041. keysRotationOffsetIncr: number[];
  37042. /**
  37043. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37044. */
  37045. keysRotationOffsetDecr: number[];
  37046. /**
  37047. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37048. */
  37049. keysRotationOffsetModifierAlt: boolean;
  37050. /**
  37051. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37052. */
  37053. keysRotationOffsetModifierCtrl: boolean;
  37054. /**
  37055. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37056. */
  37057. keysRotationOffsetModifierShift: boolean;
  37058. /**
  37059. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37060. */
  37061. keysRadiusIncr: number[];
  37062. /**
  37063. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37064. */
  37065. keysRadiusDecr: number[];
  37066. /**
  37067. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37068. */
  37069. keysRadiusModifierAlt: boolean;
  37070. /**
  37071. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37072. */
  37073. keysRadiusModifierCtrl: boolean;
  37074. /**
  37075. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37076. */
  37077. keysRadiusModifierShift: boolean;
  37078. /**
  37079. * Defines the rate of change of heightOffset.
  37080. */
  37081. heightSensibility: number;
  37082. /**
  37083. * Defines the rate of change of rotationOffset.
  37084. */
  37085. rotationSensibility: number;
  37086. /**
  37087. * Defines the rate of change of radius.
  37088. */
  37089. radiusSensibility: number;
  37090. private _keys;
  37091. private _ctrlPressed;
  37092. private _altPressed;
  37093. private _shiftPressed;
  37094. private _onCanvasBlurObserver;
  37095. private _onKeyboardObserver;
  37096. private _engine;
  37097. private _scene;
  37098. /**
  37099. * Attach the input controls to a specific dom element to get the input from.
  37100. * @param element Defines the element the controls should be listened from
  37101. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37102. */
  37103. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37104. /**
  37105. * Detach the current controls from the specified dom element.
  37106. * @param element Defines the element to stop listening the inputs from
  37107. */
  37108. detachControl(element: Nullable<HTMLElement>): void;
  37109. /**
  37110. * Update the current camera state depending on the inputs that have been used this frame.
  37111. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37112. */
  37113. checkInputs(): void;
  37114. /**
  37115. * Gets the class name of the current input.
  37116. * @returns the class name
  37117. */
  37118. getClassName(): string;
  37119. /**
  37120. * Get the friendly name associated with the input class.
  37121. * @returns the input friendly name
  37122. */
  37123. getSimpleName(): string;
  37124. /**
  37125. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37126. * allow modification of the heightOffset value.
  37127. */
  37128. private _modifierHeightOffset;
  37129. /**
  37130. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37131. * allow modification of the rotationOffset value.
  37132. */
  37133. private _modifierRotationOffset;
  37134. /**
  37135. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37136. * allow modification of the radius value.
  37137. */
  37138. private _modifierRadius;
  37139. }
  37140. }
  37141. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37142. import { Nullable } from "babylonjs/types";
  37143. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37144. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37145. module "babylonjs/Cameras/freeCameraInputsManager" {
  37146. interface FreeCameraInputsManager {
  37147. /**
  37148. * Add orientation input support to the input manager.
  37149. * @returns the current input manager
  37150. */
  37151. addDeviceOrientation(): FreeCameraInputsManager;
  37152. }
  37153. }
  37154. /**
  37155. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37156. * Screen rotation is taken into account.
  37157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37158. */
  37159. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37160. private _camera;
  37161. private _screenOrientationAngle;
  37162. private _constantTranform;
  37163. private _screenQuaternion;
  37164. private _alpha;
  37165. private _beta;
  37166. private _gamma;
  37167. /**
  37168. * Instantiates a new input
  37169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37170. */
  37171. constructor();
  37172. /**
  37173. * Define the camera controlled by the input.
  37174. */
  37175. camera: FreeCamera;
  37176. /**
  37177. * Attach the input controls to a specific dom element to get the input from.
  37178. * @param element Defines the element the controls should be listened from
  37179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37180. */
  37181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37182. private _orientationChanged;
  37183. private _deviceOrientation;
  37184. /**
  37185. * Detach the current controls from the specified dom element.
  37186. * @param element Defines the element to stop listening the inputs from
  37187. */
  37188. detachControl(element: Nullable<HTMLElement>): void;
  37189. /**
  37190. * Update the current camera state depending on the inputs that have been used this frame.
  37191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37192. */
  37193. checkInputs(): void;
  37194. /**
  37195. * Gets the class name of the current intput.
  37196. * @returns the class name
  37197. */
  37198. getClassName(): string;
  37199. /**
  37200. * Get the friendly name associated with the input class.
  37201. * @returns the input friendly name
  37202. */
  37203. getSimpleName(): string;
  37204. }
  37205. }
  37206. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37207. import { Nullable } from "babylonjs/types";
  37208. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37209. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37210. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37211. /**
  37212. * Manage the gamepad inputs to control a free camera.
  37213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37214. */
  37215. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37216. /**
  37217. * Define the camera the input is attached to.
  37218. */
  37219. camera: FreeCamera;
  37220. /**
  37221. * Define the Gamepad controlling the input
  37222. */
  37223. gamepad: Nullable<Gamepad>;
  37224. /**
  37225. * Defines the gamepad rotation sensiblity.
  37226. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37227. */
  37228. gamepadAngularSensibility: number;
  37229. /**
  37230. * Defines the gamepad move sensiblity.
  37231. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37232. */
  37233. gamepadMoveSensibility: number;
  37234. private _onGamepadConnectedObserver;
  37235. private _onGamepadDisconnectedObserver;
  37236. private _cameraTransform;
  37237. private _deltaTransform;
  37238. private _vector3;
  37239. private _vector2;
  37240. /**
  37241. * Attach the input controls to a specific dom element to get the input from.
  37242. * @param element Defines the element the controls should be listened from
  37243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37244. */
  37245. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37246. /**
  37247. * Detach the current controls from the specified dom element.
  37248. * @param element Defines the element to stop listening the inputs from
  37249. */
  37250. detachControl(element: Nullable<HTMLElement>): void;
  37251. /**
  37252. * Update the current camera state depending on the inputs that have been used this frame.
  37253. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37254. */
  37255. checkInputs(): void;
  37256. /**
  37257. * Gets the class name of the current intput.
  37258. * @returns the class name
  37259. */
  37260. getClassName(): string;
  37261. /**
  37262. * Get the friendly name associated with the input class.
  37263. * @returns the input friendly name
  37264. */
  37265. getSimpleName(): string;
  37266. }
  37267. }
  37268. declare module "babylonjs/Misc/virtualJoystick" {
  37269. import { Nullable } from "babylonjs/types";
  37270. import { Vector3 } from "babylonjs/Maths/math";
  37271. /**
  37272. * Defines the potential axis of a Joystick
  37273. */
  37274. export enum JoystickAxis {
  37275. /** X axis */
  37276. X = 0,
  37277. /** Y axis */
  37278. Y = 1,
  37279. /** Z axis */
  37280. Z = 2
  37281. }
  37282. /**
  37283. * Class used to define virtual joystick (used in touch mode)
  37284. */
  37285. export class VirtualJoystick {
  37286. /**
  37287. * Gets or sets a boolean indicating that left and right values must be inverted
  37288. */
  37289. reverseLeftRight: boolean;
  37290. /**
  37291. * Gets or sets a boolean indicating that up and down values must be inverted
  37292. */
  37293. reverseUpDown: boolean;
  37294. /**
  37295. * Gets the offset value for the position (ie. the change of the position value)
  37296. */
  37297. deltaPosition: Vector3;
  37298. /**
  37299. * Gets a boolean indicating if the virtual joystick was pressed
  37300. */
  37301. pressed: boolean;
  37302. /**
  37303. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37304. */
  37305. static Canvas: Nullable<HTMLCanvasElement>;
  37306. private static _globalJoystickIndex;
  37307. private static vjCanvasContext;
  37308. private static vjCanvasWidth;
  37309. private static vjCanvasHeight;
  37310. private static halfWidth;
  37311. private _action;
  37312. private _axisTargetedByLeftAndRight;
  37313. private _axisTargetedByUpAndDown;
  37314. private _joystickSensibility;
  37315. private _inversedSensibility;
  37316. private _joystickPointerID;
  37317. private _joystickColor;
  37318. private _joystickPointerPos;
  37319. private _joystickPreviousPointerPos;
  37320. private _joystickPointerStartPos;
  37321. private _deltaJoystickVector;
  37322. private _leftJoystick;
  37323. private _touches;
  37324. private _onPointerDownHandlerRef;
  37325. private _onPointerMoveHandlerRef;
  37326. private _onPointerUpHandlerRef;
  37327. private _onResize;
  37328. /**
  37329. * Creates a new virtual joystick
  37330. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37331. */
  37332. constructor(leftJoystick?: boolean);
  37333. /**
  37334. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37335. * @param newJoystickSensibility defines the new sensibility
  37336. */
  37337. setJoystickSensibility(newJoystickSensibility: number): void;
  37338. private _onPointerDown;
  37339. private _onPointerMove;
  37340. private _onPointerUp;
  37341. /**
  37342. * Change the color of the virtual joystick
  37343. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37344. */
  37345. setJoystickColor(newColor: string): void;
  37346. /**
  37347. * Defines a callback to call when the joystick is touched
  37348. * @param action defines the callback
  37349. */
  37350. setActionOnTouch(action: () => any): void;
  37351. /**
  37352. * Defines which axis you'd like to control for left & right
  37353. * @param axis defines the axis to use
  37354. */
  37355. setAxisForLeftRight(axis: JoystickAxis): void;
  37356. /**
  37357. * Defines which axis you'd like to control for up & down
  37358. * @param axis defines the axis to use
  37359. */
  37360. setAxisForUpDown(axis: JoystickAxis): void;
  37361. private _drawVirtualJoystick;
  37362. /**
  37363. * Release internal HTML canvas
  37364. */
  37365. releaseCanvas(): void;
  37366. }
  37367. }
  37368. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37369. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37370. import { Nullable } from "babylonjs/types";
  37371. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37372. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37373. module "babylonjs/Cameras/freeCameraInputsManager" {
  37374. interface FreeCameraInputsManager {
  37375. /**
  37376. * Add virtual joystick input support to the input manager.
  37377. * @returns the current input manager
  37378. */
  37379. addVirtualJoystick(): FreeCameraInputsManager;
  37380. }
  37381. }
  37382. /**
  37383. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37384. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37385. */
  37386. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37387. /**
  37388. * Defines the camera the input is attached to.
  37389. */
  37390. camera: FreeCamera;
  37391. private _leftjoystick;
  37392. private _rightjoystick;
  37393. /**
  37394. * Gets the left stick of the virtual joystick.
  37395. * @returns The virtual Joystick
  37396. */
  37397. getLeftJoystick(): VirtualJoystick;
  37398. /**
  37399. * Gets the right stick of the virtual joystick.
  37400. * @returns The virtual Joystick
  37401. */
  37402. getRightJoystick(): VirtualJoystick;
  37403. /**
  37404. * Update the current camera state depending on the inputs that have been used this frame.
  37405. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37406. */
  37407. checkInputs(): void;
  37408. /**
  37409. * Attach the input controls to a specific dom element to get the input from.
  37410. * @param element Defines the element the controls should be listened from
  37411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37412. */
  37413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37414. /**
  37415. * Detach the current controls from the specified dom element.
  37416. * @param element Defines the element to stop listening the inputs from
  37417. */
  37418. detachControl(element: Nullable<HTMLElement>): void;
  37419. /**
  37420. * Gets the class name of the current intput.
  37421. * @returns the class name
  37422. */
  37423. getClassName(): string;
  37424. /**
  37425. * Get the friendly name associated with the input class.
  37426. * @returns the input friendly name
  37427. */
  37428. getSimpleName(): string;
  37429. }
  37430. }
  37431. declare module "babylonjs/Cameras/Inputs/index" {
  37432. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37433. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37434. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37435. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37436. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37437. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37438. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37439. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37440. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37441. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37442. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37443. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37444. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37445. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37446. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37447. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37448. }
  37449. declare module "babylonjs/Cameras/touchCamera" {
  37450. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37451. import { Scene } from "babylonjs/scene";
  37452. import { Vector3 } from "babylonjs/Maths/math";
  37453. /**
  37454. * This represents a FPS type of camera controlled by touch.
  37455. * This is like a universal camera minus the Gamepad controls.
  37456. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37457. */
  37458. export class TouchCamera extends FreeCamera {
  37459. /**
  37460. * Defines the touch sensibility for rotation.
  37461. * The higher the faster.
  37462. */
  37463. touchAngularSensibility: number;
  37464. /**
  37465. * Defines the touch sensibility for move.
  37466. * The higher the faster.
  37467. */
  37468. touchMoveSensibility: number;
  37469. /**
  37470. * Instantiates a new touch camera.
  37471. * This represents a FPS type of camera controlled by touch.
  37472. * This is like a universal camera minus the Gamepad controls.
  37473. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37474. * @param name Define the name of the camera in the scene
  37475. * @param position Define the start position of the camera in the scene
  37476. * @param scene Define the scene the camera belongs to
  37477. */
  37478. constructor(name: string, position: Vector3, scene: Scene);
  37479. /**
  37480. * Gets the current object class name.
  37481. * @return the class name
  37482. */
  37483. getClassName(): string;
  37484. /** @hidden */
  37485. _setupInputs(): void;
  37486. }
  37487. }
  37488. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37489. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37490. import { Scene } from "babylonjs/scene";
  37491. import { Vector3, Axis } from "babylonjs/Maths/math";
  37492. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37493. /**
  37494. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37495. * being tilted forward or back and left or right.
  37496. */
  37497. export class DeviceOrientationCamera extends FreeCamera {
  37498. private _initialQuaternion;
  37499. private _quaternionCache;
  37500. /**
  37501. * Creates a new device orientation camera
  37502. * @param name The name of the camera
  37503. * @param position The start position camera
  37504. * @param scene The scene the camera belongs to
  37505. */
  37506. constructor(name: string, position: Vector3, scene: Scene);
  37507. /**
  37508. * Gets the current instance class name ("DeviceOrientationCamera").
  37509. * This helps avoiding instanceof at run time.
  37510. * @returns the class name
  37511. */
  37512. getClassName(): string;
  37513. /**
  37514. * @hidden
  37515. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37516. */
  37517. _checkInputs(): void;
  37518. /**
  37519. * Reset the camera to its default orientation on the specified axis only.
  37520. * @param axis The axis to reset
  37521. */
  37522. resetToCurrentRotation(axis?: Axis): void;
  37523. }
  37524. }
  37525. declare module "babylonjs/Cameras/universalCamera" {
  37526. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37527. import { Scene } from "babylonjs/scene";
  37528. import { Vector3 } from "babylonjs/Maths/math";
  37529. /**
  37530. * 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,
  37531. * which still works and will still be found in many Playgrounds.
  37532. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37533. */
  37534. export class UniversalCamera extends TouchCamera {
  37535. /**
  37536. * Defines the gamepad rotation sensiblity.
  37537. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37538. */
  37539. gamepadAngularSensibility: number;
  37540. /**
  37541. * Defines the gamepad move sensiblity.
  37542. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37543. */
  37544. gamepadMoveSensibility: number;
  37545. /**
  37546. * 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,
  37547. * which still works and will still be found in many Playgrounds.
  37548. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37549. * @param name Define the name of the camera in the scene
  37550. * @param position Define the start position of the camera in the scene
  37551. * @param scene Define the scene the camera belongs to
  37552. */
  37553. constructor(name: string, position: Vector3, scene: Scene);
  37554. /**
  37555. * Gets the current object class name.
  37556. * @return the class name
  37557. */
  37558. getClassName(): string;
  37559. }
  37560. }
  37561. declare module "babylonjs/Cameras/gamepadCamera" {
  37562. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37563. import { Scene } from "babylonjs/scene";
  37564. import { Vector3 } from "babylonjs/Maths/math";
  37565. /**
  37566. * This represents a FPS type of camera. This is only here for back compat purpose.
  37567. * Please use the UniversalCamera instead as both are identical.
  37568. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37569. */
  37570. export class GamepadCamera extends UniversalCamera {
  37571. /**
  37572. * Instantiates a new Gamepad Camera
  37573. * This represents a FPS type of camera. This is only here for back compat purpose.
  37574. * Please use the UniversalCamera instead as both are identical.
  37575. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37576. * @param name Define the name of the camera in the scene
  37577. * @param position Define the start position of the camera in the scene
  37578. * @param scene Define the scene the camera belongs to
  37579. */
  37580. constructor(name: string, position: Vector3, scene: Scene);
  37581. /**
  37582. * Gets the current object class name.
  37583. * @return the class name
  37584. */
  37585. getClassName(): string;
  37586. }
  37587. }
  37588. declare module "babylonjs/Shaders/pass.fragment" {
  37589. /** @hidden */
  37590. export var passPixelShader: {
  37591. name: string;
  37592. shader: string;
  37593. };
  37594. }
  37595. declare module "babylonjs/Shaders/passCube.fragment" {
  37596. /** @hidden */
  37597. export var passCubePixelShader: {
  37598. name: string;
  37599. shader: string;
  37600. };
  37601. }
  37602. declare module "babylonjs/PostProcesses/passPostProcess" {
  37603. import { Nullable } from "babylonjs/types";
  37604. import { Camera } from "babylonjs/Cameras/camera";
  37605. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37606. import { Engine } from "babylonjs/Engines/engine";
  37607. import "babylonjs/Shaders/pass.fragment";
  37608. import "babylonjs/Shaders/passCube.fragment";
  37609. /**
  37610. * PassPostProcess which produces an output the same as it's input
  37611. */
  37612. export class PassPostProcess extends PostProcess {
  37613. /**
  37614. * Creates the PassPostProcess
  37615. * @param name The name of the effect.
  37616. * @param options The required width/height ratio to downsize to before computing the render pass.
  37617. * @param camera The camera to apply the render pass to.
  37618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37619. * @param engine The engine which the post process will be applied. (default: current engine)
  37620. * @param reusable If the post process can be reused on the same frame. (default: false)
  37621. * @param textureType The type of texture to be used when performing the post processing.
  37622. * @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)
  37623. */
  37624. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37625. }
  37626. /**
  37627. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37628. */
  37629. export class PassCubePostProcess extends PostProcess {
  37630. private _face;
  37631. /**
  37632. * Gets or sets the cube face to display.
  37633. * * 0 is +X
  37634. * * 1 is -X
  37635. * * 2 is +Y
  37636. * * 3 is -Y
  37637. * * 4 is +Z
  37638. * * 5 is -Z
  37639. */
  37640. face: number;
  37641. /**
  37642. * Creates the PassCubePostProcess
  37643. * @param name The name of the effect.
  37644. * @param options The required width/height ratio to downsize to before computing the render pass.
  37645. * @param camera The camera to apply the render pass to.
  37646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37647. * @param engine The engine which the post process will be applied. (default: current engine)
  37648. * @param reusable If the post process can be reused on the same frame. (default: false)
  37649. * @param textureType The type of texture to be used when performing the post processing.
  37650. * @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)
  37651. */
  37652. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37653. }
  37654. }
  37655. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37656. /** @hidden */
  37657. export var anaglyphPixelShader: {
  37658. name: string;
  37659. shader: string;
  37660. };
  37661. }
  37662. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37663. import { Engine } from "babylonjs/Engines/engine";
  37664. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37665. import { Camera } from "babylonjs/Cameras/camera";
  37666. import "babylonjs/Shaders/anaglyph.fragment";
  37667. /**
  37668. * Postprocess used to generate anaglyphic rendering
  37669. */
  37670. export class AnaglyphPostProcess extends PostProcess {
  37671. private _passedProcess;
  37672. /**
  37673. * Creates a new AnaglyphPostProcess
  37674. * @param name defines postprocess name
  37675. * @param options defines creation options or target ratio scale
  37676. * @param rigCameras defines cameras using this postprocess
  37677. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37678. * @param engine defines hosting engine
  37679. * @param reusable defines if the postprocess will be reused multiple times per frame
  37680. */
  37681. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37682. }
  37683. }
  37684. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37685. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37686. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37687. import { Scene } from "babylonjs/scene";
  37688. import { Vector3 } from "babylonjs/Maths/math";
  37689. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37690. /**
  37691. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37692. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37693. */
  37694. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37695. /**
  37696. * Creates a new AnaglyphArcRotateCamera
  37697. * @param name defines camera name
  37698. * @param alpha defines alpha angle (in radians)
  37699. * @param beta defines beta angle (in radians)
  37700. * @param radius defines radius
  37701. * @param target defines camera target
  37702. * @param interaxialDistance defines distance between each color axis
  37703. * @param scene defines the hosting scene
  37704. */
  37705. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37706. /**
  37707. * Gets camera class name
  37708. * @returns AnaglyphArcRotateCamera
  37709. */
  37710. getClassName(): string;
  37711. }
  37712. }
  37713. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37714. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37715. import { Scene } from "babylonjs/scene";
  37716. import { Vector3 } from "babylonjs/Maths/math";
  37717. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37718. /**
  37719. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37720. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37721. */
  37722. export class AnaglyphFreeCamera extends FreeCamera {
  37723. /**
  37724. * Creates a new AnaglyphFreeCamera
  37725. * @param name defines camera name
  37726. * @param position defines initial position
  37727. * @param interaxialDistance defines distance between each color axis
  37728. * @param scene defines the hosting scene
  37729. */
  37730. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37731. /**
  37732. * Gets camera class name
  37733. * @returns AnaglyphFreeCamera
  37734. */
  37735. getClassName(): string;
  37736. }
  37737. }
  37738. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37739. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37740. import { Scene } from "babylonjs/scene";
  37741. import { Vector3 } from "babylonjs/Maths/math";
  37742. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37743. /**
  37744. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37745. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37746. */
  37747. export class AnaglyphGamepadCamera extends GamepadCamera {
  37748. /**
  37749. * Creates a new AnaglyphGamepadCamera
  37750. * @param name defines camera name
  37751. * @param position defines initial position
  37752. * @param interaxialDistance defines distance between each color axis
  37753. * @param scene defines the hosting scene
  37754. */
  37755. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37756. /**
  37757. * Gets camera class name
  37758. * @returns AnaglyphGamepadCamera
  37759. */
  37760. getClassName(): string;
  37761. }
  37762. }
  37763. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37764. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37765. import { Scene } from "babylonjs/scene";
  37766. import { Vector3 } from "babylonjs/Maths/math";
  37767. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37768. /**
  37769. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37770. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37771. */
  37772. export class AnaglyphUniversalCamera extends UniversalCamera {
  37773. /**
  37774. * Creates a new AnaglyphUniversalCamera
  37775. * @param name defines camera name
  37776. * @param position defines initial position
  37777. * @param interaxialDistance defines distance between each color axis
  37778. * @param scene defines the hosting scene
  37779. */
  37780. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37781. /**
  37782. * Gets camera class name
  37783. * @returns AnaglyphUniversalCamera
  37784. */
  37785. getClassName(): string;
  37786. }
  37787. }
  37788. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37789. /** @hidden */
  37790. export var stereoscopicInterlacePixelShader: {
  37791. name: string;
  37792. shader: string;
  37793. };
  37794. }
  37795. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37796. import { Camera } from "babylonjs/Cameras/camera";
  37797. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37798. import { Engine } from "babylonjs/Engines/engine";
  37799. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37800. /**
  37801. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37802. */
  37803. export class StereoscopicInterlacePostProcess extends PostProcess {
  37804. private _stepSize;
  37805. private _passedProcess;
  37806. /**
  37807. * Initializes a StereoscopicInterlacePostProcess
  37808. * @param name The name of the effect.
  37809. * @param rigCameras The rig cameras to be appled to the post process
  37810. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37812. * @param engine The engine which the post process will be applied. (default: current engine)
  37813. * @param reusable If the post process can be reused on the same frame. (default: false)
  37814. */
  37815. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37816. }
  37817. }
  37818. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37819. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37820. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37821. import { Scene } from "babylonjs/scene";
  37822. import { Vector3 } from "babylonjs/Maths/math";
  37823. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37824. /**
  37825. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37826. * @see http://doc.babylonjs.com/features/cameras
  37827. */
  37828. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37829. /**
  37830. * Creates a new StereoscopicArcRotateCamera
  37831. * @param name defines camera name
  37832. * @param alpha defines alpha angle (in radians)
  37833. * @param beta defines beta angle (in radians)
  37834. * @param radius defines radius
  37835. * @param target defines camera target
  37836. * @param interaxialDistance defines distance between each color axis
  37837. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37838. * @param scene defines the hosting scene
  37839. */
  37840. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37841. /**
  37842. * Gets camera class name
  37843. * @returns StereoscopicArcRotateCamera
  37844. */
  37845. getClassName(): string;
  37846. }
  37847. }
  37848. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37849. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37850. import { Scene } from "babylonjs/scene";
  37851. import { Vector3 } from "babylonjs/Maths/math";
  37852. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37853. /**
  37854. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37855. * @see http://doc.babylonjs.com/features/cameras
  37856. */
  37857. export class StereoscopicFreeCamera extends FreeCamera {
  37858. /**
  37859. * Creates a new StereoscopicFreeCamera
  37860. * @param name defines camera name
  37861. * @param position defines initial position
  37862. * @param interaxialDistance defines distance between each color axis
  37863. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37864. * @param scene defines the hosting scene
  37865. */
  37866. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37867. /**
  37868. * Gets camera class name
  37869. * @returns StereoscopicFreeCamera
  37870. */
  37871. getClassName(): string;
  37872. }
  37873. }
  37874. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37875. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37876. import { Scene } from "babylonjs/scene";
  37877. import { Vector3 } from "babylonjs/Maths/math";
  37878. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37879. /**
  37880. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37881. * @see http://doc.babylonjs.com/features/cameras
  37882. */
  37883. export class StereoscopicGamepadCamera extends GamepadCamera {
  37884. /**
  37885. * Creates a new StereoscopicGamepadCamera
  37886. * @param name defines camera name
  37887. * @param position defines initial position
  37888. * @param interaxialDistance defines distance between each color axis
  37889. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37890. * @param scene defines the hosting scene
  37891. */
  37892. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37893. /**
  37894. * Gets camera class name
  37895. * @returns StereoscopicGamepadCamera
  37896. */
  37897. getClassName(): string;
  37898. }
  37899. }
  37900. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37901. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37902. import { Scene } from "babylonjs/scene";
  37903. import { Vector3 } from "babylonjs/Maths/math";
  37904. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37905. /**
  37906. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37907. * @see http://doc.babylonjs.com/features/cameras
  37908. */
  37909. export class StereoscopicUniversalCamera extends UniversalCamera {
  37910. /**
  37911. * Creates a new StereoscopicUniversalCamera
  37912. * @param name defines camera name
  37913. * @param position defines initial position
  37914. * @param interaxialDistance defines distance between each color axis
  37915. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37916. * @param scene defines the hosting scene
  37917. */
  37918. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37919. /**
  37920. * Gets camera class name
  37921. * @returns StereoscopicUniversalCamera
  37922. */
  37923. getClassName(): string;
  37924. }
  37925. }
  37926. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37927. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37928. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37929. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37930. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37931. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37932. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37933. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37934. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37935. }
  37936. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37937. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37938. import { Scene } from "babylonjs/scene";
  37939. import { Vector3 } from "babylonjs/Maths/math";
  37940. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37941. /**
  37942. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37943. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37944. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37945. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37946. */
  37947. export class VirtualJoysticksCamera extends FreeCamera {
  37948. /**
  37949. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37950. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37951. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37952. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37953. * @param name Define the name of the camera in the scene
  37954. * @param position Define the start position of the camera in the scene
  37955. * @param scene Define the scene the camera belongs to
  37956. */
  37957. constructor(name: string, position: Vector3, scene: Scene);
  37958. /**
  37959. * Gets the current object class name.
  37960. * @return the class name
  37961. */
  37962. getClassName(): string;
  37963. }
  37964. }
  37965. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37966. import { Matrix } from "babylonjs/Maths/math";
  37967. /**
  37968. * This represents all the required metrics to create a VR camera.
  37969. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37970. */
  37971. export class VRCameraMetrics {
  37972. /**
  37973. * Define the horizontal resolution off the screen.
  37974. */
  37975. hResolution: number;
  37976. /**
  37977. * Define the vertical resolution off the screen.
  37978. */
  37979. vResolution: number;
  37980. /**
  37981. * Define the horizontal screen size.
  37982. */
  37983. hScreenSize: number;
  37984. /**
  37985. * Define the vertical screen size.
  37986. */
  37987. vScreenSize: number;
  37988. /**
  37989. * Define the vertical screen center position.
  37990. */
  37991. vScreenCenter: number;
  37992. /**
  37993. * Define the distance of the eyes to the screen.
  37994. */
  37995. eyeToScreenDistance: number;
  37996. /**
  37997. * Define the distance between both lenses
  37998. */
  37999. lensSeparationDistance: number;
  38000. /**
  38001. * Define the distance between both viewer's eyes.
  38002. */
  38003. interpupillaryDistance: number;
  38004. /**
  38005. * Define the distortion factor of the VR postprocess.
  38006. * Please, touch with care.
  38007. */
  38008. distortionK: number[];
  38009. /**
  38010. * Define the chromatic aberration correction factors for the VR post process.
  38011. */
  38012. chromaAbCorrection: number[];
  38013. /**
  38014. * Define the scale factor of the post process.
  38015. * The smaller the better but the slower.
  38016. */
  38017. postProcessScaleFactor: number;
  38018. /**
  38019. * Define an offset for the lens center.
  38020. */
  38021. lensCenterOffset: number;
  38022. /**
  38023. * Define if the current vr camera should compensate the distortion of the lense or not.
  38024. */
  38025. compensateDistortion: boolean;
  38026. /**
  38027. * Gets the rendering aspect ratio based on the provided resolutions.
  38028. */
  38029. readonly aspectRatio: number;
  38030. /**
  38031. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38032. */
  38033. readonly aspectRatioFov: number;
  38034. /**
  38035. * @hidden
  38036. */
  38037. readonly leftHMatrix: Matrix;
  38038. /**
  38039. * @hidden
  38040. */
  38041. readonly rightHMatrix: Matrix;
  38042. /**
  38043. * @hidden
  38044. */
  38045. readonly leftPreViewMatrix: Matrix;
  38046. /**
  38047. * @hidden
  38048. */
  38049. readonly rightPreViewMatrix: Matrix;
  38050. /**
  38051. * Get the default VRMetrics based on the most generic setup.
  38052. * @returns the default vr metrics
  38053. */
  38054. static GetDefault(): VRCameraMetrics;
  38055. }
  38056. }
  38057. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38058. /** @hidden */
  38059. export var vrDistortionCorrectionPixelShader: {
  38060. name: string;
  38061. shader: string;
  38062. };
  38063. }
  38064. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38065. import { Camera } from "babylonjs/Cameras/camera";
  38066. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38067. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38068. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38069. /**
  38070. * VRDistortionCorrectionPostProcess used for mobile VR
  38071. */
  38072. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38073. private _isRightEye;
  38074. private _distortionFactors;
  38075. private _postProcessScaleFactor;
  38076. private _lensCenterOffset;
  38077. private _scaleIn;
  38078. private _scaleFactor;
  38079. private _lensCenter;
  38080. /**
  38081. * Initializes the VRDistortionCorrectionPostProcess
  38082. * @param name The name of the effect.
  38083. * @param camera The camera to apply the render pass to.
  38084. * @param isRightEye If this is for the right eye distortion
  38085. * @param vrMetrics All the required metrics for the VR camera
  38086. */
  38087. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38088. }
  38089. }
  38090. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38091. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38092. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38093. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38094. import { Scene } from "babylonjs/scene";
  38095. import { Vector3 } from "babylonjs/Maths/math";
  38096. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38097. import "babylonjs/Cameras/RigModes/vrRigMode";
  38098. /**
  38099. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38100. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38101. */
  38102. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38103. /**
  38104. * Creates a new VRDeviceOrientationArcRotateCamera
  38105. * @param name defines camera name
  38106. * @param alpha defines the camera rotation along the logitudinal axis
  38107. * @param beta defines the camera rotation along the latitudinal axis
  38108. * @param radius defines the camera distance from its target
  38109. * @param target defines the camera target
  38110. * @param scene defines the scene the camera belongs to
  38111. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38112. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38113. */
  38114. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38115. /**
  38116. * Gets camera class name
  38117. * @returns VRDeviceOrientationArcRotateCamera
  38118. */
  38119. getClassName(): string;
  38120. }
  38121. }
  38122. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38123. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38124. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38125. import { Scene } from "babylonjs/scene";
  38126. import { Vector3 } from "babylonjs/Maths/math";
  38127. import "babylonjs/Cameras/RigModes/vrRigMode";
  38128. /**
  38129. * Camera used to simulate VR rendering (based on FreeCamera)
  38130. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38131. */
  38132. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38133. /**
  38134. * Creates a new VRDeviceOrientationFreeCamera
  38135. * @param name defines camera name
  38136. * @param position defines the start position of the camera
  38137. * @param scene defines the scene the camera belongs to
  38138. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38139. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38140. */
  38141. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38142. /**
  38143. * Gets camera class name
  38144. * @returns VRDeviceOrientationFreeCamera
  38145. */
  38146. getClassName(): string;
  38147. }
  38148. }
  38149. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38150. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38151. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38152. import { Scene } from "babylonjs/scene";
  38153. import { Vector3 } from "babylonjs/Maths/math";
  38154. /**
  38155. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38156. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38157. */
  38158. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38159. /**
  38160. * Creates a new VRDeviceOrientationGamepadCamera
  38161. * @param name defines camera name
  38162. * @param position defines the start position of the camera
  38163. * @param scene defines the scene the camera belongs to
  38164. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38165. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38166. */
  38167. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38168. /**
  38169. * Gets camera class name
  38170. * @returns VRDeviceOrientationGamepadCamera
  38171. */
  38172. getClassName(): string;
  38173. }
  38174. }
  38175. declare module "babylonjs/Gamepads/xboxGamepad" {
  38176. import { Observable } from "babylonjs/Misc/observable";
  38177. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38178. /**
  38179. * Defines supported buttons for XBox360 compatible gamepads
  38180. */
  38181. export enum Xbox360Button {
  38182. /** A */
  38183. A = 0,
  38184. /** B */
  38185. B = 1,
  38186. /** X */
  38187. X = 2,
  38188. /** Y */
  38189. Y = 3,
  38190. /** Start */
  38191. Start = 4,
  38192. /** Back */
  38193. Back = 5,
  38194. /** Left button */
  38195. LB = 6,
  38196. /** Right button */
  38197. RB = 7,
  38198. /** Left stick */
  38199. LeftStick = 8,
  38200. /** Right stick */
  38201. RightStick = 9
  38202. }
  38203. /** Defines values for XBox360 DPad */
  38204. export enum Xbox360Dpad {
  38205. /** Up */
  38206. Up = 0,
  38207. /** Down */
  38208. Down = 1,
  38209. /** Left */
  38210. Left = 2,
  38211. /** Right */
  38212. Right = 3
  38213. }
  38214. /**
  38215. * Defines a XBox360 gamepad
  38216. */
  38217. export class Xbox360Pad extends Gamepad {
  38218. private _leftTrigger;
  38219. private _rightTrigger;
  38220. private _onlefttriggerchanged;
  38221. private _onrighttriggerchanged;
  38222. private _onbuttondown;
  38223. private _onbuttonup;
  38224. private _ondpaddown;
  38225. private _ondpadup;
  38226. /** Observable raised when a button is pressed */
  38227. onButtonDownObservable: Observable<Xbox360Button>;
  38228. /** Observable raised when a button is released */
  38229. onButtonUpObservable: Observable<Xbox360Button>;
  38230. /** Observable raised when a pad is pressed */
  38231. onPadDownObservable: Observable<Xbox360Dpad>;
  38232. /** Observable raised when a pad is released */
  38233. onPadUpObservable: Observable<Xbox360Dpad>;
  38234. private _buttonA;
  38235. private _buttonB;
  38236. private _buttonX;
  38237. private _buttonY;
  38238. private _buttonBack;
  38239. private _buttonStart;
  38240. private _buttonLB;
  38241. private _buttonRB;
  38242. private _buttonLeftStick;
  38243. private _buttonRightStick;
  38244. private _dPadUp;
  38245. private _dPadDown;
  38246. private _dPadLeft;
  38247. private _dPadRight;
  38248. private _isXboxOnePad;
  38249. /**
  38250. * Creates a new XBox360 gamepad object
  38251. * @param id defines the id of this gamepad
  38252. * @param index defines its index
  38253. * @param gamepad defines the internal HTML gamepad object
  38254. * @param xboxOne defines if it is a XBox One gamepad
  38255. */
  38256. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38257. /**
  38258. * Defines the callback to call when left trigger is pressed
  38259. * @param callback defines the callback to use
  38260. */
  38261. onlefttriggerchanged(callback: (value: number) => void): void;
  38262. /**
  38263. * Defines the callback to call when right trigger is pressed
  38264. * @param callback defines the callback to use
  38265. */
  38266. onrighttriggerchanged(callback: (value: number) => void): void;
  38267. /**
  38268. * Gets the left trigger value
  38269. */
  38270. /**
  38271. * Sets the left trigger value
  38272. */
  38273. leftTrigger: number;
  38274. /**
  38275. * Gets the right trigger value
  38276. */
  38277. /**
  38278. * Sets the right trigger value
  38279. */
  38280. rightTrigger: number;
  38281. /**
  38282. * Defines the callback to call when a button is pressed
  38283. * @param callback defines the callback to use
  38284. */
  38285. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38286. /**
  38287. * Defines the callback to call when a button is released
  38288. * @param callback defines the callback to use
  38289. */
  38290. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38291. /**
  38292. * Defines the callback to call when a pad is pressed
  38293. * @param callback defines the callback to use
  38294. */
  38295. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38296. /**
  38297. * Defines the callback to call when a pad is released
  38298. * @param callback defines the callback to use
  38299. */
  38300. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38301. private _setButtonValue;
  38302. private _setDPadValue;
  38303. /**
  38304. * Gets the value of the `A` button
  38305. */
  38306. /**
  38307. * Sets the value of the `A` button
  38308. */
  38309. buttonA: number;
  38310. /**
  38311. * Gets the value of the `B` button
  38312. */
  38313. /**
  38314. * Sets the value of the `B` button
  38315. */
  38316. buttonB: number;
  38317. /**
  38318. * Gets the value of the `X` button
  38319. */
  38320. /**
  38321. * Sets the value of the `X` button
  38322. */
  38323. buttonX: number;
  38324. /**
  38325. * Gets the value of the `Y` button
  38326. */
  38327. /**
  38328. * Sets the value of the `Y` button
  38329. */
  38330. buttonY: number;
  38331. /**
  38332. * Gets the value of the `Start` button
  38333. */
  38334. /**
  38335. * Sets the value of the `Start` button
  38336. */
  38337. buttonStart: number;
  38338. /**
  38339. * Gets the value of the `Back` button
  38340. */
  38341. /**
  38342. * Sets the value of the `Back` button
  38343. */
  38344. buttonBack: number;
  38345. /**
  38346. * Gets the value of the `Left` button
  38347. */
  38348. /**
  38349. * Sets the value of the `Left` button
  38350. */
  38351. buttonLB: number;
  38352. /**
  38353. * Gets the value of the `Right` button
  38354. */
  38355. /**
  38356. * Sets the value of the `Right` button
  38357. */
  38358. buttonRB: number;
  38359. /**
  38360. * Gets the value of the Left joystick
  38361. */
  38362. /**
  38363. * Sets the value of the Left joystick
  38364. */
  38365. buttonLeftStick: number;
  38366. /**
  38367. * Gets the value of the Right joystick
  38368. */
  38369. /**
  38370. * Sets the value of the Right joystick
  38371. */
  38372. buttonRightStick: number;
  38373. /**
  38374. * Gets the value of D-pad up
  38375. */
  38376. /**
  38377. * Sets the value of D-pad up
  38378. */
  38379. dPadUp: number;
  38380. /**
  38381. * Gets the value of D-pad down
  38382. */
  38383. /**
  38384. * Sets the value of D-pad down
  38385. */
  38386. dPadDown: number;
  38387. /**
  38388. * Gets the value of D-pad left
  38389. */
  38390. /**
  38391. * Sets the value of D-pad left
  38392. */
  38393. dPadLeft: number;
  38394. /**
  38395. * Gets the value of D-pad right
  38396. */
  38397. /**
  38398. * Sets the value of D-pad right
  38399. */
  38400. dPadRight: number;
  38401. /**
  38402. * Force the gamepad to synchronize with device values
  38403. */
  38404. update(): void;
  38405. /**
  38406. * Disposes the gamepad
  38407. */
  38408. dispose(): void;
  38409. }
  38410. }
  38411. declare module "babylonjs/Materials/pushMaterial" {
  38412. import { Nullable } from "babylonjs/types";
  38413. import { Scene } from "babylonjs/scene";
  38414. import { Matrix } from "babylonjs/Maths/math";
  38415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38416. import { Mesh } from "babylonjs/Meshes/mesh";
  38417. import { Material } from "babylonjs/Materials/material";
  38418. import { Effect } from "babylonjs/Materials/effect";
  38419. /**
  38420. * Base class of materials working in push mode in babylon JS
  38421. * @hidden
  38422. */
  38423. export class PushMaterial extends Material {
  38424. protected _activeEffect: Effect;
  38425. protected _normalMatrix: Matrix;
  38426. /**
  38427. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38428. * This means that the material can keep using a previous shader while a new one is being compiled.
  38429. * This is mostly used when shader parallel compilation is supported (true by default)
  38430. */
  38431. allowShaderHotSwapping: boolean;
  38432. constructor(name: string, scene: Scene);
  38433. getEffect(): Effect;
  38434. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38435. /**
  38436. * Binds the given world matrix to the active effect
  38437. *
  38438. * @param world the matrix to bind
  38439. */
  38440. bindOnlyWorldMatrix(world: Matrix): void;
  38441. /**
  38442. * Binds the given normal matrix to the active effect
  38443. *
  38444. * @param normalMatrix the matrix to bind
  38445. */
  38446. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38447. bind(world: Matrix, mesh?: Mesh): void;
  38448. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38449. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38450. }
  38451. }
  38452. declare module "babylonjs/Materials/materialFlags" {
  38453. /**
  38454. * This groups all the flags used to control the materials channel.
  38455. */
  38456. export class MaterialFlags {
  38457. private static _DiffuseTextureEnabled;
  38458. /**
  38459. * Are diffuse textures enabled in the application.
  38460. */
  38461. static DiffuseTextureEnabled: boolean;
  38462. private static _AmbientTextureEnabled;
  38463. /**
  38464. * Are ambient textures enabled in the application.
  38465. */
  38466. static AmbientTextureEnabled: boolean;
  38467. private static _OpacityTextureEnabled;
  38468. /**
  38469. * Are opacity textures enabled in the application.
  38470. */
  38471. static OpacityTextureEnabled: boolean;
  38472. private static _ReflectionTextureEnabled;
  38473. /**
  38474. * Are reflection textures enabled in the application.
  38475. */
  38476. static ReflectionTextureEnabled: boolean;
  38477. private static _EmissiveTextureEnabled;
  38478. /**
  38479. * Are emissive textures enabled in the application.
  38480. */
  38481. static EmissiveTextureEnabled: boolean;
  38482. private static _SpecularTextureEnabled;
  38483. /**
  38484. * Are specular textures enabled in the application.
  38485. */
  38486. static SpecularTextureEnabled: boolean;
  38487. private static _BumpTextureEnabled;
  38488. /**
  38489. * Are bump textures enabled in the application.
  38490. */
  38491. static BumpTextureEnabled: boolean;
  38492. private static _LightmapTextureEnabled;
  38493. /**
  38494. * Are lightmap textures enabled in the application.
  38495. */
  38496. static LightmapTextureEnabled: boolean;
  38497. private static _RefractionTextureEnabled;
  38498. /**
  38499. * Are refraction textures enabled in the application.
  38500. */
  38501. static RefractionTextureEnabled: boolean;
  38502. private static _ColorGradingTextureEnabled;
  38503. /**
  38504. * Are color grading textures enabled in the application.
  38505. */
  38506. static ColorGradingTextureEnabled: boolean;
  38507. private static _FresnelEnabled;
  38508. /**
  38509. * Are fresnels enabled in the application.
  38510. */
  38511. static FresnelEnabled: boolean;
  38512. private static _ClearCoatTextureEnabled;
  38513. /**
  38514. * Are clear coat textures enabled in the application.
  38515. */
  38516. static ClearCoatTextureEnabled: boolean;
  38517. private static _ClearCoatBumpTextureEnabled;
  38518. /**
  38519. * Are clear coat bump textures enabled in the application.
  38520. */
  38521. static ClearCoatBumpTextureEnabled: boolean;
  38522. private static _ClearCoatTintTextureEnabled;
  38523. /**
  38524. * Are clear coat tint textures enabled in the application.
  38525. */
  38526. static ClearCoatTintTextureEnabled: boolean;
  38527. }
  38528. }
  38529. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38530. /** @hidden */
  38531. export var defaultFragmentDeclaration: {
  38532. name: string;
  38533. shader: string;
  38534. };
  38535. }
  38536. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38537. /** @hidden */
  38538. export var defaultUboDeclaration: {
  38539. name: string;
  38540. shader: string;
  38541. };
  38542. }
  38543. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38544. /** @hidden */
  38545. export var lightFragmentDeclaration: {
  38546. name: string;
  38547. shader: string;
  38548. };
  38549. }
  38550. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38551. /** @hidden */
  38552. export var lightUboDeclaration: {
  38553. name: string;
  38554. shader: string;
  38555. };
  38556. }
  38557. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38558. /** @hidden */
  38559. export var lightsFragmentFunctions: {
  38560. name: string;
  38561. shader: string;
  38562. };
  38563. }
  38564. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38565. /** @hidden */
  38566. export var shadowsFragmentFunctions: {
  38567. name: string;
  38568. shader: string;
  38569. };
  38570. }
  38571. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38572. /** @hidden */
  38573. export var fresnelFunction: {
  38574. name: string;
  38575. shader: string;
  38576. };
  38577. }
  38578. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38579. /** @hidden */
  38580. export var reflectionFunction: {
  38581. name: string;
  38582. shader: string;
  38583. };
  38584. }
  38585. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38586. /** @hidden */
  38587. export var bumpFragmentFunctions: {
  38588. name: string;
  38589. shader: string;
  38590. };
  38591. }
  38592. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38593. /** @hidden */
  38594. export var logDepthDeclaration: {
  38595. name: string;
  38596. shader: string;
  38597. };
  38598. }
  38599. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38600. /** @hidden */
  38601. export var bumpFragment: {
  38602. name: string;
  38603. shader: string;
  38604. };
  38605. }
  38606. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38607. /** @hidden */
  38608. export var depthPrePass: {
  38609. name: string;
  38610. shader: string;
  38611. };
  38612. }
  38613. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38614. /** @hidden */
  38615. export var lightFragment: {
  38616. name: string;
  38617. shader: string;
  38618. };
  38619. }
  38620. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38621. /** @hidden */
  38622. export var logDepthFragment: {
  38623. name: string;
  38624. shader: string;
  38625. };
  38626. }
  38627. declare module "babylonjs/Shaders/default.fragment" {
  38628. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38629. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38630. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38631. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38632. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38633. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38634. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38635. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38636. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38637. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38638. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38639. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38640. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38641. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38642. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38643. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38644. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38645. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38646. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38647. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38648. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38649. /** @hidden */
  38650. export var defaultPixelShader: {
  38651. name: string;
  38652. shader: string;
  38653. };
  38654. }
  38655. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38656. /** @hidden */
  38657. export var defaultVertexDeclaration: {
  38658. name: string;
  38659. shader: string;
  38660. };
  38661. }
  38662. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38663. /** @hidden */
  38664. export var bumpVertexDeclaration: {
  38665. name: string;
  38666. shader: string;
  38667. };
  38668. }
  38669. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38670. /** @hidden */
  38671. export var bumpVertex: {
  38672. name: string;
  38673. shader: string;
  38674. };
  38675. }
  38676. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38677. /** @hidden */
  38678. export var fogVertex: {
  38679. name: string;
  38680. shader: string;
  38681. };
  38682. }
  38683. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38684. /** @hidden */
  38685. export var shadowsVertex: {
  38686. name: string;
  38687. shader: string;
  38688. };
  38689. }
  38690. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38691. /** @hidden */
  38692. export var pointCloudVertex: {
  38693. name: string;
  38694. shader: string;
  38695. };
  38696. }
  38697. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38698. /** @hidden */
  38699. export var logDepthVertex: {
  38700. name: string;
  38701. shader: string;
  38702. };
  38703. }
  38704. declare module "babylonjs/Shaders/default.vertex" {
  38705. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38706. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38707. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38708. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38709. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38710. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38711. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38712. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38713. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38714. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38715. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38716. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38717. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38718. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38719. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38720. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38721. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38722. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38723. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38724. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38725. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38726. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38727. /** @hidden */
  38728. export var defaultVertexShader: {
  38729. name: string;
  38730. shader: string;
  38731. };
  38732. }
  38733. declare module "babylonjs/Materials/standardMaterial" {
  38734. import { SmartArray } from "babylonjs/Misc/smartArray";
  38735. import { IAnimatable } from "babylonjs/Misc/tools";
  38736. import { Nullable } from "babylonjs/types";
  38737. import { Scene } from "babylonjs/scene";
  38738. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38739. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38741. import { Mesh } from "babylonjs/Meshes/mesh";
  38742. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38743. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38744. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38745. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38746. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38747. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38748. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38749. import "babylonjs/Shaders/default.fragment";
  38750. import "babylonjs/Shaders/default.vertex";
  38751. /** @hidden */
  38752. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38753. MAINUV1: boolean;
  38754. MAINUV2: boolean;
  38755. DIFFUSE: boolean;
  38756. DIFFUSEDIRECTUV: number;
  38757. AMBIENT: boolean;
  38758. AMBIENTDIRECTUV: number;
  38759. OPACITY: boolean;
  38760. OPACITYDIRECTUV: number;
  38761. OPACITYRGB: boolean;
  38762. REFLECTION: boolean;
  38763. EMISSIVE: boolean;
  38764. EMISSIVEDIRECTUV: number;
  38765. SPECULAR: boolean;
  38766. SPECULARDIRECTUV: number;
  38767. BUMP: boolean;
  38768. BUMPDIRECTUV: number;
  38769. PARALLAX: boolean;
  38770. PARALLAXOCCLUSION: boolean;
  38771. SPECULAROVERALPHA: boolean;
  38772. CLIPPLANE: boolean;
  38773. CLIPPLANE2: boolean;
  38774. CLIPPLANE3: boolean;
  38775. CLIPPLANE4: boolean;
  38776. ALPHATEST: boolean;
  38777. DEPTHPREPASS: boolean;
  38778. ALPHAFROMDIFFUSE: boolean;
  38779. POINTSIZE: boolean;
  38780. FOG: boolean;
  38781. SPECULARTERM: boolean;
  38782. DIFFUSEFRESNEL: boolean;
  38783. OPACITYFRESNEL: boolean;
  38784. REFLECTIONFRESNEL: boolean;
  38785. REFRACTIONFRESNEL: boolean;
  38786. EMISSIVEFRESNEL: boolean;
  38787. FRESNEL: boolean;
  38788. NORMAL: boolean;
  38789. UV1: boolean;
  38790. UV2: boolean;
  38791. VERTEXCOLOR: boolean;
  38792. VERTEXALPHA: boolean;
  38793. NUM_BONE_INFLUENCERS: number;
  38794. BonesPerMesh: number;
  38795. BONETEXTURE: boolean;
  38796. INSTANCES: boolean;
  38797. GLOSSINESS: boolean;
  38798. ROUGHNESS: boolean;
  38799. EMISSIVEASILLUMINATION: boolean;
  38800. LINKEMISSIVEWITHDIFFUSE: boolean;
  38801. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38802. LIGHTMAP: boolean;
  38803. LIGHTMAPDIRECTUV: number;
  38804. OBJECTSPACE_NORMALMAP: boolean;
  38805. USELIGHTMAPASSHADOWMAP: boolean;
  38806. REFLECTIONMAP_3D: boolean;
  38807. REFLECTIONMAP_SPHERICAL: boolean;
  38808. REFLECTIONMAP_PLANAR: boolean;
  38809. REFLECTIONMAP_CUBIC: boolean;
  38810. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38811. REFLECTIONMAP_PROJECTION: boolean;
  38812. REFLECTIONMAP_SKYBOX: boolean;
  38813. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38814. REFLECTIONMAP_EXPLICIT: boolean;
  38815. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38816. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38817. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38818. INVERTCUBICMAP: boolean;
  38819. LOGARITHMICDEPTH: boolean;
  38820. REFRACTION: boolean;
  38821. REFRACTIONMAP_3D: boolean;
  38822. REFLECTIONOVERALPHA: boolean;
  38823. TWOSIDEDLIGHTING: boolean;
  38824. SHADOWFLOAT: boolean;
  38825. MORPHTARGETS: boolean;
  38826. MORPHTARGETS_NORMAL: boolean;
  38827. MORPHTARGETS_TANGENT: boolean;
  38828. NUM_MORPH_INFLUENCERS: number;
  38829. NONUNIFORMSCALING: boolean;
  38830. PREMULTIPLYALPHA: boolean;
  38831. IMAGEPROCESSING: boolean;
  38832. VIGNETTE: boolean;
  38833. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38834. VIGNETTEBLENDMODEOPAQUE: boolean;
  38835. TONEMAPPING: boolean;
  38836. TONEMAPPING_ACES: boolean;
  38837. CONTRAST: boolean;
  38838. COLORCURVES: boolean;
  38839. COLORGRADING: boolean;
  38840. COLORGRADING3D: boolean;
  38841. SAMPLER3DGREENDEPTH: boolean;
  38842. SAMPLER3DBGRMAP: boolean;
  38843. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38844. /**
  38845. * If the reflection texture on this material is in linear color space
  38846. * @hidden
  38847. */
  38848. IS_REFLECTION_LINEAR: boolean;
  38849. /**
  38850. * If the refraction texture on this material is in linear color space
  38851. * @hidden
  38852. */
  38853. IS_REFRACTION_LINEAR: boolean;
  38854. EXPOSURE: boolean;
  38855. constructor();
  38856. setReflectionMode(modeToEnable: string): void;
  38857. }
  38858. /**
  38859. * This is the default material used in Babylon. It is the best trade off between quality
  38860. * and performances.
  38861. * @see http://doc.babylonjs.com/babylon101/materials
  38862. */
  38863. export class StandardMaterial extends PushMaterial {
  38864. private _diffuseTexture;
  38865. /**
  38866. * The basic texture of the material as viewed under a light.
  38867. */
  38868. diffuseTexture: Nullable<BaseTexture>;
  38869. private _ambientTexture;
  38870. /**
  38871. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38872. */
  38873. ambientTexture: Nullable<BaseTexture>;
  38874. private _opacityTexture;
  38875. /**
  38876. * Define the transparency of the material from a texture.
  38877. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38878. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38879. */
  38880. opacityTexture: Nullable<BaseTexture>;
  38881. private _reflectionTexture;
  38882. /**
  38883. * Define the texture used to display the reflection.
  38884. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38885. */
  38886. reflectionTexture: Nullable<BaseTexture>;
  38887. private _emissiveTexture;
  38888. /**
  38889. * Define texture of the material as if self lit.
  38890. * This will be mixed in the final result even in the absence of light.
  38891. */
  38892. emissiveTexture: Nullable<BaseTexture>;
  38893. private _specularTexture;
  38894. /**
  38895. * Define how the color and intensity of the highlight given by the light in the material.
  38896. */
  38897. specularTexture: Nullable<BaseTexture>;
  38898. private _bumpTexture;
  38899. /**
  38900. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38901. * 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.
  38902. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38903. */
  38904. bumpTexture: Nullable<BaseTexture>;
  38905. private _lightmapTexture;
  38906. /**
  38907. * Complex lighting can be computationally expensive to compute at runtime.
  38908. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38909. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38910. */
  38911. lightmapTexture: Nullable<BaseTexture>;
  38912. private _refractionTexture;
  38913. /**
  38914. * Define the texture used to display the refraction.
  38915. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38916. */
  38917. refractionTexture: Nullable<BaseTexture>;
  38918. /**
  38919. * The color of the material lit by the environmental background lighting.
  38920. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38921. */
  38922. ambientColor: Color3;
  38923. /**
  38924. * The basic color of the material as viewed under a light.
  38925. */
  38926. diffuseColor: Color3;
  38927. /**
  38928. * Define how the color and intensity of the highlight given by the light in the material.
  38929. */
  38930. specularColor: Color3;
  38931. /**
  38932. * Define the color of the material as if self lit.
  38933. * This will be mixed in the final result even in the absence of light.
  38934. */
  38935. emissiveColor: Color3;
  38936. /**
  38937. * Defines how sharp are the highlights in the material.
  38938. * The bigger the value the sharper giving a more glossy feeling to the result.
  38939. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38940. */
  38941. specularPower: number;
  38942. private _useAlphaFromDiffuseTexture;
  38943. /**
  38944. * Does the transparency come from the diffuse texture alpha channel.
  38945. */
  38946. useAlphaFromDiffuseTexture: boolean;
  38947. private _useEmissiveAsIllumination;
  38948. /**
  38949. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38950. */
  38951. useEmissiveAsIllumination: boolean;
  38952. private _linkEmissiveWithDiffuse;
  38953. /**
  38954. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38955. * the emissive level when the final color is close to one.
  38956. */
  38957. linkEmissiveWithDiffuse: boolean;
  38958. private _useSpecularOverAlpha;
  38959. /**
  38960. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38961. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38962. */
  38963. useSpecularOverAlpha: boolean;
  38964. private _useReflectionOverAlpha;
  38965. /**
  38966. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38967. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38968. */
  38969. useReflectionOverAlpha: boolean;
  38970. private _disableLighting;
  38971. /**
  38972. * Does lights from the scene impacts this material.
  38973. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38974. */
  38975. disableLighting: boolean;
  38976. private _useObjectSpaceNormalMap;
  38977. /**
  38978. * Allows using an object space normal map (instead of tangent space).
  38979. */
  38980. useObjectSpaceNormalMap: boolean;
  38981. private _useParallax;
  38982. /**
  38983. * Is parallax enabled or not.
  38984. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38985. */
  38986. useParallax: boolean;
  38987. private _useParallaxOcclusion;
  38988. /**
  38989. * Is parallax occlusion enabled or not.
  38990. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38991. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38992. */
  38993. useParallaxOcclusion: boolean;
  38994. /**
  38995. * 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.
  38996. */
  38997. parallaxScaleBias: number;
  38998. private _roughness;
  38999. /**
  39000. * Helps to define how blurry the reflections should appears in the material.
  39001. */
  39002. roughness: number;
  39003. /**
  39004. * In case of refraction, define the value of the indice of refraction.
  39005. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39006. */
  39007. indexOfRefraction: number;
  39008. /**
  39009. * Invert the refraction texture alongside the y axis.
  39010. * It can be useful with procedural textures or probe for instance.
  39011. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39012. */
  39013. invertRefractionY: boolean;
  39014. /**
  39015. * Defines the alpha limits in alpha test mode.
  39016. */
  39017. alphaCutOff: number;
  39018. private _useLightmapAsShadowmap;
  39019. /**
  39020. * In case of light mapping, define whether the map contains light or shadow informations.
  39021. */
  39022. useLightmapAsShadowmap: boolean;
  39023. private _diffuseFresnelParameters;
  39024. /**
  39025. * Define the diffuse fresnel parameters of the material.
  39026. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39027. */
  39028. diffuseFresnelParameters: FresnelParameters;
  39029. private _opacityFresnelParameters;
  39030. /**
  39031. * Define the opacity fresnel parameters of the material.
  39032. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39033. */
  39034. opacityFresnelParameters: FresnelParameters;
  39035. private _reflectionFresnelParameters;
  39036. /**
  39037. * Define the reflection fresnel parameters of the material.
  39038. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39039. */
  39040. reflectionFresnelParameters: FresnelParameters;
  39041. private _refractionFresnelParameters;
  39042. /**
  39043. * Define the refraction fresnel parameters of the material.
  39044. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39045. */
  39046. refractionFresnelParameters: FresnelParameters;
  39047. private _emissiveFresnelParameters;
  39048. /**
  39049. * Define the emissive fresnel parameters of the material.
  39050. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39051. */
  39052. emissiveFresnelParameters: FresnelParameters;
  39053. private _useReflectionFresnelFromSpecular;
  39054. /**
  39055. * If true automatically deducts the fresnels values from the material specularity.
  39056. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39057. */
  39058. useReflectionFresnelFromSpecular: boolean;
  39059. private _useGlossinessFromSpecularMapAlpha;
  39060. /**
  39061. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39062. */
  39063. useGlossinessFromSpecularMapAlpha: boolean;
  39064. private _maxSimultaneousLights;
  39065. /**
  39066. * Defines the maximum number of lights that can be used in the material
  39067. */
  39068. maxSimultaneousLights: number;
  39069. private _invertNormalMapX;
  39070. /**
  39071. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39072. */
  39073. invertNormalMapX: boolean;
  39074. private _invertNormalMapY;
  39075. /**
  39076. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39077. */
  39078. invertNormalMapY: boolean;
  39079. private _twoSidedLighting;
  39080. /**
  39081. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39082. */
  39083. twoSidedLighting: boolean;
  39084. /**
  39085. * Default configuration related to image processing available in the standard Material.
  39086. */
  39087. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39088. /**
  39089. * Gets the image processing configuration used either in this material.
  39090. */
  39091. /**
  39092. * Sets the Default image processing configuration used either in the this material.
  39093. *
  39094. * If sets to null, the scene one is in use.
  39095. */
  39096. imageProcessingConfiguration: ImageProcessingConfiguration;
  39097. /**
  39098. * Keep track of the image processing observer to allow dispose and replace.
  39099. */
  39100. private _imageProcessingObserver;
  39101. /**
  39102. * Attaches a new image processing configuration to the Standard Material.
  39103. * @param configuration
  39104. */
  39105. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39106. /**
  39107. * Gets wether the color curves effect is enabled.
  39108. */
  39109. /**
  39110. * Sets wether the color curves effect is enabled.
  39111. */
  39112. cameraColorCurvesEnabled: boolean;
  39113. /**
  39114. * Gets wether the color grading effect is enabled.
  39115. */
  39116. /**
  39117. * Gets wether the color grading effect is enabled.
  39118. */
  39119. cameraColorGradingEnabled: boolean;
  39120. /**
  39121. * Gets wether tonemapping is enabled or not.
  39122. */
  39123. /**
  39124. * Sets wether tonemapping is enabled or not
  39125. */
  39126. cameraToneMappingEnabled: boolean;
  39127. /**
  39128. * The camera exposure used on this material.
  39129. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39130. * This corresponds to a photographic exposure.
  39131. */
  39132. /**
  39133. * The camera exposure used on this material.
  39134. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39135. * This corresponds to a photographic exposure.
  39136. */
  39137. cameraExposure: number;
  39138. /**
  39139. * Gets The camera contrast used on this material.
  39140. */
  39141. /**
  39142. * Sets The camera contrast used on this material.
  39143. */
  39144. cameraContrast: number;
  39145. /**
  39146. * Gets the Color Grading 2D Lookup Texture.
  39147. */
  39148. /**
  39149. * Sets the Color Grading 2D Lookup Texture.
  39150. */
  39151. cameraColorGradingTexture: Nullable<BaseTexture>;
  39152. /**
  39153. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39154. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39155. * 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;
  39156. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39157. */
  39158. /**
  39159. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39160. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39161. * 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;
  39162. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39163. */
  39164. cameraColorCurves: Nullable<ColorCurves>;
  39165. /**
  39166. * Custom callback helping to override the default shader used in the material.
  39167. */
  39168. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39169. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39170. protected _worldViewProjectionMatrix: Matrix;
  39171. protected _globalAmbientColor: Color3;
  39172. protected _useLogarithmicDepth: boolean;
  39173. /**
  39174. * Instantiates a new standard material.
  39175. * This is the default material used in Babylon. It is the best trade off between quality
  39176. * and performances.
  39177. * @see http://doc.babylonjs.com/babylon101/materials
  39178. * @param name Define the name of the material in the scene
  39179. * @param scene Define the scene the material belong to
  39180. */
  39181. constructor(name: string, scene: Scene);
  39182. /**
  39183. * Gets a boolean indicating that current material needs to register RTT
  39184. */
  39185. readonly hasRenderTargetTextures: boolean;
  39186. /**
  39187. * Gets the current class name of the material e.g. "StandardMaterial"
  39188. * Mainly use in serialization.
  39189. * @returns the class name
  39190. */
  39191. getClassName(): string;
  39192. /**
  39193. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39194. * You can try switching to logarithmic depth.
  39195. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39196. */
  39197. useLogarithmicDepth: boolean;
  39198. /**
  39199. * Specifies if the material will require alpha blending
  39200. * @returns a boolean specifying if alpha blending is needed
  39201. */
  39202. needAlphaBlending(): boolean;
  39203. /**
  39204. * Specifies if this material should be rendered in alpha test mode
  39205. * @returns a boolean specifying if an alpha test is needed.
  39206. */
  39207. needAlphaTesting(): boolean;
  39208. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39209. /**
  39210. * Get the texture used for alpha test purpose.
  39211. * @returns the diffuse texture in case of the standard material.
  39212. */
  39213. getAlphaTestTexture(): Nullable<BaseTexture>;
  39214. /**
  39215. * Get if the submesh is ready to be used and all its information available.
  39216. * Child classes can use it to update shaders
  39217. * @param mesh defines the mesh to check
  39218. * @param subMesh defines which submesh to check
  39219. * @param useInstances specifies that instances should be used
  39220. * @returns a boolean indicating that the submesh is ready or not
  39221. */
  39222. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39223. /**
  39224. * Builds the material UBO layouts.
  39225. * Used internally during the effect preparation.
  39226. */
  39227. buildUniformLayout(): void;
  39228. /**
  39229. * Unbinds the material from the mesh
  39230. */
  39231. unbind(): void;
  39232. /**
  39233. * Binds the submesh to this material by preparing the effect and shader to draw
  39234. * @param world defines the world transformation matrix
  39235. * @param mesh defines the mesh containing the submesh
  39236. * @param subMesh defines the submesh to bind the material to
  39237. */
  39238. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39239. /**
  39240. * Get the list of animatables in the material.
  39241. * @returns the list of animatables object used in the material
  39242. */
  39243. getAnimatables(): IAnimatable[];
  39244. /**
  39245. * Gets the active textures from the material
  39246. * @returns an array of textures
  39247. */
  39248. getActiveTextures(): BaseTexture[];
  39249. /**
  39250. * Specifies if the material uses a texture
  39251. * @param texture defines the texture to check against the material
  39252. * @returns a boolean specifying if the material uses the texture
  39253. */
  39254. hasTexture(texture: BaseTexture): boolean;
  39255. /**
  39256. * Disposes the material
  39257. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39258. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39259. */
  39260. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39261. /**
  39262. * Makes a duplicate of the material, and gives it a new name
  39263. * @param name defines the new name for the duplicated material
  39264. * @returns the cloned material
  39265. */
  39266. clone(name: string): StandardMaterial;
  39267. /**
  39268. * Serializes this material in a JSON representation
  39269. * @returns the serialized material object
  39270. */
  39271. serialize(): any;
  39272. /**
  39273. * Creates a standard material from parsed material data
  39274. * @param source defines the JSON representation of the material
  39275. * @param scene defines the hosting scene
  39276. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39277. * @returns a new standard material
  39278. */
  39279. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39280. /**
  39281. * Are diffuse textures enabled in the application.
  39282. */
  39283. static DiffuseTextureEnabled: boolean;
  39284. /**
  39285. * Are ambient textures enabled in the application.
  39286. */
  39287. static AmbientTextureEnabled: boolean;
  39288. /**
  39289. * Are opacity textures enabled in the application.
  39290. */
  39291. static OpacityTextureEnabled: boolean;
  39292. /**
  39293. * Are reflection textures enabled in the application.
  39294. */
  39295. static ReflectionTextureEnabled: boolean;
  39296. /**
  39297. * Are emissive textures enabled in the application.
  39298. */
  39299. static EmissiveTextureEnabled: boolean;
  39300. /**
  39301. * Are specular textures enabled in the application.
  39302. */
  39303. static SpecularTextureEnabled: boolean;
  39304. /**
  39305. * Are bump textures enabled in the application.
  39306. */
  39307. static BumpTextureEnabled: boolean;
  39308. /**
  39309. * Are lightmap textures enabled in the application.
  39310. */
  39311. static LightmapTextureEnabled: boolean;
  39312. /**
  39313. * Are refraction textures enabled in the application.
  39314. */
  39315. static RefractionTextureEnabled: boolean;
  39316. /**
  39317. * Are color grading textures enabled in the application.
  39318. */
  39319. static ColorGradingTextureEnabled: boolean;
  39320. /**
  39321. * Are fresnels enabled in the application.
  39322. */
  39323. static FresnelEnabled: boolean;
  39324. }
  39325. }
  39326. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39327. import { Scene } from "babylonjs/scene";
  39328. import { Texture } from "babylonjs/Materials/Textures/texture";
  39329. /**
  39330. * A class extending Texture allowing drawing on a texture
  39331. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39332. */
  39333. export class DynamicTexture extends Texture {
  39334. private _generateMipMaps;
  39335. private _canvas;
  39336. private _context;
  39337. private _engine;
  39338. /**
  39339. * Creates a DynamicTexture
  39340. * @param name defines the name of the texture
  39341. * @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
  39342. * @param scene defines the scene where you want the texture
  39343. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39344. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39345. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39346. */
  39347. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39348. /**
  39349. * Get the current class name of the texture useful for serialization or dynamic coding.
  39350. * @returns "DynamicTexture"
  39351. */
  39352. getClassName(): string;
  39353. /**
  39354. * Gets the current state of canRescale
  39355. */
  39356. readonly canRescale: boolean;
  39357. private _recreate;
  39358. /**
  39359. * Scales the texture
  39360. * @param ratio the scale factor to apply to both width and height
  39361. */
  39362. scale(ratio: number): void;
  39363. /**
  39364. * Resizes the texture
  39365. * @param width the new width
  39366. * @param height the new height
  39367. */
  39368. scaleTo(width: number, height: number): void;
  39369. /**
  39370. * Gets the context of the canvas used by the texture
  39371. * @returns the canvas context of the dynamic texture
  39372. */
  39373. getContext(): CanvasRenderingContext2D;
  39374. /**
  39375. * Clears the texture
  39376. */
  39377. clear(): void;
  39378. /**
  39379. * Updates the texture
  39380. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39381. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39382. */
  39383. update(invertY?: boolean, premulAlpha?: boolean): void;
  39384. /**
  39385. * Draws text onto the texture
  39386. * @param text defines the text to be drawn
  39387. * @param x defines the placement of the text from the left
  39388. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39389. * @param font defines the font to be used with font-style, font-size, font-name
  39390. * @param color defines the color used for the text
  39391. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39392. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39393. * @param update defines whether texture is immediately update (default is true)
  39394. */
  39395. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39396. /**
  39397. * Clones the texture
  39398. * @returns the clone of the texture.
  39399. */
  39400. clone(): DynamicTexture;
  39401. /**
  39402. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39403. * @returns a serialized dynamic texture object
  39404. */
  39405. serialize(): any;
  39406. /** @hidden */
  39407. _rebuild(): void;
  39408. }
  39409. }
  39410. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39411. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39412. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39413. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39414. /** @hidden */
  39415. export var imageProcessingPixelShader: {
  39416. name: string;
  39417. shader: string;
  39418. };
  39419. }
  39420. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39421. import { Nullable } from "babylonjs/types";
  39422. import { Color4 } from "babylonjs/Maths/math";
  39423. import { Camera } from "babylonjs/Cameras/camera";
  39424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39425. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39426. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39427. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39428. import { Engine } from "babylonjs/Engines/engine";
  39429. import "babylonjs/Shaders/imageProcessing.fragment";
  39430. import "babylonjs/Shaders/postprocess.vertex";
  39431. /**
  39432. * ImageProcessingPostProcess
  39433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39434. */
  39435. export class ImageProcessingPostProcess extends PostProcess {
  39436. /**
  39437. * Default configuration related to image processing available in the PBR Material.
  39438. */
  39439. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39440. /**
  39441. * Gets the image processing configuration used either in this material.
  39442. */
  39443. /**
  39444. * Sets the Default image processing configuration used either in the this material.
  39445. *
  39446. * If sets to null, the scene one is in use.
  39447. */
  39448. imageProcessingConfiguration: ImageProcessingConfiguration;
  39449. /**
  39450. * Keep track of the image processing observer to allow dispose and replace.
  39451. */
  39452. private _imageProcessingObserver;
  39453. /**
  39454. * Attaches a new image processing configuration to the PBR Material.
  39455. * @param configuration
  39456. */
  39457. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39458. /**
  39459. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39460. */
  39461. /**
  39462. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39463. */
  39464. colorCurves: Nullable<ColorCurves>;
  39465. /**
  39466. * Gets wether the color curves effect is enabled.
  39467. */
  39468. /**
  39469. * Sets wether the color curves effect is enabled.
  39470. */
  39471. colorCurvesEnabled: boolean;
  39472. /**
  39473. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39474. */
  39475. /**
  39476. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39477. */
  39478. colorGradingTexture: Nullable<BaseTexture>;
  39479. /**
  39480. * Gets wether the color grading effect is enabled.
  39481. */
  39482. /**
  39483. * Gets wether the color grading effect is enabled.
  39484. */
  39485. colorGradingEnabled: boolean;
  39486. /**
  39487. * Gets exposure used in the effect.
  39488. */
  39489. /**
  39490. * Sets exposure used in the effect.
  39491. */
  39492. exposure: number;
  39493. /**
  39494. * Gets wether tonemapping is enabled or not.
  39495. */
  39496. /**
  39497. * Sets wether tonemapping is enabled or not
  39498. */
  39499. toneMappingEnabled: boolean;
  39500. /**
  39501. * Gets the type of tone mapping effect.
  39502. */
  39503. /**
  39504. * Sets the type of tone mapping effect.
  39505. */
  39506. toneMappingType: number;
  39507. /**
  39508. * Gets contrast used in the effect.
  39509. */
  39510. /**
  39511. * Sets contrast used in the effect.
  39512. */
  39513. contrast: number;
  39514. /**
  39515. * Gets Vignette stretch size.
  39516. */
  39517. /**
  39518. * Sets Vignette stretch size.
  39519. */
  39520. vignetteStretch: number;
  39521. /**
  39522. * Gets Vignette centre X Offset.
  39523. */
  39524. /**
  39525. * Sets Vignette centre X Offset.
  39526. */
  39527. vignetteCentreX: number;
  39528. /**
  39529. * Gets Vignette centre Y Offset.
  39530. */
  39531. /**
  39532. * Sets Vignette centre Y Offset.
  39533. */
  39534. vignetteCentreY: number;
  39535. /**
  39536. * Gets Vignette weight or intensity of the vignette effect.
  39537. */
  39538. /**
  39539. * Sets Vignette weight or intensity of the vignette effect.
  39540. */
  39541. vignetteWeight: number;
  39542. /**
  39543. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39544. * if vignetteEnabled is set to true.
  39545. */
  39546. /**
  39547. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39548. * if vignetteEnabled is set to true.
  39549. */
  39550. vignetteColor: Color4;
  39551. /**
  39552. * Gets Camera field of view used by the Vignette effect.
  39553. */
  39554. /**
  39555. * Sets Camera field of view used by the Vignette effect.
  39556. */
  39557. vignetteCameraFov: number;
  39558. /**
  39559. * Gets the vignette blend mode allowing different kind of effect.
  39560. */
  39561. /**
  39562. * Sets the vignette blend mode allowing different kind of effect.
  39563. */
  39564. vignetteBlendMode: number;
  39565. /**
  39566. * Gets wether the vignette effect is enabled.
  39567. */
  39568. /**
  39569. * Sets wether the vignette effect is enabled.
  39570. */
  39571. vignetteEnabled: boolean;
  39572. private _fromLinearSpace;
  39573. /**
  39574. * Gets wether the input of the processing is in Gamma or Linear Space.
  39575. */
  39576. /**
  39577. * Sets wether the input of the processing is in Gamma or Linear Space.
  39578. */
  39579. fromLinearSpace: boolean;
  39580. /**
  39581. * Defines cache preventing GC.
  39582. */
  39583. private _defines;
  39584. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39585. /**
  39586. * "ImageProcessingPostProcess"
  39587. * @returns "ImageProcessingPostProcess"
  39588. */
  39589. getClassName(): string;
  39590. protected _updateParameters(): void;
  39591. dispose(camera?: Camera): void;
  39592. }
  39593. }
  39594. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39595. import { Scene } from "babylonjs/scene";
  39596. import { Color3 } from "babylonjs/Maths/math";
  39597. import { Mesh } from "babylonjs/Meshes/mesh";
  39598. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39599. /**
  39600. * Class containing static functions to help procedurally build meshes
  39601. */
  39602. export class GroundBuilder {
  39603. /**
  39604. * Creates a ground mesh
  39605. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39606. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39608. * @param name defines the name of the mesh
  39609. * @param options defines the options used to create the mesh
  39610. * @param scene defines the hosting scene
  39611. * @returns the ground mesh
  39612. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39613. */
  39614. static CreateGround(name: string, options: {
  39615. width?: number;
  39616. height?: number;
  39617. subdivisions?: number;
  39618. subdivisionsX?: number;
  39619. subdivisionsY?: number;
  39620. updatable?: boolean;
  39621. }, scene: any): Mesh;
  39622. /**
  39623. * Creates a tiled ground mesh
  39624. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39625. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39626. * * 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
  39627. * * 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
  39628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39629. * @param name defines the name of the mesh
  39630. * @param options defines the options used to create the mesh
  39631. * @param scene defines the hosting scene
  39632. * @returns the tiled ground mesh
  39633. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39634. */
  39635. static CreateTiledGround(name: string, options: {
  39636. xmin: number;
  39637. zmin: number;
  39638. xmax: number;
  39639. zmax: number;
  39640. subdivisions?: {
  39641. w: number;
  39642. h: number;
  39643. };
  39644. precision?: {
  39645. w: number;
  39646. h: number;
  39647. };
  39648. updatable?: boolean;
  39649. }, scene: Scene): Mesh;
  39650. /**
  39651. * Creates a ground mesh from a height map
  39652. * * The parameter `url` sets the URL of the height map image resource.
  39653. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39654. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39655. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39656. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39657. * * 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.
  39658. * * 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).
  39659. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39661. * @param name defines the name of the mesh
  39662. * @param url defines the url to the height map
  39663. * @param options defines the options used to create the mesh
  39664. * @param scene defines the hosting scene
  39665. * @returns the ground mesh
  39666. * @see https://doc.babylonjs.com/babylon101/height_map
  39667. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39668. */
  39669. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39670. width?: number;
  39671. height?: number;
  39672. subdivisions?: number;
  39673. minHeight?: number;
  39674. maxHeight?: number;
  39675. colorFilter?: Color3;
  39676. alphaFilter?: number;
  39677. updatable?: boolean;
  39678. onReady?: (mesh: GroundMesh) => void;
  39679. }, scene: Scene): GroundMesh;
  39680. }
  39681. }
  39682. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39683. import { Vector4 } from "babylonjs/Maths/math";
  39684. import { Mesh } from "babylonjs/Meshes/mesh";
  39685. /**
  39686. * Class containing static functions to help procedurally build meshes
  39687. */
  39688. export class TorusBuilder {
  39689. /**
  39690. * Creates a torus mesh
  39691. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39692. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39693. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39695. * * If you create a double-sided mesh, you can choose what parts of 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
  39696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39697. * @param name defines the name of the mesh
  39698. * @param options defines the options used to create the mesh
  39699. * @param scene defines the hosting scene
  39700. * @returns the torus mesh
  39701. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39702. */
  39703. static CreateTorus(name: string, options: {
  39704. diameter?: number;
  39705. thickness?: number;
  39706. tessellation?: number;
  39707. updatable?: boolean;
  39708. sideOrientation?: number;
  39709. frontUVs?: Vector4;
  39710. backUVs?: Vector4;
  39711. }, scene: any): Mesh;
  39712. }
  39713. }
  39714. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39715. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39716. import { Mesh } from "babylonjs/Meshes/mesh";
  39717. /**
  39718. * Class containing static functions to help procedurally build meshes
  39719. */
  39720. export class CylinderBuilder {
  39721. /**
  39722. * Creates a cylinder or a cone mesh
  39723. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39724. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39725. * * 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.
  39726. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39727. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39728. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39729. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39730. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39731. * * 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).
  39732. * * 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
  39733. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39734. * * 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
  39735. * * 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.
  39736. * * If `enclose` is false, a ring surface is one element.
  39737. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39738. * * 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
  39739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39740. * * If you create a double-sided mesh, you can choose what parts of 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
  39741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39742. * @param name defines the name of the mesh
  39743. * @param options defines the options used to create the mesh
  39744. * @param scene defines the hosting scene
  39745. * @returns the cylinder mesh
  39746. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39747. */
  39748. static CreateCylinder(name: string, options: {
  39749. height?: number;
  39750. diameterTop?: number;
  39751. diameterBottom?: number;
  39752. diameter?: number;
  39753. tessellation?: number;
  39754. subdivisions?: number;
  39755. arc?: number;
  39756. faceColors?: Color4[];
  39757. faceUV?: Vector4[];
  39758. updatable?: boolean;
  39759. hasRings?: boolean;
  39760. enclose?: boolean;
  39761. sideOrientation?: number;
  39762. frontUVs?: Vector4;
  39763. backUVs?: Vector4;
  39764. }, scene: any): Mesh;
  39765. }
  39766. }
  39767. declare module "babylonjs/Gamepads/gamepadManager" {
  39768. import { Observable } from "babylonjs/Misc/observable";
  39769. import { Nullable } from "babylonjs/types";
  39770. import { Scene } from "babylonjs/scene";
  39771. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39772. /**
  39773. * Manager for handling gamepads
  39774. */
  39775. export class GamepadManager {
  39776. private _scene?;
  39777. private _babylonGamepads;
  39778. private _oneGamepadConnected;
  39779. /** @hidden */
  39780. _isMonitoring: boolean;
  39781. private _gamepadEventSupported;
  39782. private _gamepadSupport;
  39783. /**
  39784. * observable to be triggered when the gamepad controller has been connected
  39785. */
  39786. onGamepadConnectedObservable: Observable<Gamepad>;
  39787. /**
  39788. * observable to be triggered when the gamepad controller has been disconnected
  39789. */
  39790. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39791. private _onGamepadConnectedEvent;
  39792. private _onGamepadDisconnectedEvent;
  39793. /**
  39794. * Initializes the gamepad manager
  39795. * @param _scene BabylonJS scene
  39796. */
  39797. constructor(_scene?: Scene | undefined);
  39798. /**
  39799. * The gamepads in the game pad manager
  39800. */
  39801. readonly gamepads: Gamepad[];
  39802. /**
  39803. * Get the gamepad controllers based on type
  39804. * @param type The type of gamepad controller
  39805. * @returns Nullable gamepad
  39806. */
  39807. getGamepadByType(type?: number): Nullable<Gamepad>;
  39808. /**
  39809. * Disposes the gamepad manager
  39810. */
  39811. dispose(): void;
  39812. private _addNewGamepad;
  39813. private _startMonitoringGamepads;
  39814. private _stopMonitoringGamepads;
  39815. /** @hidden */
  39816. _checkGamepadsStatus(): void;
  39817. private _updateGamepadObjects;
  39818. }
  39819. }
  39820. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39821. import { Nullable } from "babylonjs/types";
  39822. import { Scene } from "babylonjs/scene";
  39823. import { ISceneComponent } from "babylonjs/sceneComponent";
  39824. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39825. module "babylonjs/scene" {
  39826. interface Scene {
  39827. /** @hidden */
  39828. _gamepadManager: Nullable<GamepadManager>;
  39829. /**
  39830. * Gets the gamepad manager associated with the scene
  39831. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39832. */
  39833. gamepadManager: GamepadManager;
  39834. }
  39835. }
  39836. module "babylonjs/Cameras/freeCameraInputsManager" {
  39837. /**
  39838. * Interface representing a free camera inputs manager
  39839. */
  39840. interface FreeCameraInputsManager {
  39841. /**
  39842. * Adds gamepad input support to the FreeCameraInputsManager.
  39843. * @returns the FreeCameraInputsManager
  39844. */
  39845. addGamepad(): FreeCameraInputsManager;
  39846. }
  39847. }
  39848. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39849. /**
  39850. * Interface representing an arc rotate camera inputs manager
  39851. */
  39852. interface ArcRotateCameraInputsManager {
  39853. /**
  39854. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39855. * @returns the camera inputs manager
  39856. */
  39857. addGamepad(): ArcRotateCameraInputsManager;
  39858. }
  39859. }
  39860. /**
  39861. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39862. */
  39863. export class GamepadSystemSceneComponent implements ISceneComponent {
  39864. /**
  39865. * The component name helpfull to identify the component in the list of scene components.
  39866. */
  39867. readonly name: string;
  39868. /**
  39869. * The scene the component belongs to.
  39870. */
  39871. scene: Scene;
  39872. /**
  39873. * Creates a new instance of the component for the given scene
  39874. * @param scene Defines the scene to register the component in
  39875. */
  39876. constructor(scene: Scene);
  39877. /**
  39878. * Registers the component in a given scene
  39879. */
  39880. register(): void;
  39881. /**
  39882. * Rebuilds the elements related to this component in case of
  39883. * context lost for instance.
  39884. */
  39885. rebuild(): void;
  39886. /**
  39887. * Disposes the component and the associated ressources
  39888. */
  39889. dispose(): void;
  39890. private _beforeCameraUpdate;
  39891. }
  39892. }
  39893. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39894. import { Observable } from "babylonjs/Misc/observable";
  39895. import { Nullable } from "babylonjs/types";
  39896. import { Camera } from "babylonjs/Cameras/camera";
  39897. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39898. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39899. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39900. import { Scene } from "babylonjs/scene";
  39901. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39902. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39904. import { Mesh } from "babylonjs/Meshes/mesh";
  39905. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39906. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39907. import "babylonjs/Meshes/Builders/groundBuilder";
  39908. import "babylonjs/Meshes/Builders/torusBuilder";
  39909. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39910. import "babylonjs/Gamepads/gamepadSceneComponent";
  39911. import "babylonjs/Animations/animatable";
  39912. /**
  39913. * Options to modify the vr teleportation behavior.
  39914. */
  39915. export interface VRTeleportationOptions {
  39916. /**
  39917. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39918. */
  39919. floorMeshName?: string;
  39920. /**
  39921. * A list of meshes to be used as the teleportation floor. (default: empty)
  39922. */
  39923. floorMeshes?: Mesh[];
  39924. }
  39925. /**
  39926. * Options to modify the vr experience helper's behavior.
  39927. */
  39928. export interface VRExperienceHelperOptions extends WebVROptions {
  39929. /**
  39930. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39931. */
  39932. createDeviceOrientationCamera?: boolean;
  39933. /**
  39934. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39935. */
  39936. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39937. /**
  39938. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39939. */
  39940. laserToggle?: boolean;
  39941. /**
  39942. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39943. */
  39944. floorMeshes?: Mesh[];
  39945. /**
  39946. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39947. */
  39948. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39949. }
  39950. /**
  39951. * Event containing information after VR has been entered
  39952. */
  39953. export class OnAfterEnteringVRObservableEvent {
  39954. /**
  39955. * If entering vr was successful
  39956. */
  39957. success: boolean;
  39958. }
  39959. /**
  39960. * Helps to quickly add VR support to an existing scene.
  39961. * See http://doc.babylonjs.com/how_to/webvr_helper
  39962. */
  39963. export class VRExperienceHelper {
  39964. /** Options to modify the vr experience helper's behavior. */
  39965. webVROptions: VRExperienceHelperOptions;
  39966. private _scene;
  39967. private _position;
  39968. private _btnVR;
  39969. private _btnVRDisplayed;
  39970. private _webVRsupported;
  39971. private _webVRready;
  39972. private _webVRrequesting;
  39973. private _webVRpresenting;
  39974. private _hasEnteredVR;
  39975. private _fullscreenVRpresenting;
  39976. private _canvas;
  39977. private _webVRCamera;
  39978. private _vrDeviceOrientationCamera;
  39979. private _deviceOrientationCamera;
  39980. private _existingCamera;
  39981. private _onKeyDown;
  39982. private _onVrDisplayPresentChange;
  39983. private _onVRDisplayChanged;
  39984. private _onVRRequestPresentStart;
  39985. private _onVRRequestPresentComplete;
  39986. /**
  39987. * Observable raised right before entering VR.
  39988. */
  39989. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39990. /**
  39991. * Observable raised when entering VR has completed.
  39992. */
  39993. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39994. /**
  39995. * Observable raised when exiting VR.
  39996. */
  39997. onExitingVRObservable: Observable<VRExperienceHelper>;
  39998. /**
  39999. * Observable raised when controller mesh is loaded.
  40000. */
  40001. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40002. /** Return this.onEnteringVRObservable
  40003. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40004. */
  40005. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40006. /** Return this.onExitingVRObservable
  40007. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40008. */
  40009. readonly onExitingVR: Observable<VRExperienceHelper>;
  40010. /** Return this.onControllerMeshLoadedObservable
  40011. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40012. */
  40013. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40014. private _rayLength;
  40015. private _useCustomVRButton;
  40016. private _teleportationRequested;
  40017. private _teleportActive;
  40018. private _floorMeshName;
  40019. private _floorMeshesCollection;
  40020. private _rotationAllowed;
  40021. private _teleportBackwardsVector;
  40022. private _teleportationTarget;
  40023. private _isDefaultTeleportationTarget;
  40024. private _postProcessMove;
  40025. private _teleportationFillColor;
  40026. private _teleportationBorderColor;
  40027. private _rotationAngle;
  40028. private _haloCenter;
  40029. private _cameraGazer;
  40030. private _padSensibilityUp;
  40031. private _padSensibilityDown;
  40032. private _leftController;
  40033. private _rightController;
  40034. /**
  40035. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40036. */
  40037. onNewMeshSelected: Observable<AbstractMesh>;
  40038. /**
  40039. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40040. */
  40041. onNewMeshPicked: Observable<PickingInfo>;
  40042. private _circleEase;
  40043. /**
  40044. * Observable raised before camera teleportation
  40045. */
  40046. onBeforeCameraTeleport: Observable<Vector3>;
  40047. /**
  40048. * Observable raised after camera teleportation
  40049. */
  40050. onAfterCameraTeleport: Observable<Vector3>;
  40051. /**
  40052. * Observable raised when current selected mesh gets unselected
  40053. */
  40054. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40055. private _raySelectionPredicate;
  40056. /**
  40057. * To be optionaly changed by user to define custom ray selection
  40058. */
  40059. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40060. /**
  40061. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40062. */
  40063. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40064. /**
  40065. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40066. */
  40067. teleportationEnabled: boolean;
  40068. private _defaultHeight;
  40069. private _teleportationInitialized;
  40070. private _interactionsEnabled;
  40071. private _interactionsRequested;
  40072. private _displayGaze;
  40073. private _displayLaserPointer;
  40074. /**
  40075. * The mesh used to display where the user is going to teleport.
  40076. */
  40077. /**
  40078. * Sets the mesh to be used to display where the user is going to teleport.
  40079. */
  40080. teleportationTarget: Mesh;
  40081. /**
  40082. * 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
  40083. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40084. * See http://doc.babylonjs.com/resources/baking_transformations
  40085. */
  40086. gazeTrackerMesh: Mesh;
  40087. /**
  40088. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40089. */
  40090. updateGazeTrackerScale: boolean;
  40091. /**
  40092. * If the gaze trackers color should be updated when selecting meshes
  40093. */
  40094. updateGazeTrackerColor: boolean;
  40095. /**
  40096. * The gaze tracking mesh corresponding to the left controller
  40097. */
  40098. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40099. /**
  40100. * The gaze tracking mesh corresponding to the right controller
  40101. */
  40102. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40103. /**
  40104. * If the ray of the gaze should be displayed.
  40105. */
  40106. /**
  40107. * Sets if the ray of the gaze should be displayed.
  40108. */
  40109. displayGaze: boolean;
  40110. /**
  40111. * If the ray of the LaserPointer should be displayed.
  40112. */
  40113. /**
  40114. * Sets if the ray of the LaserPointer should be displayed.
  40115. */
  40116. displayLaserPointer: boolean;
  40117. /**
  40118. * The deviceOrientationCamera used as the camera when not in VR.
  40119. */
  40120. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40121. /**
  40122. * Based on the current WebVR support, returns the current VR camera used.
  40123. */
  40124. readonly currentVRCamera: Nullable<Camera>;
  40125. /**
  40126. * The webVRCamera which is used when in VR.
  40127. */
  40128. readonly webVRCamera: WebVRFreeCamera;
  40129. /**
  40130. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40131. */
  40132. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40133. private readonly _teleportationRequestInitiated;
  40134. /**
  40135. * Defines wether or not Pointer lock should be requested when switching to
  40136. * full screen.
  40137. */
  40138. requestPointerLockOnFullScreen: boolean;
  40139. /**
  40140. * Instantiates a VRExperienceHelper.
  40141. * Helps to quickly add VR support to an existing scene.
  40142. * @param scene The scene the VRExperienceHelper belongs to.
  40143. * @param webVROptions Options to modify the vr experience helper's behavior.
  40144. */
  40145. constructor(scene: Scene,
  40146. /** Options to modify the vr experience helper's behavior. */
  40147. webVROptions?: VRExperienceHelperOptions);
  40148. private _onDefaultMeshLoaded;
  40149. private _onResize;
  40150. private _onFullscreenChange;
  40151. /**
  40152. * Gets a value indicating if we are currently in VR mode.
  40153. */
  40154. readonly isInVRMode: boolean;
  40155. private onVrDisplayPresentChange;
  40156. private onVRDisplayChanged;
  40157. private moveButtonToBottomRight;
  40158. private displayVRButton;
  40159. private updateButtonVisibility;
  40160. private _cachedAngularSensibility;
  40161. /**
  40162. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40163. * Otherwise, will use the fullscreen API.
  40164. */
  40165. enterVR(): void;
  40166. /**
  40167. * Attempt to exit VR, or fullscreen.
  40168. */
  40169. exitVR(): void;
  40170. /**
  40171. * The position of the vr experience helper.
  40172. */
  40173. /**
  40174. * Sets the position of the vr experience helper.
  40175. */
  40176. position: Vector3;
  40177. /**
  40178. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40179. */
  40180. enableInteractions(): void;
  40181. private readonly _noControllerIsActive;
  40182. private beforeRender;
  40183. private _isTeleportationFloor;
  40184. /**
  40185. * Adds a floor mesh to be used for teleportation.
  40186. * @param floorMesh the mesh to be used for teleportation.
  40187. */
  40188. addFloorMesh(floorMesh: Mesh): void;
  40189. /**
  40190. * Removes a floor mesh from being used for teleportation.
  40191. * @param floorMesh the mesh to be removed.
  40192. */
  40193. removeFloorMesh(floorMesh: Mesh): void;
  40194. /**
  40195. * Enables interactions and teleportation using the VR controllers and gaze.
  40196. * @param vrTeleportationOptions options to modify teleportation behavior.
  40197. */
  40198. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40199. private _onNewGamepadConnected;
  40200. private _tryEnableInteractionOnController;
  40201. private _onNewGamepadDisconnected;
  40202. private _enableInteractionOnController;
  40203. private _checkTeleportWithRay;
  40204. private _checkRotate;
  40205. private _checkTeleportBackwards;
  40206. private _enableTeleportationOnController;
  40207. private _createTeleportationCircles;
  40208. private _displayTeleportationTarget;
  40209. private _hideTeleportationTarget;
  40210. private _rotateCamera;
  40211. private _moveTeleportationSelectorTo;
  40212. private _workingVector;
  40213. private _workingQuaternion;
  40214. private _workingMatrix;
  40215. /**
  40216. * Teleports the users feet to the desired location
  40217. * @param location The location where the user's feet should be placed
  40218. */
  40219. teleportCamera(location: Vector3): void;
  40220. private _convertNormalToDirectionOfRay;
  40221. private _castRayAndSelectObject;
  40222. private _notifySelectedMeshUnselected;
  40223. /**
  40224. * Sets the color of the laser ray from the vr controllers.
  40225. * @param color new color for the ray.
  40226. */
  40227. changeLaserColor(color: Color3): void;
  40228. /**
  40229. * Sets the color of the ray from the vr headsets gaze.
  40230. * @param color new color for the ray.
  40231. */
  40232. changeGazeColor(color: Color3): void;
  40233. /**
  40234. * Exits VR and disposes of the vr experience helper
  40235. */
  40236. dispose(): void;
  40237. /**
  40238. * Gets the name of the VRExperienceHelper class
  40239. * @returns "VRExperienceHelper"
  40240. */
  40241. getClassName(): string;
  40242. }
  40243. }
  40244. declare module "babylonjs/Cameras/VR/index" {
  40245. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40246. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40247. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40248. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40249. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40250. export * from "babylonjs/Cameras/VR/webVRCamera";
  40251. }
  40252. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40253. import { Observable } from "babylonjs/Misc/observable";
  40254. import { Nullable } from "babylonjs/types";
  40255. import { IDisposable, Scene } from "babylonjs/scene";
  40256. import { Vector3 } from "babylonjs/Maths/math";
  40257. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40258. import { Ray } from "babylonjs/Culling/ray";
  40259. /**
  40260. * Manages an XRSession
  40261. * @see https://doc.babylonjs.com/how_to/webxr
  40262. */
  40263. export class WebXRSessionManager implements IDisposable {
  40264. private scene;
  40265. /**
  40266. * Fires every time a new xrFrame arrives which can be used to update the camera
  40267. */
  40268. onXRFrameObservable: Observable<any>;
  40269. /**
  40270. * Fires when the xr session is ended either by the device or manually done
  40271. */
  40272. onXRSessionEnded: Observable<any>;
  40273. /** @hidden */
  40274. _xrSession: XRSession;
  40275. /** @hidden */
  40276. _frameOfReference: XRFrameOfReference;
  40277. /** @hidden */
  40278. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40279. /** @hidden */
  40280. _currentXRFrame: Nullable<XRFrame>;
  40281. private _xrNavigator;
  40282. private _xrDevice;
  40283. private _tmpMatrix;
  40284. /**
  40285. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40286. * @param scene The scene which the session should be created for
  40287. */
  40288. constructor(scene: Scene);
  40289. /**
  40290. * Initializes the manager
  40291. * After initialization enterXR can be called to start an XR session
  40292. * @returns Promise which resolves after it is initialized
  40293. */
  40294. initializeAsync(): Promise<void>;
  40295. /**
  40296. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40297. * @param sessionCreationOptions xr options to create the session with
  40298. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40299. * @returns Promise which resolves after it enters XR
  40300. */
  40301. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40302. /**
  40303. * Stops the xrSession and restores the renderloop
  40304. * @returns Promise which resolves after it exits XR
  40305. */
  40306. exitXRAsync(): Promise<void>;
  40307. /**
  40308. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40309. * @param ray ray to cast into the environment
  40310. * @returns Promise which resolves with a collision point in the environment if it exists
  40311. */
  40312. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40313. /**
  40314. * Checks if a session would be supported for the creation options specified
  40315. * @param options creation options to check if they are supported
  40316. * @returns true if supported
  40317. */
  40318. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40319. /**
  40320. * @hidden
  40321. * Converts the render layer of xrSession to a render target
  40322. * @param session session to create render target for
  40323. * @param scene scene the new render target should be created for
  40324. */
  40325. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40326. /**
  40327. * Disposes of the session manager
  40328. */
  40329. dispose(): void;
  40330. }
  40331. }
  40332. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40333. import { Scene } from "babylonjs/scene";
  40334. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40335. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40336. /**
  40337. * WebXR Camera which holds the views for the xrSession
  40338. * @see https://doc.babylonjs.com/how_to/webxr
  40339. */
  40340. export class WebXRCamera extends FreeCamera {
  40341. private static _TmpMatrix;
  40342. /**
  40343. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40344. * @param name the name of the camera
  40345. * @param scene the scene to add the camera to
  40346. */
  40347. constructor(name: string, scene: Scene);
  40348. private _updateNumberOfRigCameras;
  40349. /** @hidden */
  40350. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40351. /**
  40352. * Updates the cameras position from the current pose information of the XR session
  40353. * @param xrSessionManager the session containing pose information
  40354. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40355. */
  40356. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40357. }
  40358. }
  40359. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40360. import { Nullable } from "babylonjs/types";
  40361. import { Observable } from "babylonjs/Misc/observable";
  40362. import { IDisposable, Scene } from "babylonjs/scene";
  40363. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40365. import { Ray } from "babylonjs/Culling/ray";
  40366. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40367. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40368. /**
  40369. * States of the webXR experience
  40370. */
  40371. export enum WebXRState {
  40372. /**
  40373. * Transitioning to being in XR mode
  40374. */
  40375. ENTERING_XR = 0,
  40376. /**
  40377. * Transitioning to non XR mode
  40378. */
  40379. EXITING_XR = 1,
  40380. /**
  40381. * In XR mode and presenting
  40382. */
  40383. IN_XR = 2,
  40384. /**
  40385. * Not entered XR mode
  40386. */
  40387. NOT_IN_XR = 3
  40388. }
  40389. /**
  40390. * Helper class used to enable XR
  40391. * @see https://doc.babylonjs.com/how_to/webxr
  40392. */
  40393. export class WebXRExperienceHelper implements IDisposable {
  40394. private scene;
  40395. /**
  40396. * 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
  40397. */
  40398. container: AbstractMesh;
  40399. /**
  40400. * Camera used to render xr content
  40401. */
  40402. camera: WebXRCamera;
  40403. /**
  40404. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40405. */
  40406. state: WebXRState;
  40407. private _setState;
  40408. private static _TmpVector;
  40409. /**
  40410. * Fires when the state of the experience helper has changed
  40411. */
  40412. onStateChangedObservable: Observable<WebXRState>;
  40413. /** @hidden */
  40414. _sessionManager: WebXRSessionManager;
  40415. private _nonVRCamera;
  40416. private _originalSceneAutoClear;
  40417. private _supported;
  40418. /**
  40419. * Creates the experience helper
  40420. * @param scene the scene to attach the experience helper to
  40421. * @returns a promise for the experience helper
  40422. */
  40423. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40424. /**
  40425. * Creates a WebXRExperienceHelper
  40426. * @param scene The scene the helper should be created in
  40427. */
  40428. private constructor();
  40429. /**
  40430. * Exits XR mode and returns the scene to its original state
  40431. * @returns promise that resolves after xr mode has exited
  40432. */
  40433. exitXRAsync(): Promise<void>;
  40434. /**
  40435. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40436. * @param sessionCreationOptions options for the XR session
  40437. * @param frameOfReference frame of reference of the XR session
  40438. * @returns promise that resolves after xr mode has entered
  40439. */
  40440. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40441. /**
  40442. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40443. * @param ray ray to cast into the environment
  40444. * @returns Promise which resolves with a collision point in the environment if it exists
  40445. */
  40446. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40447. /**
  40448. * Updates the global position of the camera by moving the camera's container
  40449. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40450. * @param position The desired global position of the camera
  40451. */
  40452. setPositionOfCameraUsingContainer(position: Vector3): void;
  40453. /**
  40454. * Rotates the xr camera by rotating the camera's container around the camera's position
  40455. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40456. * @param rotation the desired quaternion rotation to apply to the camera
  40457. */
  40458. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40459. /**
  40460. * Checks if the creation options are supported by the xr session
  40461. * @param options creation options
  40462. * @returns true if supported
  40463. */
  40464. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40465. /**
  40466. * Disposes of the experience helper
  40467. */
  40468. dispose(): void;
  40469. }
  40470. }
  40471. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40472. import { Nullable } from "babylonjs/types";
  40473. import { Observable } from "babylonjs/Misc/observable";
  40474. import { IDisposable, Scene } from "babylonjs/scene";
  40475. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40476. /**
  40477. * Button which can be used to enter a different mode of XR
  40478. */
  40479. export class WebXREnterExitUIButton {
  40480. /** button element */
  40481. element: HTMLElement;
  40482. /** XR initialization options for the button */
  40483. initializationOptions: XRSessionCreationOptions;
  40484. /**
  40485. * Creates a WebXREnterExitUIButton
  40486. * @param element button element
  40487. * @param initializationOptions XR initialization options for the button
  40488. */
  40489. constructor(
  40490. /** button element */
  40491. element: HTMLElement,
  40492. /** XR initialization options for the button */
  40493. initializationOptions: XRSessionCreationOptions);
  40494. /**
  40495. * Overwritable function which can be used to update the button's visuals when the state changes
  40496. * @param activeButton the current active button in the UI
  40497. */
  40498. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40499. }
  40500. /**
  40501. * Options to create the webXR UI
  40502. */
  40503. export class WebXREnterExitUIOptions {
  40504. /**
  40505. * Context to enter xr with
  40506. */
  40507. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40508. /**
  40509. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40510. */
  40511. customButtons?: Array<WebXREnterExitUIButton>;
  40512. }
  40513. /**
  40514. * UI to allow the user to enter/exit XR mode
  40515. */
  40516. export class WebXREnterExitUI implements IDisposable {
  40517. private scene;
  40518. private _overlay;
  40519. private _buttons;
  40520. private _activeButton;
  40521. /**
  40522. * Fired every time the active button is changed.
  40523. *
  40524. * When xr is entered via a button that launches xr that button will be the callback parameter
  40525. *
  40526. * When exiting xr the callback parameter will be null)
  40527. */
  40528. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40529. /**
  40530. * Creates UI to allow the user to enter/exit XR mode
  40531. * @param scene the scene to add the ui to
  40532. * @param helper the xr experience helper to enter/exit xr with
  40533. * @param options options to configure the UI
  40534. * @returns the created ui
  40535. */
  40536. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40537. private constructor();
  40538. private _updateButtons;
  40539. /**
  40540. * Disposes of the object
  40541. */
  40542. dispose(): void;
  40543. }
  40544. }
  40545. declare module "babylonjs/Cameras/XR/webXRInput" {
  40546. import { IDisposable, Scene } from "babylonjs/scene";
  40547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40548. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40549. /**
  40550. * Represents an XR input
  40551. */
  40552. export class WebXRController {
  40553. /**
  40554. * 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
  40555. */
  40556. grip?: AbstractMesh;
  40557. /**
  40558. * Pointer which can be used to select objects or attach a visible laser to
  40559. */
  40560. pointer: AbstractMesh;
  40561. /**
  40562. * Creates the controller
  40563. * @see https://doc.babylonjs.com/how_to/webxr
  40564. * @param scene the scene which the controller should be associated to
  40565. */
  40566. constructor(scene: Scene);
  40567. /**
  40568. * Disposes of the object
  40569. */
  40570. dispose(): void;
  40571. }
  40572. /**
  40573. * XR input used to track XR inputs such as controllers/rays
  40574. */
  40575. export class WebXRInput implements IDisposable {
  40576. private helper;
  40577. /**
  40578. * XR controllers being tracked
  40579. */
  40580. controllers: Array<WebXRController>;
  40581. private _tmpMatrix;
  40582. private _frameObserver;
  40583. /**
  40584. * Initializes the WebXRInput
  40585. * @param helper experience helper which the input should be created for
  40586. */
  40587. constructor(helper: WebXRExperienceHelper);
  40588. /**
  40589. * Disposes of the object
  40590. */
  40591. dispose(): void;
  40592. }
  40593. }
  40594. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40595. import { Nullable } from "babylonjs/types";
  40596. import { IDisposable } from "babylonjs/scene";
  40597. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40598. /**
  40599. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40600. */
  40601. export class WebXRManagedOutputCanvas implements IDisposable {
  40602. private _canvas;
  40603. /**
  40604. * xrpresent context of the canvas which can be used to display/mirror xr content
  40605. */
  40606. canvasContext: Nullable<WebGLRenderingContext>;
  40607. /**
  40608. * Initializes the canvas to be added/removed upon entering/exiting xr
  40609. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40610. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40611. */
  40612. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40613. /**
  40614. * Disposes of the object
  40615. */
  40616. dispose(): void;
  40617. private _setManagedOutputCanvas;
  40618. private _addCanvas;
  40619. private _removeCanvas;
  40620. }
  40621. }
  40622. declare module "babylonjs/Cameras/XR/index" {
  40623. export * from "babylonjs/Cameras/XR/webXRCamera";
  40624. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40625. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40626. export * from "babylonjs/Cameras/XR/webXRInput";
  40627. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40628. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40629. }
  40630. declare module "babylonjs/Cameras/RigModes/index" {
  40631. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40632. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40633. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40634. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40635. }
  40636. declare module "babylonjs/Cameras/index" {
  40637. export * from "babylonjs/Cameras/Inputs/index";
  40638. export * from "babylonjs/Cameras/cameraInputsManager";
  40639. export * from "babylonjs/Cameras/camera";
  40640. export * from "babylonjs/Cameras/targetCamera";
  40641. export * from "babylonjs/Cameras/freeCamera";
  40642. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40643. export * from "babylonjs/Cameras/touchCamera";
  40644. export * from "babylonjs/Cameras/arcRotateCamera";
  40645. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40646. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40647. export * from "babylonjs/Cameras/flyCamera";
  40648. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40649. export * from "babylonjs/Cameras/followCamera";
  40650. export * from "babylonjs/Cameras/gamepadCamera";
  40651. export * from "babylonjs/Cameras/Stereoscopic/index";
  40652. export * from "babylonjs/Cameras/universalCamera";
  40653. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40654. export * from "babylonjs/Cameras/VR/index";
  40655. export * from "babylonjs/Cameras/XR/index";
  40656. export * from "babylonjs/Cameras/RigModes/index";
  40657. }
  40658. declare module "babylonjs/Collisions/index" {
  40659. export * from "babylonjs/Collisions/collider";
  40660. export * from "babylonjs/Collisions/collisionCoordinator";
  40661. export * from "babylonjs/Collisions/pickingInfo";
  40662. export * from "babylonjs/Collisions/intersectionInfo";
  40663. }
  40664. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40665. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40666. import { Vector3, Plane } from "babylonjs/Maths/math";
  40667. import { Ray } from "babylonjs/Culling/ray";
  40668. /**
  40669. * Contains an array of blocks representing the octree
  40670. */
  40671. export interface IOctreeContainer<T> {
  40672. /**
  40673. * Blocks within the octree
  40674. */
  40675. blocks: Array<OctreeBlock<T>>;
  40676. }
  40677. /**
  40678. * Class used to store a cell in an octree
  40679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40680. */
  40681. export class OctreeBlock<T> {
  40682. /**
  40683. * Gets the content of the current block
  40684. */
  40685. entries: T[];
  40686. /**
  40687. * Gets the list of block children
  40688. */
  40689. blocks: Array<OctreeBlock<T>>;
  40690. private _depth;
  40691. private _maxDepth;
  40692. private _capacity;
  40693. private _minPoint;
  40694. private _maxPoint;
  40695. private _boundingVectors;
  40696. private _creationFunc;
  40697. /**
  40698. * Creates a new block
  40699. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40700. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40701. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40702. * @param depth defines the current depth of this block in the octree
  40703. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40704. * @param creationFunc defines a callback to call when an element is added to the block
  40705. */
  40706. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40707. /**
  40708. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40709. */
  40710. readonly capacity: number;
  40711. /**
  40712. * Gets the minimum vector (in world space) of the block's bounding box
  40713. */
  40714. readonly minPoint: Vector3;
  40715. /**
  40716. * Gets the maximum vector (in world space) of the block's bounding box
  40717. */
  40718. readonly maxPoint: Vector3;
  40719. /**
  40720. * Add a new element to this block
  40721. * @param entry defines the element to add
  40722. */
  40723. addEntry(entry: T): void;
  40724. /**
  40725. * Remove an element from this block
  40726. * @param entry defines the element to remove
  40727. */
  40728. removeEntry(entry: T): void;
  40729. /**
  40730. * Add an array of elements to this block
  40731. * @param entries defines the array of elements to add
  40732. */
  40733. addEntries(entries: T[]): void;
  40734. /**
  40735. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40736. * @param frustumPlanes defines the frustum planes to test
  40737. * @param selection defines the array to store current content if selection is positive
  40738. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40739. */
  40740. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40741. /**
  40742. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40743. * @param sphereCenter defines the bounding sphere center
  40744. * @param sphereRadius defines the bounding sphere radius
  40745. * @param selection defines the array to store current content if selection is positive
  40746. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40747. */
  40748. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40749. /**
  40750. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40751. * @param ray defines the ray to test with
  40752. * @param selection defines the array to store current content if selection is positive
  40753. */
  40754. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40755. /**
  40756. * Subdivide the content into child blocks (this block will then be empty)
  40757. */
  40758. createInnerBlocks(): void;
  40759. /**
  40760. * @hidden
  40761. */
  40762. 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;
  40763. }
  40764. }
  40765. declare module "babylonjs/Culling/Octrees/octree" {
  40766. import { SmartArray } from "babylonjs/Misc/smartArray";
  40767. import { Vector3, Plane } from "babylonjs/Maths/math";
  40768. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40770. import { Ray } from "babylonjs/Culling/ray";
  40771. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40772. /**
  40773. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40774. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40775. */
  40776. export class Octree<T> {
  40777. /** 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.) */
  40778. maxDepth: number;
  40779. /**
  40780. * Blocks within the octree containing objects
  40781. */
  40782. blocks: Array<OctreeBlock<T>>;
  40783. /**
  40784. * Content stored in the octree
  40785. */
  40786. dynamicContent: T[];
  40787. private _maxBlockCapacity;
  40788. private _selectionContent;
  40789. private _creationFunc;
  40790. /**
  40791. * Creates a octree
  40792. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40793. * @param creationFunc function to be used to instatiate the octree
  40794. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40795. * @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.)
  40796. */
  40797. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40798. /** 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.) */
  40799. maxDepth?: number);
  40800. /**
  40801. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40802. * @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);
  40803. * @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);
  40804. * @param entries meshes to be added to the octree blocks
  40805. */
  40806. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40807. /**
  40808. * Adds a mesh to the octree
  40809. * @param entry Mesh to add to the octree
  40810. */
  40811. addMesh(entry: T): void;
  40812. /**
  40813. * Remove an element from the octree
  40814. * @param entry defines the element to remove
  40815. */
  40816. removeMesh(entry: T): void;
  40817. /**
  40818. * Selects an array of meshes within the frustum
  40819. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40820. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40821. * @returns array of meshes within the frustum
  40822. */
  40823. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40824. /**
  40825. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40826. * @param sphereCenter defines the bounding sphere center
  40827. * @param sphereRadius defines the bounding sphere radius
  40828. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40829. * @returns an array of objects that intersect the sphere
  40830. */
  40831. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40832. /**
  40833. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40834. * @param ray defines the ray to test with
  40835. * @returns array of intersected objects
  40836. */
  40837. intersectsRay(ray: Ray): SmartArray<T>;
  40838. /**
  40839. * Adds a mesh into the octree block if it intersects the block
  40840. */
  40841. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40842. /**
  40843. * Adds a submesh into the octree block if it intersects the block
  40844. */
  40845. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40846. }
  40847. }
  40848. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40849. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40850. import { Scene } from "babylonjs/scene";
  40851. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40853. import { Ray } from "babylonjs/Culling/ray";
  40854. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40855. import { Collider } from "babylonjs/Collisions/collider";
  40856. module "babylonjs/scene" {
  40857. interface Scene {
  40858. /**
  40859. * @hidden
  40860. * Backing Filed
  40861. */
  40862. _selectionOctree: Octree<AbstractMesh>;
  40863. /**
  40864. * Gets the octree used to boost mesh selection (picking)
  40865. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40866. */
  40867. selectionOctree: Octree<AbstractMesh>;
  40868. /**
  40869. * Creates or updates the octree used to boost selection (picking)
  40870. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40871. * @param maxCapacity defines the maximum capacity per leaf
  40872. * @param maxDepth defines the maximum depth of the octree
  40873. * @returns an octree of AbstractMesh
  40874. */
  40875. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40876. }
  40877. }
  40878. module "babylonjs/Meshes/abstractMesh" {
  40879. interface AbstractMesh {
  40880. /**
  40881. * @hidden
  40882. * Backing Field
  40883. */
  40884. _submeshesOctree: Octree<SubMesh>;
  40885. /**
  40886. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40887. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40888. * @param maxCapacity defines the maximum size of each block (64 by default)
  40889. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40890. * @returns the new octree
  40891. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40892. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40893. */
  40894. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40895. }
  40896. }
  40897. /**
  40898. * Defines the octree scene component responsible to manage any octrees
  40899. * in a given scene.
  40900. */
  40901. export class OctreeSceneComponent {
  40902. /**
  40903. * The component name helpfull to identify the component in the list of scene components.
  40904. */
  40905. readonly name: string;
  40906. /**
  40907. * The scene the component belongs to.
  40908. */
  40909. scene: Scene;
  40910. /**
  40911. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40912. */
  40913. readonly checksIsEnabled: boolean;
  40914. /**
  40915. * Creates a new instance of the component for the given scene
  40916. * @param scene Defines the scene to register the component in
  40917. */
  40918. constructor(scene: Scene);
  40919. /**
  40920. * Registers the component in a given scene
  40921. */
  40922. register(): void;
  40923. /**
  40924. * Return the list of active meshes
  40925. * @returns the list of active meshes
  40926. */
  40927. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40928. /**
  40929. * Return the list of active sub meshes
  40930. * @param mesh The mesh to get the candidates sub meshes from
  40931. * @returns the list of active sub meshes
  40932. */
  40933. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40934. private _tempRay;
  40935. /**
  40936. * Return the list of sub meshes intersecting with a given local ray
  40937. * @param mesh defines the mesh to find the submesh for
  40938. * @param localRay defines the ray in local space
  40939. * @returns the list of intersecting sub meshes
  40940. */
  40941. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40942. /**
  40943. * Return the list of sub meshes colliding with a collider
  40944. * @param mesh defines the mesh to find the submesh for
  40945. * @param collider defines the collider to evaluate the collision against
  40946. * @returns the list of colliding sub meshes
  40947. */
  40948. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40949. /**
  40950. * Rebuilds the elements related to this component in case of
  40951. * context lost for instance.
  40952. */
  40953. rebuild(): void;
  40954. /**
  40955. * Disposes the component and the associated ressources.
  40956. */
  40957. dispose(): void;
  40958. }
  40959. }
  40960. declare module "babylonjs/Culling/Octrees/index" {
  40961. export * from "babylonjs/Culling/Octrees/octree";
  40962. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40963. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40964. }
  40965. declare module "babylonjs/Culling/index" {
  40966. export * from "babylonjs/Culling/boundingBox";
  40967. export * from "babylonjs/Culling/boundingInfo";
  40968. export * from "babylonjs/Culling/boundingSphere";
  40969. export * from "babylonjs/Culling/Octrees/index";
  40970. export * from "babylonjs/Culling/ray";
  40971. }
  40972. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40973. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40974. import { Nullable } from "babylonjs/types";
  40975. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  40976. import { Scene } from "babylonjs/scene";
  40977. /**
  40978. * Class containing static functions to help procedurally build meshes
  40979. */
  40980. export class LinesBuilder {
  40981. /**
  40982. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40983. * * 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
  40984. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40985. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40986. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40987. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40988. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40989. * * 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
  40990. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40992. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40993. * @param name defines the name of the new line system
  40994. * @param options defines the options used to create the line system
  40995. * @param scene defines the hosting scene
  40996. * @returns a new line system mesh
  40997. */
  40998. static CreateLineSystem(name: string, options: {
  40999. lines: Vector3[][];
  41000. updatable?: boolean;
  41001. instance?: Nullable<LinesMesh>;
  41002. colors?: Nullable<Color4[][]>;
  41003. useVertexAlpha?: boolean;
  41004. }, scene: Nullable<Scene>): LinesMesh;
  41005. /**
  41006. * Creates a line mesh
  41007. * 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
  41008. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41009. * * The parameter `points` is an array successive Vector3
  41010. * * 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
  41011. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41012. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41013. * * When updating an instance, remember that only point positions can change, not the number of points
  41014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41015. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41016. * @param name defines the name of the new line system
  41017. * @param options defines the options used to create the line system
  41018. * @param scene defines the hosting scene
  41019. * @returns a new line mesh
  41020. */
  41021. static CreateLines(name: string, options: {
  41022. points: Vector3[];
  41023. updatable?: boolean;
  41024. instance?: Nullable<LinesMesh>;
  41025. colors?: Color4[];
  41026. useVertexAlpha?: boolean;
  41027. }, scene?: Nullable<Scene>): LinesMesh;
  41028. /**
  41029. * Creates a dashed line mesh
  41030. * * 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
  41031. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41032. * * The parameter `points` is an array successive Vector3
  41033. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41034. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41035. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41036. * * 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
  41037. * * When updating an instance, remember that only point positions can change, not the number of points
  41038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41039. * @param name defines the name of the mesh
  41040. * @param options defines the options used to create the mesh
  41041. * @param scene defines the hosting scene
  41042. * @returns the dashed line mesh
  41043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41044. */
  41045. static CreateDashedLines(name: string, options: {
  41046. points: Vector3[];
  41047. dashSize?: number;
  41048. gapSize?: number;
  41049. dashNb?: number;
  41050. updatable?: boolean;
  41051. instance?: LinesMesh;
  41052. }, scene?: Nullable<Scene>): LinesMesh;
  41053. }
  41054. }
  41055. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41056. import { IDisposable, Scene } from "babylonjs/scene";
  41057. import { Nullable } from "babylonjs/types";
  41058. import { Observable } from "babylonjs/Misc/observable";
  41059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41060. /**
  41061. * Renders a layer on top of an existing scene
  41062. */
  41063. export class UtilityLayerRenderer implements IDisposable {
  41064. /** the original scene that will be rendered on top of */
  41065. originalScene: Scene;
  41066. private _pointerCaptures;
  41067. private _lastPointerEvents;
  41068. private static _DefaultUtilityLayer;
  41069. private static _DefaultKeepDepthUtilityLayer;
  41070. /**
  41071. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41072. */
  41073. pickUtilitySceneFirst: boolean;
  41074. /**
  41075. * 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)
  41076. */
  41077. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41078. /**
  41079. * 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)
  41080. */
  41081. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41082. /**
  41083. * The scene that is rendered on top of the original scene
  41084. */
  41085. utilityLayerScene: Scene;
  41086. /**
  41087. * If the utility layer should automatically be rendered on top of existing scene
  41088. */
  41089. shouldRender: boolean;
  41090. /**
  41091. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41092. */
  41093. onlyCheckPointerDownEvents: boolean;
  41094. /**
  41095. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41096. */
  41097. processAllEvents: boolean;
  41098. /**
  41099. * Observable raised when the pointer move from the utility layer scene to the main scene
  41100. */
  41101. onPointerOutObservable: Observable<number>;
  41102. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41103. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41104. private _afterRenderObserver;
  41105. private _sceneDisposeObserver;
  41106. private _originalPointerObserver;
  41107. /**
  41108. * Instantiates a UtilityLayerRenderer
  41109. * @param originalScene the original scene that will be rendered on top of
  41110. * @param handleEvents boolean indicating if the utility layer should handle events
  41111. */
  41112. constructor(
  41113. /** the original scene that will be rendered on top of */
  41114. originalScene: Scene, handleEvents?: boolean);
  41115. private _notifyObservers;
  41116. /**
  41117. * Renders the utility layers scene on top of the original scene
  41118. */
  41119. render(): void;
  41120. /**
  41121. * Disposes of the renderer
  41122. */
  41123. dispose(): void;
  41124. private _updateCamera;
  41125. }
  41126. }
  41127. declare module "babylonjs/Gizmos/gizmo" {
  41128. import { Nullable } from "babylonjs/types";
  41129. import { IDisposable } from "babylonjs/scene";
  41130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41131. import { Mesh } from "babylonjs/Meshes/mesh";
  41132. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41133. /**
  41134. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41135. */
  41136. export class Gizmo implements IDisposable {
  41137. /** The utility layer the gizmo will be added to */
  41138. gizmoLayer: UtilityLayerRenderer;
  41139. /**
  41140. * The root mesh of the gizmo
  41141. */
  41142. _rootMesh: Mesh;
  41143. private _attachedMesh;
  41144. /**
  41145. * Ratio for the scale of the gizmo (Default: 1)
  41146. */
  41147. scaleRatio: number;
  41148. private _tmpMatrix;
  41149. /**
  41150. * If a custom mesh has been set (Default: false)
  41151. */
  41152. protected _customMeshSet: boolean;
  41153. /**
  41154. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41155. * * When set, interactions will be enabled
  41156. */
  41157. attachedMesh: Nullable<AbstractMesh>;
  41158. /**
  41159. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41160. * @param mesh The mesh to replace the default mesh of the gizmo
  41161. */
  41162. setCustomMesh(mesh: Mesh): void;
  41163. /**
  41164. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41165. */
  41166. updateGizmoRotationToMatchAttachedMesh: boolean;
  41167. /**
  41168. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41169. */
  41170. updateGizmoPositionToMatchAttachedMesh: boolean;
  41171. /**
  41172. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41173. */
  41174. protected _updateScale: boolean;
  41175. protected _interactionsEnabled: boolean;
  41176. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41177. private _beforeRenderObserver;
  41178. /**
  41179. * Creates a gizmo
  41180. * @param gizmoLayer The utility layer the gizmo will be added to
  41181. */
  41182. constructor(
  41183. /** The utility layer the gizmo will be added to */
  41184. gizmoLayer?: UtilityLayerRenderer);
  41185. private _tempVector;
  41186. /**
  41187. * @hidden
  41188. * Updates the gizmo to match the attached mesh's position/rotation
  41189. */
  41190. protected _update(): void;
  41191. /**
  41192. * Disposes of the gizmo
  41193. */
  41194. dispose(): void;
  41195. }
  41196. }
  41197. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41198. import { Observable } from "babylonjs/Misc/observable";
  41199. import { Nullable } from "babylonjs/types";
  41200. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41201. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41203. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41204. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41205. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41206. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41207. import { Scene } from "babylonjs/scene";
  41208. /**
  41209. * Single axis drag gizmo
  41210. */
  41211. export class AxisDragGizmo extends Gizmo {
  41212. /**
  41213. * Drag behavior responsible for the gizmos dragging interactions
  41214. */
  41215. dragBehavior: PointerDragBehavior;
  41216. private _pointerObserver;
  41217. /**
  41218. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41219. */
  41220. snapDistance: number;
  41221. /**
  41222. * Event that fires each time the gizmo snaps to a new location.
  41223. * * snapDistance is the the change in distance
  41224. */
  41225. onSnapObservable: Observable<{
  41226. snapDistance: number;
  41227. }>;
  41228. /** @hidden */
  41229. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41230. /** @hidden */
  41231. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41232. /**
  41233. * Creates an AxisDragGizmo
  41234. * @param gizmoLayer The utility layer the gizmo will be added to
  41235. * @param dragAxis The axis which the gizmo will be able to drag on
  41236. * @param color The color of the gizmo
  41237. */
  41238. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41239. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41240. /**
  41241. * Disposes of the gizmo
  41242. */
  41243. dispose(): void;
  41244. }
  41245. }
  41246. declare module "babylonjs/Debug/axesViewer" {
  41247. import { Vector3 } from "babylonjs/Maths/math";
  41248. import { Nullable } from "babylonjs/types";
  41249. import { Scene } from "babylonjs/scene";
  41250. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41251. /**
  41252. * The Axes viewer will show 3 axes in a specific point in space
  41253. */
  41254. export class AxesViewer {
  41255. private _xAxis;
  41256. private _yAxis;
  41257. private _zAxis;
  41258. private _scaleLinesFactor;
  41259. private _instanced;
  41260. /**
  41261. * Gets the hosting scene
  41262. */
  41263. scene: Scene;
  41264. /**
  41265. * Gets or sets a number used to scale line length
  41266. */
  41267. scaleLines: number;
  41268. /** Gets the node hierarchy used to render x-axis */
  41269. readonly xAxis: TransformNode;
  41270. /** Gets the node hierarchy used to render y-axis */
  41271. readonly yAxis: TransformNode;
  41272. /** Gets the node hierarchy used to render z-axis */
  41273. readonly zAxis: TransformNode;
  41274. /**
  41275. * Creates a new AxesViewer
  41276. * @param scene defines the hosting scene
  41277. * @param scaleLines defines a number used to scale line length (1 by default)
  41278. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41279. * @param xAxis defines the node hierarchy used to render the x-axis
  41280. * @param yAxis defines the node hierarchy used to render the y-axis
  41281. * @param zAxis defines the node hierarchy used to render the z-axis
  41282. */
  41283. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41284. /**
  41285. * Force the viewer to update
  41286. * @param position defines the position of the viewer
  41287. * @param xaxis defines the x axis of the viewer
  41288. * @param yaxis defines the y axis of the viewer
  41289. * @param zaxis defines the z axis of the viewer
  41290. */
  41291. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41292. /**
  41293. * Creates an instance of this axes viewer.
  41294. * @returns a new axes viewer with instanced meshes
  41295. */
  41296. createInstance(): AxesViewer;
  41297. /** Releases resources */
  41298. dispose(): void;
  41299. private static _SetRenderingGroupId;
  41300. }
  41301. }
  41302. declare module "babylonjs/Debug/boneAxesViewer" {
  41303. import { Nullable } from "babylonjs/types";
  41304. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41305. import { Vector3 } from "babylonjs/Maths/math";
  41306. import { Mesh } from "babylonjs/Meshes/mesh";
  41307. import { Bone } from "babylonjs/Bones/bone";
  41308. import { Scene } from "babylonjs/scene";
  41309. /**
  41310. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41311. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41312. */
  41313. export class BoneAxesViewer extends AxesViewer {
  41314. /**
  41315. * Gets or sets the target mesh where to display the axes viewer
  41316. */
  41317. mesh: Nullable<Mesh>;
  41318. /**
  41319. * Gets or sets the target bone where to display the axes viewer
  41320. */
  41321. bone: Nullable<Bone>;
  41322. /** Gets current position */
  41323. pos: Vector3;
  41324. /** Gets direction of X axis */
  41325. xaxis: Vector3;
  41326. /** Gets direction of Y axis */
  41327. yaxis: Vector3;
  41328. /** Gets direction of Z axis */
  41329. zaxis: Vector3;
  41330. /**
  41331. * Creates a new BoneAxesViewer
  41332. * @param scene defines the hosting scene
  41333. * @param bone defines the target bone
  41334. * @param mesh defines the target mesh
  41335. * @param scaleLines defines a scaling factor for line length (1 by default)
  41336. */
  41337. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41338. /**
  41339. * Force the viewer to update
  41340. */
  41341. update(): void;
  41342. /** Releases resources */
  41343. dispose(): void;
  41344. }
  41345. }
  41346. declare module "babylonjs/Debug/debugLayer" {
  41347. import { Observable } from "babylonjs/Misc/observable";
  41348. import { Scene } from "babylonjs/scene";
  41349. /**
  41350. * Interface used to define scene explorer extensibility option
  41351. */
  41352. export interface IExplorerExtensibilityOption {
  41353. /**
  41354. * Define the option label
  41355. */
  41356. label: string;
  41357. /**
  41358. * Defines the action to execute on click
  41359. */
  41360. action: (entity: any) => void;
  41361. }
  41362. /**
  41363. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41364. */
  41365. export interface IExplorerExtensibilityGroup {
  41366. /**
  41367. * Defines a predicate to test if a given type mut be extended
  41368. */
  41369. predicate: (entity: any) => boolean;
  41370. /**
  41371. * Gets the list of options added to a type
  41372. */
  41373. entries: IExplorerExtensibilityOption[];
  41374. }
  41375. /**
  41376. * Interface used to define the options to use to create the Inspector
  41377. */
  41378. export interface IInspectorOptions {
  41379. /**
  41380. * Display in overlay mode (default: false)
  41381. */
  41382. overlay?: boolean;
  41383. /**
  41384. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41385. */
  41386. globalRoot?: HTMLElement;
  41387. /**
  41388. * Display the Scene explorer
  41389. */
  41390. showExplorer?: boolean;
  41391. /**
  41392. * Display the property inspector
  41393. */
  41394. showInspector?: boolean;
  41395. /**
  41396. * Display in embed mode (both panes on the right)
  41397. */
  41398. embedMode?: boolean;
  41399. /**
  41400. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41401. */
  41402. handleResize?: boolean;
  41403. /**
  41404. * Allow the panes to popup (default: true)
  41405. */
  41406. enablePopup?: boolean;
  41407. /**
  41408. * Allow the panes to be closed by users (default: true)
  41409. */
  41410. enableClose?: boolean;
  41411. /**
  41412. * Optional list of extensibility entries
  41413. */
  41414. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41415. /**
  41416. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41417. */
  41418. inspectorURL?: string;
  41419. }
  41420. module "babylonjs/scene" {
  41421. interface Scene {
  41422. /**
  41423. * @hidden
  41424. * Backing field
  41425. */
  41426. _debugLayer: DebugLayer;
  41427. /**
  41428. * Gets the debug layer (aka Inspector) associated with the scene
  41429. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41430. */
  41431. debugLayer: DebugLayer;
  41432. }
  41433. }
  41434. /**
  41435. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41436. * what is happening in your scene
  41437. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41438. */
  41439. export class DebugLayer {
  41440. /**
  41441. * Define the url to get the inspector script from.
  41442. * By default it uses the babylonjs CDN.
  41443. * @ignoreNaming
  41444. */
  41445. static InspectorURL: string;
  41446. private _scene;
  41447. private BJSINSPECTOR;
  41448. /**
  41449. * Observable triggered when a property is changed through the inspector.
  41450. */
  41451. onPropertyChangedObservable: Observable<{
  41452. object: any;
  41453. property: string;
  41454. value: any;
  41455. initialValue: any;
  41456. }>;
  41457. /**
  41458. * Instantiates a new debug layer.
  41459. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41460. * what is happening in your scene
  41461. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41462. * @param scene Defines the scene to inspect
  41463. */
  41464. constructor(scene: Scene);
  41465. /** Creates the inspector window. */
  41466. private _createInspector;
  41467. /**
  41468. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41469. * @param entity defines the entity to select
  41470. * @param lineContainerTitle defines the specific block to highlight
  41471. */
  41472. select(entity: any, lineContainerTitle?: string): void;
  41473. /** Get the inspector from bundle or global */
  41474. private _getGlobalInspector;
  41475. /**
  41476. * Get if the inspector is visible or not.
  41477. * @returns true if visible otherwise, false
  41478. */
  41479. isVisible(): boolean;
  41480. /**
  41481. * Hide the inspector and close its window.
  41482. */
  41483. hide(): void;
  41484. /**
  41485. * Launch the debugLayer.
  41486. * @param config Define the configuration of the inspector
  41487. * @return a promise fulfilled when the debug layer is visible
  41488. */
  41489. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41490. }
  41491. }
  41492. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41493. import { Nullable } from "babylonjs/types";
  41494. import { Scene } from "babylonjs/scene";
  41495. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41496. import { Mesh } from "babylonjs/Meshes/mesh";
  41497. /**
  41498. * Class containing static functions to help procedurally build meshes
  41499. */
  41500. export class BoxBuilder {
  41501. /**
  41502. * Creates a box mesh
  41503. * * The parameter `size` sets the size (float) of each box side (default 1)
  41504. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41505. * * 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)
  41506. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41508. * * If you create a double-sided mesh, you can choose what parts of 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
  41509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41510. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41511. * @param name defines the name of the mesh
  41512. * @param options defines the options used to create the mesh
  41513. * @param scene defines the hosting scene
  41514. * @returns the box mesh
  41515. */
  41516. static CreateBox(name: string, options: {
  41517. size?: number;
  41518. width?: number;
  41519. height?: number;
  41520. depth?: number;
  41521. faceUV?: Vector4[];
  41522. faceColors?: Color4[];
  41523. sideOrientation?: number;
  41524. frontUVs?: Vector4;
  41525. backUVs?: Vector4;
  41526. updatable?: boolean;
  41527. }, scene?: Nullable<Scene>): Mesh;
  41528. }
  41529. }
  41530. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41531. import { Vector4 } from "babylonjs/Maths/math";
  41532. import { Mesh } from "babylonjs/Meshes/mesh";
  41533. /**
  41534. * Class containing static functions to help procedurally build meshes
  41535. */
  41536. export class SphereBuilder {
  41537. /**
  41538. * Creates a sphere mesh
  41539. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41540. * * 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`)
  41541. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41542. * * 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
  41543. * * 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)
  41544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41545. * * If you create a double-sided mesh, you can choose what parts of 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
  41546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41547. * @param name defines the name of the mesh
  41548. * @param options defines the options used to create the mesh
  41549. * @param scene defines the hosting scene
  41550. * @returns the sphere mesh
  41551. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41552. */
  41553. static CreateSphere(name: string, options: {
  41554. segments?: number;
  41555. diameter?: number;
  41556. diameterX?: number;
  41557. diameterY?: number;
  41558. diameterZ?: number;
  41559. arc?: number;
  41560. slice?: number;
  41561. sideOrientation?: number;
  41562. frontUVs?: Vector4;
  41563. backUVs?: Vector4;
  41564. updatable?: boolean;
  41565. }, scene: any): Mesh;
  41566. }
  41567. }
  41568. declare module "babylonjs/Debug/physicsViewer" {
  41569. import { Nullable } from "babylonjs/types";
  41570. import { Scene } from "babylonjs/scene";
  41571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41572. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41573. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41574. /**
  41575. * Used to show the physics impostor around the specific mesh
  41576. */
  41577. export class PhysicsViewer {
  41578. /** @hidden */
  41579. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41580. /** @hidden */
  41581. protected _meshes: Array<Nullable<AbstractMesh>>;
  41582. /** @hidden */
  41583. protected _scene: Nullable<Scene>;
  41584. /** @hidden */
  41585. protected _numMeshes: number;
  41586. /** @hidden */
  41587. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41588. private _renderFunction;
  41589. private _utilityLayer;
  41590. private _debugBoxMesh;
  41591. private _debugSphereMesh;
  41592. private _debugMaterial;
  41593. /**
  41594. * Creates a new PhysicsViewer
  41595. * @param scene defines the hosting scene
  41596. */
  41597. constructor(scene: Scene);
  41598. /** @hidden */
  41599. protected _updateDebugMeshes(): void;
  41600. /**
  41601. * Renders a specified physic impostor
  41602. * @param impostor defines the impostor to render
  41603. * @returns the new debug mesh used to render the impostor
  41604. */
  41605. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41606. /**
  41607. * Hides a specified physic impostor
  41608. * @param impostor defines the impostor to hide
  41609. */
  41610. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41611. private _getDebugMaterial;
  41612. private _getDebugBoxMesh;
  41613. private _getDebugSphereMesh;
  41614. private _getDebugMesh;
  41615. /** Releases all resources */
  41616. dispose(): void;
  41617. }
  41618. }
  41619. declare module "babylonjs/Debug/rayHelper" {
  41620. import { Nullable } from "babylonjs/types";
  41621. import { Ray } from "babylonjs/Culling/ray";
  41622. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41623. import { Scene } from "babylonjs/scene";
  41624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41625. import "babylonjs/Meshes/Builders/linesBuilder";
  41626. /**
  41627. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41628. * in order to better appreciate the issue one might have.
  41629. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41630. */
  41631. export class RayHelper {
  41632. /**
  41633. * Defines the ray we are currently tryin to visualize.
  41634. */
  41635. ray: Nullable<Ray>;
  41636. private _renderPoints;
  41637. private _renderLine;
  41638. private _renderFunction;
  41639. private _scene;
  41640. private _updateToMeshFunction;
  41641. private _attachedToMesh;
  41642. private _meshSpaceDirection;
  41643. private _meshSpaceOrigin;
  41644. /**
  41645. * Helper function to create a colored helper in a scene in one line.
  41646. * @param ray Defines the ray we are currently tryin to visualize
  41647. * @param scene Defines the scene the ray is used in
  41648. * @param color Defines the color we want to see the ray in
  41649. * @returns The newly created ray helper.
  41650. */
  41651. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41652. /**
  41653. * Instantiate a new ray helper.
  41654. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41655. * in order to better appreciate the issue one might have.
  41656. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41657. * @param ray Defines the ray we are currently tryin to visualize
  41658. */
  41659. constructor(ray: Ray);
  41660. /**
  41661. * Shows the ray we are willing to debug.
  41662. * @param scene Defines the scene the ray needs to be rendered in
  41663. * @param color Defines the color the ray needs to be rendered in
  41664. */
  41665. show(scene: Scene, color?: Color3): void;
  41666. /**
  41667. * Hides the ray we are debugging.
  41668. */
  41669. hide(): void;
  41670. private _render;
  41671. /**
  41672. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41673. * @param mesh Defines the mesh we want the helper attached to
  41674. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41675. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41676. * @param length Defines the length of the ray
  41677. */
  41678. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41679. /**
  41680. * Detach the ray helper from the mesh it has previously been attached to.
  41681. */
  41682. detachFromMesh(): void;
  41683. private _updateToMesh;
  41684. /**
  41685. * Dispose the helper and release its associated resources.
  41686. */
  41687. dispose(): void;
  41688. }
  41689. }
  41690. declare module "babylonjs/Debug/skeletonViewer" {
  41691. import { Color3 } from "babylonjs/Maths/math";
  41692. import { Scene } from "babylonjs/scene";
  41693. import { Nullable } from "babylonjs/types";
  41694. import { Skeleton } from "babylonjs/Bones/skeleton";
  41695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41696. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41697. /**
  41698. * Class used to render a debug view of a given skeleton
  41699. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41700. */
  41701. export class SkeletonViewer {
  41702. /** defines the skeleton to render */
  41703. skeleton: Skeleton;
  41704. /** defines the mesh attached to the skeleton */
  41705. mesh: AbstractMesh;
  41706. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41707. autoUpdateBonesMatrices: boolean;
  41708. /** defines the rendering group id to use with the viewer */
  41709. renderingGroupId: number;
  41710. /** Gets or sets the color used to render the skeleton */
  41711. color: Color3;
  41712. private _scene;
  41713. private _debugLines;
  41714. private _debugMesh;
  41715. private _isEnabled;
  41716. private _renderFunction;
  41717. private _utilityLayer;
  41718. /**
  41719. * Returns the mesh used to render the bones
  41720. */
  41721. readonly debugMesh: Nullable<LinesMesh>;
  41722. /**
  41723. * Creates a new SkeletonViewer
  41724. * @param skeleton defines the skeleton to render
  41725. * @param mesh defines the mesh attached to the skeleton
  41726. * @param scene defines the hosting scene
  41727. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41728. * @param renderingGroupId defines the rendering group id to use with the viewer
  41729. */
  41730. constructor(
  41731. /** defines the skeleton to render */
  41732. skeleton: Skeleton,
  41733. /** defines the mesh attached to the skeleton */
  41734. mesh: AbstractMesh, scene: Scene,
  41735. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41736. autoUpdateBonesMatrices?: boolean,
  41737. /** defines the rendering group id to use with the viewer */
  41738. renderingGroupId?: number);
  41739. /** Gets or sets a boolean indicating if the viewer is enabled */
  41740. isEnabled: boolean;
  41741. private _getBonePosition;
  41742. private _getLinesForBonesWithLength;
  41743. private _getLinesForBonesNoLength;
  41744. /** Update the viewer to sync with current skeleton state */
  41745. update(): void;
  41746. /** Release associated resources */
  41747. dispose(): void;
  41748. }
  41749. }
  41750. declare module "babylonjs/Debug/index" {
  41751. export * from "babylonjs/Debug/axesViewer";
  41752. export * from "babylonjs/Debug/boneAxesViewer";
  41753. export * from "babylonjs/Debug/debugLayer";
  41754. export * from "babylonjs/Debug/physicsViewer";
  41755. export * from "babylonjs/Debug/rayHelper";
  41756. export * from "babylonjs/Debug/skeletonViewer";
  41757. }
  41758. declare module "babylonjs/Engines/nullEngine" {
  41759. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41760. import { Scene } from "babylonjs/scene";
  41761. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41762. import { Engine } from "babylonjs/Engines/engine";
  41763. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41764. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41765. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41766. import { Effect } from "babylonjs/Materials/effect";
  41767. /**
  41768. * Options to create the null engine
  41769. */
  41770. export class NullEngineOptions {
  41771. /**
  41772. * Render width (Default: 512)
  41773. */
  41774. renderWidth: number;
  41775. /**
  41776. * Render height (Default: 256)
  41777. */
  41778. renderHeight: number;
  41779. /**
  41780. * Texture size (Default: 512)
  41781. */
  41782. textureSize: number;
  41783. /**
  41784. * If delta time between frames should be constant
  41785. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41786. */
  41787. deterministicLockstep: boolean;
  41788. /**
  41789. * Maximum about of steps between frames (Default: 4)
  41790. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41791. */
  41792. lockstepMaxSteps: number;
  41793. }
  41794. /**
  41795. * The null engine class provides support for headless version of babylon.js.
  41796. * This can be used in server side scenario or for testing purposes
  41797. */
  41798. export class NullEngine extends Engine {
  41799. private _options;
  41800. /**
  41801. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41802. */
  41803. isDeterministicLockStep(): boolean;
  41804. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41805. getLockstepMaxSteps(): number;
  41806. /**
  41807. * Sets hardware scaling, used to save performance if needed
  41808. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41809. */
  41810. getHardwareScalingLevel(): number;
  41811. constructor(options?: NullEngineOptions);
  41812. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41813. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41814. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41815. getRenderWidth(useScreen?: boolean): number;
  41816. getRenderHeight(useScreen?: boolean): number;
  41817. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41818. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41819. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41820. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41821. bindSamplers(effect: Effect): void;
  41822. enableEffect(effect: Effect): void;
  41823. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41824. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41825. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41826. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41827. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41828. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41829. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41830. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41831. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41832. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41833. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41834. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41835. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41836. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41837. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41838. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41839. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41840. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41841. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41842. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41843. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41844. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41845. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41846. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41847. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41848. bindBuffers(vertexBuffers: {
  41849. [key: string]: VertexBuffer;
  41850. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41851. wipeCaches(bruteForce?: boolean): void;
  41852. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41853. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41854. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41855. /** @hidden */
  41856. _createTexture(): WebGLTexture;
  41857. /** @hidden */
  41858. _releaseTexture(texture: InternalTexture): void;
  41859. 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;
  41860. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41861. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41862. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41863. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41864. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41865. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41866. areAllEffectsReady(): boolean;
  41867. /**
  41868. * @hidden
  41869. * Get the current error code of the webGL context
  41870. * @returns the error code
  41871. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41872. */
  41873. getError(): number;
  41874. /** @hidden */
  41875. _getUnpackAlignement(): number;
  41876. /** @hidden */
  41877. _unpackFlipY(value: boolean): void;
  41878. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41879. /**
  41880. * Updates a dynamic vertex buffer.
  41881. * @param vertexBuffer the vertex buffer to update
  41882. * @param data the data used to update the vertex buffer
  41883. * @param byteOffset the byte offset of the data (optional)
  41884. * @param byteLength the byte length of the data (optional)
  41885. */
  41886. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41887. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41888. /** @hidden */
  41889. _bindTexture(channel: number, texture: InternalTexture): void;
  41890. /** @hidden */
  41891. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41892. releaseEffects(): void;
  41893. displayLoadingUI(): void;
  41894. hideLoadingUI(): void;
  41895. /** @hidden */
  41896. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41897. /** @hidden */
  41898. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41899. /** @hidden */
  41900. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41901. /** @hidden */
  41902. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41903. }
  41904. }
  41905. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41906. import { Nullable, int } from "babylonjs/types";
  41907. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41908. /** @hidden */
  41909. export class _OcclusionDataStorage {
  41910. /** @hidden */
  41911. occlusionInternalRetryCounter: number;
  41912. /** @hidden */
  41913. isOcclusionQueryInProgress: boolean;
  41914. /** @hidden */
  41915. isOccluded: boolean;
  41916. /** @hidden */
  41917. occlusionRetryCount: number;
  41918. /** @hidden */
  41919. occlusionType: number;
  41920. /** @hidden */
  41921. occlusionQueryAlgorithmType: number;
  41922. }
  41923. module "babylonjs/Engines/engine" {
  41924. interface Engine {
  41925. /**
  41926. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41927. * @return the new query
  41928. */
  41929. createQuery(): WebGLQuery;
  41930. /**
  41931. * Delete and release a webGL query
  41932. * @param query defines the query to delete
  41933. * @return the current engine
  41934. */
  41935. deleteQuery(query: WebGLQuery): Engine;
  41936. /**
  41937. * Check if a given query has resolved and got its value
  41938. * @param query defines the query to check
  41939. * @returns true if the query got its value
  41940. */
  41941. isQueryResultAvailable(query: WebGLQuery): boolean;
  41942. /**
  41943. * Gets the value of a given query
  41944. * @param query defines the query to check
  41945. * @returns the value of the query
  41946. */
  41947. getQueryResult(query: WebGLQuery): number;
  41948. /**
  41949. * Initiates an occlusion query
  41950. * @param algorithmType defines the algorithm to use
  41951. * @param query defines the query to use
  41952. * @returns the current engine
  41953. * @see http://doc.babylonjs.com/features/occlusionquery
  41954. */
  41955. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41956. /**
  41957. * Ends an occlusion query
  41958. * @see http://doc.babylonjs.com/features/occlusionquery
  41959. * @param algorithmType defines the algorithm to use
  41960. * @returns the current engine
  41961. */
  41962. endOcclusionQuery(algorithmType: number): Engine;
  41963. /**
  41964. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41965. * Please note that only one query can be issued at a time
  41966. * @returns a time token used to track the time span
  41967. */
  41968. startTimeQuery(): Nullable<_TimeToken>;
  41969. /**
  41970. * Ends a time query
  41971. * @param token defines the token used to measure the time span
  41972. * @returns the time spent (in ns)
  41973. */
  41974. endTimeQuery(token: _TimeToken): int;
  41975. /** @hidden */
  41976. _currentNonTimestampToken: Nullable<_TimeToken>;
  41977. /** @hidden */
  41978. _createTimeQuery(): WebGLQuery;
  41979. /** @hidden */
  41980. _deleteTimeQuery(query: WebGLQuery): void;
  41981. /** @hidden */
  41982. _getGlAlgorithmType(algorithmType: number): number;
  41983. /** @hidden */
  41984. _getTimeQueryResult(query: WebGLQuery): any;
  41985. /** @hidden */
  41986. _getTimeQueryAvailability(query: WebGLQuery): any;
  41987. }
  41988. }
  41989. module "babylonjs/Meshes/abstractMesh" {
  41990. interface AbstractMesh {
  41991. /**
  41992. * Backing filed
  41993. * @hidden
  41994. */
  41995. __occlusionDataStorage: _OcclusionDataStorage;
  41996. /**
  41997. * Access property
  41998. * @hidden
  41999. */
  42000. _occlusionDataStorage: _OcclusionDataStorage;
  42001. /**
  42002. * 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.
  42003. * The default value is -1 which means don't break the query and wait till the result
  42004. * @see http://doc.babylonjs.com/features/occlusionquery
  42005. */
  42006. occlusionRetryCount: number;
  42007. /**
  42008. * 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:
  42009. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42010. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42011. * * 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.
  42012. * @see http://doc.babylonjs.com/features/occlusionquery
  42013. */
  42014. occlusionType: number;
  42015. /**
  42016. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42017. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42018. * * 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.
  42019. * @see http://doc.babylonjs.com/features/occlusionquery
  42020. */
  42021. occlusionQueryAlgorithmType: number;
  42022. /**
  42023. * 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
  42024. * @see http://doc.babylonjs.com/features/occlusionquery
  42025. */
  42026. isOccluded: boolean;
  42027. /**
  42028. * Flag to check the progress status of the query
  42029. * @see http://doc.babylonjs.com/features/occlusionquery
  42030. */
  42031. isOcclusionQueryInProgress: boolean;
  42032. }
  42033. }
  42034. }
  42035. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42036. import { Nullable } from "babylonjs/types";
  42037. /** @hidden */
  42038. export var _forceTransformFeedbackToBundle: boolean;
  42039. module "babylonjs/Engines/engine" {
  42040. interface Engine {
  42041. /**
  42042. * Creates a webGL transform feedback object
  42043. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42044. * @returns the webGL transform feedback object
  42045. */
  42046. createTransformFeedback(): WebGLTransformFeedback;
  42047. /**
  42048. * Delete a webGL transform feedback object
  42049. * @param value defines the webGL transform feedback object to delete
  42050. */
  42051. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42052. /**
  42053. * Bind a webGL transform feedback object to the webgl context
  42054. * @param value defines the webGL transform feedback object to bind
  42055. */
  42056. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42057. /**
  42058. * Begins a transform feedback operation
  42059. * @param usePoints defines if points or triangles must be used
  42060. */
  42061. beginTransformFeedback(usePoints: boolean): void;
  42062. /**
  42063. * Ends a transform feedback operation
  42064. */
  42065. endTransformFeedback(): void;
  42066. /**
  42067. * Specify the varyings to use with transform feedback
  42068. * @param program defines the associated webGL program
  42069. * @param value defines the list of strings representing the varying names
  42070. */
  42071. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42072. /**
  42073. * Bind a webGL buffer for a transform feedback operation
  42074. * @param value defines the webGL buffer to bind
  42075. */
  42076. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42077. }
  42078. }
  42079. }
  42080. declare module "babylonjs/Engines/Extensions/index" {
  42081. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42082. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42083. }
  42084. declare module "babylonjs/Engines/index" {
  42085. export * from "babylonjs/Engines/constants";
  42086. export * from "babylonjs/Engines/engine";
  42087. export * from "babylonjs/Engines/engineStore";
  42088. export * from "babylonjs/Engines/nullEngine";
  42089. export * from "babylonjs/Engines/Extensions/index";
  42090. }
  42091. declare module "babylonjs/Events/clipboardEvents" {
  42092. /**
  42093. * Gather the list of clipboard event types as constants.
  42094. */
  42095. export class ClipboardEventTypes {
  42096. /**
  42097. * The clipboard event is fired when a copy command is active (pressed).
  42098. */
  42099. static readonly COPY: number;
  42100. /**
  42101. * The clipboard event is fired when a cut command is active (pressed).
  42102. */
  42103. static readonly CUT: number;
  42104. /**
  42105. * The clipboard event is fired when a paste command is active (pressed).
  42106. */
  42107. static readonly PASTE: number;
  42108. }
  42109. /**
  42110. * This class is used to store clipboard related info for the onClipboardObservable event.
  42111. */
  42112. export class ClipboardInfo {
  42113. /**
  42114. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42115. */
  42116. type: number;
  42117. /**
  42118. * Defines the related dom event
  42119. */
  42120. event: ClipboardEvent;
  42121. /**
  42122. *Creates an instance of ClipboardInfo.
  42123. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42124. * @param event Defines the related dom event
  42125. */
  42126. constructor(
  42127. /**
  42128. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42129. */
  42130. type: number,
  42131. /**
  42132. * Defines the related dom event
  42133. */
  42134. event: ClipboardEvent);
  42135. /**
  42136. * Get the clipboard event's type from the keycode.
  42137. * @param keyCode Defines the keyCode for the current keyboard event.
  42138. * @return {number}
  42139. */
  42140. static GetTypeFromCharacter(keyCode: number): number;
  42141. }
  42142. }
  42143. declare module "babylonjs/Events/index" {
  42144. export * from "babylonjs/Events/keyboardEvents";
  42145. export * from "babylonjs/Events/pointerEvents";
  42146. export * from "babylonjs/Events/clipboardEvents";
  42147. }
  42148. declare module "babylonjs/Loading/sceneLoader" {
  42149. import { Observable } from "babylonjs/Misc/observable";
  42150. import { Nullable } from "babylonjs/types";
  42151. import { Scene } from "babylonjs/scene";
  42152. import { Engine } from "babylonjs/Engines/engine";
  42153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42154. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42155. import { AssetContainer } from "babylonjs/assetContainer";
  42156. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42157. import { Skeleton } from "babylonjs/Bones/skeleton";
  42158. /**
  42159. * Class used to represent data loading progression
  42160. */
  42161. export class SceneLoaderProgressEvent {
  42162. /** defines if data length to load can be evaluated */
  42163. readonly lengthComputable: boolean;
  42164. /** defines the loaded data length */
  42165. readonly loaded: number;
  42166. /** defines the data length to load */
  42167. readonly total: number;
  42168. /**
  42169. * Create a new progress event
  42170. * @param lengthComputable defines if data length to load can be evaluated
  42171. * @param loaded defines the loaded data length
  42172. * @param total defines the data length to load
  42173. */
  42174. constructor(
  42175. /** defines if data length to load can be evaluated */
  42176. lengthComputable: boolean,
  42177. /** defines the loaded data length */
  42178. loaded: number,
  42179. /** defines the data length to load */
  42180. total: number);
  42181. /**
  42182. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42183. * @param event defines the source event
  42184. * @returns a new SceneLoaderProgressEvent
  42185. */
  42186. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42187. }
  42188. /**
  42189. * Interface used by SceneLoader plugins to define supported file extensions
  42190. */
  42191. export interface ISceneLoaderPluginExtensions {
  42192. /**
  42193. * Defines the list of supported extensions
  42194. */
  42195. [extension: string]: {
  42196. isBinary: boolean;
  42197. };
  42198. }
  42199. /**
  42200. * Interface used by SceneLoader plugin factory
  42201. */
  42202. export interface ISceneLoaderPluginFactory {
  42203. /**
  42204. * Defines the name of the factory
  42205. */
  42206. name: string;
  42207. /**
  42208. * Function called to create a new plugin
  42209. * @return the new plugin
  42210. */
  42211. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42212. /**
  42213. * Boolean indicating if the plugin can direct load specific data
  42214. */
  42215. canDirectLoad?: (data: string) => boolean;
  42216. }
  42217. /**
  42218. * Interface used to define a SceneLoader plugin
  42219. */
  42220. export interface ISceneLoaderPlugin {
  42221. /**
  42222. * The friendly name of this plugin.
  42223. */
  42224. name: string;
  42225. /**
  42226. * The file extensions supported by this plugin.
  42227. */
  42228. extensions: string | ISceneLoaderPluginExtensions;
  42229. /**
  42230. * Import meshes into a scene.
  42231. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42232. * @param scene The scene to import into
  42233. * @param data The data to import
  42234. * @param rootUrl The root url for scene and resources
  42235. * @param meshes The meshes array to import into
  42236. * @param particleSystems The particle systems array to import into
  42237. * @param skeletons The skeletons array to import into
  42238. * @param onError The callback when import fails
  42239. * @returns True if successful or false otherwise
  42240. */
  42241. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42242. /**
  42243. * Load into a scene.
  42244. * @param scene The scene to load into
  42245. * @param data The data to import
  42246. * @param rootUrl The root url for scene and resources
  42247. * @param onError The callback when import fails
  42248. * @returns true if successful or false otherwise
  42249. */
  42250. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42251. /**
  42252. * The callback that returns true if the data can be directly loaded.
  42253. */
  42254. canDirectLoad?: (data: string) => boolean;
  42255. /**
  42256. * The callback that allows custom handling of the root url based on the response url.
  42257. */
  42258. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42259. /**
  42260. * Load into an asset container.
  42261. * @param scene The scene to load into
  42262. * @param data The data to import
  42263. * @param rootUrl The root url for scene and resources
  42264. * @param onError The callback when import fails
  42265. * @returns The loaded asset container
  42266. */
  42267. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42268. }
  42269. /**
  42270. * Interface used to define an async SceneLoader plugin
  42271. */
  42272. export interface ISceneLoaderPluginAsync {
  42273. /**
  42274. * The friendly name of this plugin.
  42275. */
  42276. name: string;
  42277. /**
  42278. * The file extensions supported by this plugin.
  42279. */
  42280. extensions: string | ISceneLoaderPluginExtensions;
  42281. /**
  42282. * Import meshes into a scene.
  42283. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42284. * @param scene The scene to import into
  42285. * @param data The data to import
  42286. * @param rootUrl The root url for scene and resources
  42287. * @param onProgress The callback when the load progresses
  42288. * @param fileName Defines the name of the file to load
  42289. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42290. */
  42291. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42292. meshes: AbstractMesh[];
  42293. particleSystems: IParticleSystem[];
  42294. skeletons: Skeleton[];
  42295. animationGroups: AnimationGroup[];
  42296. }>;
  42297. /**
  42298. * Load into a scene.
  42299. * @param scene The scene to load into
  42300. * @param data The data to import
  42301. * @param rootUrl The root url for scene and resources
  42302. * @param onProgress The callback when the load progresses
  42303. * @param fileName Defines the name of the file to load
  42304. * @returns Nothing
  42305. */
  42306. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42307. /**
  42308. * The callback that returns true if the data can be directly loaded.
  42309. */
  42310. canDirectLoad?: (data: string) => boolean;
  42311. /**
  42312. * The callback that allows custom handling of the root url based on the response url.
  42313. */
  42314. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42315. /**
  42316. * Load into an asset container.
  42317. * @param scene The scene to load into
  42318. * @param data The data to import
  42319. * @param rootUrl The root url for scene and resources
  42320. * @param onProgress The callback when the load progresses
  42321. * @param fileName Defines the name of the file to load
  42322. * @returns The loaded asset container
  42323. */
  42324. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42325. }
  42326. /**
  42327. * Class used to load scene from various file formats using registered plugins
  42328. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42329. */
  42330. export class SceneLoader {
  42331. /**
  42332. * No logging while loading
  42333. */
  42334. static readonly NO_LOGGING: number;
  42335. /**
  42336. * Minimal logging while loading
  42337. */
  42338. static readonly MINIMAL_LOGGING: number;
  42339. /**
  42340. * Summary logging while loading
  42341. */
  42342. static readonly SUMMARY_LOGGING: number;
  42343. /**
  42344. * Detailled logging while loading
  42345. */
  42346. static readonly DETAILED_LOGGING: number;
  42347. /**
  42348. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42349. */
  42350. static ForceFullSceneLoadingForIncremental: boolean;
  42351. /**
  42352. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42353. */
  42354. static ShowLoadingScreen: boolean;
  42355. /**
  42356. * Defines the current logging level (while loading the scene)
  42357. * @ignorenaming
  42358. */
  42359. static loggingLevel: number;
  42360. /**
  42361. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42362. */
  42363. static CleanBoneMatrixWeights: boolean;
  42364. /**
  42365. * Event raised when a plugin is used to load a scene
  42366. */
  42367. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42368. private static _registeredPlugins;
  42369. private static _getDefaultPlugin;
  42370. private static _getPluginForExtension;
  42371. private static _getPluginForDirectLoad;
  42372. private static _getPluginForFilename;
  42373. private static _getDirectLoad;
  42374. private static _loadData;
  42375. private static _getFileInfo;
  42376. /**
  42377. * Gets a plugin that can load the given extension
  42378. * @param extension defines the extension to load
  42379. * @returns a plugin or null if none works
  42380. */
  42381. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42382. /**
  42383. * Gets a boolean indicating that the given extension can be loaded
  42384. * @param extension defines the extension to load
  42385. * @returns true if the extension is supported
  42386. */
  42387. static IsPluginForExtensionAvailable(extension: string): boolean;
  42388. /**
  42389. * Adds a new plugin to the list of registered plugins
  42390. * @param plugin defines the plugin to add
  42391. */
  42392. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42393. /**
  42394. * Import meshes into a scene
  42395. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42396. * @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)
  42397. * @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)
  42398. * @param scene the instance of BABYLON.Scene to append to
  42399. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42400. * @param onProgress a callback with a progress event for each file being loaded
  42401. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42402. * @param pluginExtension the extension used to determine the plugin
  42403. * @returns The loaded plugin
  42404. */
  42405. 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>;
  42406. /**
  42407. * Import meshes into a scene
  42408. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42409. * @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)
  42410. * @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)
  42411. * @param scene the instance of BABYLON.Scene to append to
  42412. * @param onProgress a callback with a progress event for each file being loaded
  42413. * @param pluginExtension the extension used to determine the plugin
  42414. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42415. */
  42416. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42417. meshes: AbstractMesh[];
  42418. particleSystems: IParticleSystem[];
  42419. skeletons: Skeleton[];
  42420. animationGroups: AnimationGroup[];
  42421. }>;
  42422. /**
  42423. * Load a scene
  42424. * @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)
  42425. * @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)
  42426. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42427. * @param onSuccess a callback with the scene when import succeeds
  42428. * @param onProgress a callback with a progress event for each file being loaded
  42429. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42430. * @param pluginExtension the extension used to determine the plugin
  42431. * @returns The loaded plugin
  42432. */
  42433. 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>;
  42434. /**
  42435. * Load a scene
  42436. * @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)
  42437. * @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)
  42438. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42439. * @param onProgress a callback with a progress event for each file being loaded
  42440. * @param pluginExtension the extension used to determine the plugin
  42441. * @returns The loaded scene
  42442. */
  42443. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42444. /**
  42445. * Append a scene
  42446. * @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)
  42447. * @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)
  42448. * @param scene is the instance of BABYLON.Scene to append to
  42449. * @param onSuccess a callback with the scene when import succeeds
  42450. * @param onProgress a callback with a progress event for each file being loaded
  42451. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42452. * @param pluginExtension the extension used to determine the plugin
  42453. * @returns The loaded plugin
  42454. */
  42455. 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>;
  42456. /**
  42457. * Append a scene
  42458. * @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)
  42459. * @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)
  42460. * @param scene is the instance of BABYLON.Scene to append to
  42461. * @param onProgress a callback with a progress event for each file being loaded
  42462. * @param pluginExtension the extension used to determine the plugin
  42463. * @returns The given scene
  42464. */
  42465. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42466. /**
  42467. * Load a scene into an asset container
  42468. * @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)
  42469. * @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)
  42470. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42471. * @param onSuccess a callback with the scene when import succeeds
  42472. * @param onProgress a callback with a progress event for each file being loaded
  42473. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42474. * @param pluginExtension the extension used to determine the plugin
  42475. * @returns The loaded plugin
  42476. */
  42477. 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>;
  42478. /**
  42479. * Load a scene into an asset container
  42480. * @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)
  42481. * @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)
  42482. * @param scene is the instance of Scene to append to
  42483. * @param onProgress a callback with a progress event for each file being loaded
  42484. * @param pluginExtension the extension used to determine the plugin
  42485. * @returns The loaded asset container
  42486. */
  42487. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42488. }
  42489. }
  42490. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42491. import { Scene } from "babylonjs/scene";
  42492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42493. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42494. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42495. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42496. /**
  42497. * Google Daydream controller
  42498. */
  42499. export class DaydreamController extends WebVRController {
  42500. /**
  42501. * Base Url for the controller model.
  42502. */
  42503. static MODEL_BASE_URL: string;
  42504. /**
  42505. * File name for the controller model.
  42506. */
  42507. static MODEL_FILENAME: string;
  42508. /**
  42509. * Gamepad Id prefix used to identify Daydream Controller.
  42510. */
  42511. static readonly GAMEPAD_ID_PREFIX: string;
  42512. /**
  42513. * Creates a new DaydreamController from a gamepad
  42514. * @param vrGamepad the gamepad that the controller should be created from
  42515. */
  42516. constructor(vrGamepad: any);
  42517. /**
  42518. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42519. * @param scene scene in which to add meshes
  42520. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42521. */
  42522. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42523. /**
  42524. * Called once for each button that changed state since the last frame
  42525. * @param buttonIdx Which button index changed
  42526. * @param state New state of the button
  42527. * @param changes Which properties on the state changed since last frame
  42528. */
  42529. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42530. }
  42531. }
  42532. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42533. import { Scene } from "babylonjs/scene";
  42534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42535. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42536. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42537. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42538. /**
  42539. * Gear VR Controller
  42540. */
  42541. export class GearVRController extends WebVRController {
  42542. /**
  42543. * Base Url for the controller model.
  42544. */
  42545. static MODEL_BASE_URL: string;
  42546. /**
  42547. * File name for the controller model.
  42548. */
  42549. static MODEL_FILENAME: string;
  42550. /**
  42551. * Gamepad Id prefix used to identify this controller.
  42552. */
  42553. static readonly GAMEPAD_ID_PREFIX: string;
  42554. private readonly _buttonIndexToObservableNameMap;
  42555. /**
  42556. * Creates a new GearVRController from a gamepad
  42557. * @param vrGamepad the gamepad that the controller should be created from
  42558. */
  42559. constructor(vrGamepad: any);
  42560. /**
  42561. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42562. * @param scene scene in which to add meshes
  42563. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42564. */
  42565. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42566. /**
  42567. * Called once for each button that changed state since the last frame
  42568. * @param buttonIdx Which button index changed
  42569. * @param state New state of the button
  42570. * @param changes Which properties on the state changed since last frame
  42571. */
  42572. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42573. }
  42574. }
  42575. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42576. import { Scene } from "babylonjs/scene";
  42577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42578. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42579. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42580. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42581. /**
  42582. * Generic Controller
  42583. */
  42584. export class GenericController extends WebVRController {
  42585. /**
  42586. * Base Url for the controller model.
  42587. */
  42588. static readonly MODEL_BASE_URL: string;
  42589. /**
  42590. * File name for the controller model.
  42591. */
  42592. static readonly MODEL_FILENAME: string;
  42593. /**
  42594. * Creates a new GenericController from a gamepad
  42595. * @param vrGamepad the gamepad that the controller should be created from
  42596. */
  42597. constructor(vrGamepad: any);
  42598. /**
  42599. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42600. * @param scene scene in which to add meshes
  42601. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42602. */
  42603. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42604. /**
  42605. * Called once for each button that changed state since the last frame
  42606. * @param buttonIdx Which button index changed
  42607. * @param state New state of the button
  42608. * @param changes Which properties on the state changed since last frame
  42609. */
  42610. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42611. }
  42612. }
  42613. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42614. import { Observable } from "babylonjs/Misc/observable";
  42615. import { Scene } from "babylonjs/scene";
  42616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42617. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42618. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42619. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42620. /**
  42621. * Oculus Touch Controller
  42622. */
  42623. export class OculusTouchController extends WebVRController {
  42624. /**
  42625. * Base Url for the controller model.
  42626. */
  42627. static MODEL_BASE_URL: string;
  42628. /**
  42629. * File name for the left controller model.
  42630. */
  42631. static MODEL_LEFT_FILENAME: string;
  42632. /**
  42633. * File name for the right controller model.
  42634. */
  42635. static MODEL_RIGHT_FILENAME: string;
  42636. /**
  42637. * Fired when the secondary trigger on this controller is modified
  42638. */
  42639. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42640. /**
  42641. * Fired when the thumb rest on this controller is modified
  42642. */
  42643. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42644. /**
  42645. * Creates a new OculusTouchController from a gamepad
  42646. * @param vrGamepad the gamepad that the controller should be created from
  42647. */
  42648. constructor(vrGamepad: any);
  42649. /**
  42650. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42651. * @param scene scene in which to add meshes
  42652. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42653. */
  42654. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42655. /**
  42656. * Fired when the A button on this controller is modified
  42657. */
  42658. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42659. /**
  42660. * Fired when the B button on this controller is modified
  42661. */
  42662. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42663. /**
  42664. * Fired when the X button on this controller is modified
  42665. */
  42666. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42667. /**
  42668. * Fired when the Y button on this controller is modified
  42669. */
  42670. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42671. /**
  42672. * Called once for each button that changed state since the last frame
  42673. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42674. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42675. * 2) secondary trigger (same)
  42676. * 3) A (right) X (left), touch, pressed = value
  42677. * 4) B / Y
  42678. * 5) thumb rest
  42679. * @param buttonIdx Which button index changed
  42680. * @param state New state of the button
  42681. * @param changes Which properties on the state changed since last frame
  42682. */
  42683. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42684. }
  42685. }
  42686. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42687. import { Scene } from "babylonjs/scene";
  42688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42689. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42690. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42691. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42692. import { Observable } from "babylonjs/Misc/observable";
  42693. /**
  42694. * Vive Controller
  42695. */
  42696. export class ViveController extends WebVRController {
  42697. /**
  42698. * Base Url for the controller model.
  42699. */
  42700. static MODEL_BASE_URL: string;
  42701. /**
  42702. * File name for the controller model.
  42703. */
  42704. static MODEL_FILENAME: string;
  42705. /**
  42706. * Creates a new ViveController from a gamepad
  42707. * @param vrGamepad the gamepad that the controller should be created from
  42708. */
  42709. constructor(vrGamepad: any);
  42710. /**
  42711. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42712. * @param scene scene in which to add meshes
  42713. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42714. */
  42715. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42716. /**
  42717. * Fired when the left button on this controller is modified
  42718. */
  42719. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42720. /**
  42721. * Fired when the right button on this controller is modified
  42722. */
  42723. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42724. /**
  42725. * Fired when the menu button on this controller is modified
  42726. */
  42727. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42728. /**
  42729. * Called once for each button that changed state since the last frame
  42730. * Vive mapping:
  42731. * 0: touchpad
  42732. * 1: trigger
  42733. * 2: left AND right buttons
  42734. * 3: menu button
  42735. * @param buttonIdx Which button index changed
  42736. * @param state New state of the button
  42737. * @param changes Which properties on the state changed since last frame
  42738. */
  42739. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42740. }
  42741. }
  42742. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42743. import { Observable } from "babylonjs/Misc/observable";
  42744. import { Scene } from "babylonjs/scene";
  42745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42746. import { Ray } from "babylonjs/Culling/ray";
  42747. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42748. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42749. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42750. /**
  42751. * Defines the WindowsMotionController object that the state of the windows motion controller
  42752. */
  42753. export class WindowsMotionController extends WebVRController {
  42754. /**
  42755. * The base url used to load the left and right controller models
  42756. */
  42757. static MODEL_BASE_URL: string;
  42758. /**
  42759. * The name of the left controller model file
  42760. */
  42761. static MODEL_LEFT_FILENAME: string;
  42762. /**
  42763. * The name of the right controller model file
  42764. */
  42765. static MODEL_RIGHT_FILENAME: string;
  42766. /**
  42767. * The controller name prefix for this controller type
  42768. */
  42769. static readonly GAMEPAD_ID_PREFIX: string;
  42770. /**
  42771. * The controller id pattern for this controller type
  42772. */
  42773. private static readonly GAMEPAD_ID_PATTERN;
  42774. private _loadedMeshInfo;
  42775. private readonly _mapping;
  42776. /**
  42777. * Fired when the trackpad on this controller is clicked
  42778. */
  42779. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42780. /**
  42781. * Fired when the trackpad on this controller is modified
  42782. */
  42783. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42784. /**
  42785. * The current x and y values of this controller's trackpad
  42786. */
  42787. trackpad: StickValues;
  42788. /**
  42789. * Creates a new WindowsMotionController from a gamepad
  42790. * @param vrGamepad the gamepad that the controller should be created from
  42791. */
  42792. constructor(vrGamepad: any);
  42793. /**
  42794. * Fired when the trigger on this controller is modified
  42795. */
  42796. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42797. /**
  42798. * Fired when the menu button on this controller is modified
  42799. */
  42800. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42801. /**
  42802. * Fired when the grip button on this controller is modified
  42803. */
  42804. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42805. /**
  42806. * Fired when the thumbstick button on this controller is modified
  42807. */
  42808. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42809. /**
  42810. * Fired when the touchpad button on this controller is modified
  42811. */
  42812. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42813. /**
  42814. * Fired when the touchpad values on this controller are modified
  42815. */
  42816. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42817. private _updateTrackpad;
  42818. /**
  42819. * Called once per frame by the engine.
  42820. */
  42821. update(): void;
  42822. /**
  42823. * Called once for each button that changed state since the last frame
  42824. * @param buttonIdx Which button index changed
  42825. * @param state New state of the button
  42826. * @param changes Which properties on the state changed since last frame
  42827. */
  42828. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42829. /**
  42830. * Moves the buttons on the controller mesh based on their current state
  42831. * @param buttonName the name of the button to move
  42832. * @param buttonValue the value of the button which determines the buttons new position
  42833. */
  42834. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42835. /**
  42836. * Moves the axis on the controller mesh based on its current state
  42837. * @param axis the index of the axis
  42838. * @param axisValue the value of the axis which determines the meshes new position
  42839. * @hidden
  42840. */
  42841. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42842. /**
  42843. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42844. * @param scene scene in which to add meshes
  42845. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42846. */
  42847. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42848. /**
  42849. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42850. * can be transformed by button presses and axes values, based on this._mapping.
  42851. *
  42852. * @param scene scene in which the meshes exist
  42853. * @param meshes list of meshes that make up the controller model to process
  42854. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42855. */
  42856. private processModel;
  42857. private createMeshInfo;
  42858. /**
  42859. * Gets the ray of the controller in the direction the controller is pointing
  42860. * @param length the length the resulting ray should be
  42861. * @returns a ray in the direction the controller is pointing
  42862. */
  42863. getForwardRay(length?: number): Ray;
  42864. /**
  42865. * Disposes of the controller
  42866. */
  42867. dispose(): void;
  42868. }
  42869. }
  42870. declare module "babylonjs/Gamepads/Controllers/index" {
  42871. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42872. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42873. export * from "babylonjs/Gamepads/Controllers/genericController";
  42874. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42875. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42876. export * from "babylonjs/Gamepads/Controllers/viveController";
  42877. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42878. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42879. }
  42880. declare module "babylonjs/Gamepads/index" {
  42881. export * from "babylonjs/Gamepads/Controllers/index";
  42882. export * from "babylonjs/Gamepads/gamepad";
  42883. export * from "babylonjs/Gamepads/gamepadManager";
  42884. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42885. export * from "babylonjs/Gamepads/xboxGamepad";
  42886. }
  42887. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42888. import { Observable } from "babylonjs/Misc/observable";
  42889. import { Nullable } from "babylonjs/types";
  42890. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42892. import { Mesh } from "babylonjs/Meshes/mesh";
  42893. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42894. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42895. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42896. /**
  42897. * Single axis scale gizmo
  42898. */
  42899. export class AxisScaleGizmo extends Gizmo {
  42900. private _coloredMaterial;
  42901. /**
  42902. * Drag behavior responsible for the gizmos dragging interactions
  42903. */
  42904. dragBehavior: PointerDragBehavior;
  42905. private _pointerObserver;
  42906. /**
  42907. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42908. */
  42909. snapDistance: number;
  42910. /**
  42911. * Event that fires each time the gizmo snaps to a new location.
  42912. * * snapDistance is the the change in distance
  42913. */
  42914. onSnapObservable: Observable<{
  42915. snapDistance: number;
  42916. }>;
  42917. /**
  42918. * If the scaling operation should be done on all axis (default: false)
  42919. */
  42920. uniformScaling: boolean;
  42921. /**
  42922. * Creates an AxisScaleGizmo
  42923. * @param gizmoLayer The utility layer the gizmo will be added to
  42924. * @param dragAxis The axis which the gizmo will be able to scale on
  42925. * @param color The color of the gizmo
  42926. */
  42927. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42928. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42929. /**
  42930. * Disposes of the gizmo
  42931. */
  42932. dispose(): void;
  42933. /**
  42934. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42935. * @param mesh The mesh to replace the default mesh of the gizmo
  42936. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42937. */
  42938. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42939. }
  42940. }
  42941. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42942. import { Observable } from "babylonjs/Misc/observable";
  42943. import { Nullable } from "babylonjs/types";
  42944. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42946. import { Mesh } from "babylonjs/Meshes/mesh";
  42947. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42948. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42949. import "babylonjs/Meshes/Builders/boxBuilder";
  42950. /**
  42951. * Bounding box gizmo
  42952. */
  42953. export class BoundingBoxGizmo extends Gizmo {
  42954. private _lineBoundingBox;
  42955. private _rotateSpheresParent;
  42956. private _scaleBoxesParent;
  42957. private _boundingDimensions;
  42958. private _renderObserver;
  42959. private _pointerObserver;
  42960. private _scaleDragSpeed;
  42961. private _tmpQuaternion;
  42962. private _tmpVector;
  42963. private _tmpRotationMatrix;
  42964. /**
  42965. * 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)
  42966. */
  42967. ignoreChildren: boolean;
  42968. /**
  42969. * 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)
  42970. */
  42971. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42972. /**
  42973. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42974. */
  42975. rotationSphereSize: number;
  42976. /**
  42977. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42978. */
  42979. scaleBoxSize: number;
  42980. /**
  42981. * 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)
  42982. */
  42983. fixedDragMeshScreenSize: boolean;
  42984. /**
  42985. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42986. */
  42987. fixedDragMeshScreenSizeDistanceFactor: number;
  42988. /**
  42989. * Fired when a rotation sphere or scale box is dragged
  42990. */
  42991. onDragStartObservable: Observable<{}>;
  42992. /**
  42993. * Fired when a scale box is dragged
  42994. */
  42995. onScaleBoxDragObservable: Observable<{}>;
  42996. /**
  42997. * Fired when a scale box drag is ended
  42998. */
  42999. onScaleBoxDragEndObservable: Observable<{}>;
  43000. /**
  43001. * Fired when a rotation sphere is dragged
  43002. */
  43003. onRotationSphereDragObservable: Observable<{}>;
  43004. /**
  43005. * Fired when a rotation sphere drag is ended
  43006. */
  43007. onRotationSphereDragEndObservable: Observable<{}>;
  43008. /**
  43009. * 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)
  43010. */
  43011. scalePivot: Nullable<Vector3>;
  43012. private _anchorMesh;
  43013. private _existingMeshScale;
  43014. private _dragMesh;
  43015. private pointerDragBehavior;
  43016. private coloredMaterial;
  43017. private hoverColoredMaterial;
  43018. /**
  43019. * Sets the color of the bounding box gizmo
  43020. * @param color the color to set
  43021. */
  43022. setColor(color: Color3): void;
  43023. /**
  43024. * Creates an BoundingBoxGizmo
  43025. * @param gizmoLayer The utility layer the gizmo will be added to
  43026. * @param color The color of the gizmo
  43027. */
  43028. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43029. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43030. private _selectNode;
  43031. /**
  43032. * Updates the bounding box information for the Gizmo
  43033. */
  43034. updateBoundingBox(): void;
  43035. private _updateRotationSpheres;
  43036. private _updateScaleBoxes;
  43037. /**
  43038. * Enables rotation on the specified axis and disables rotation on the others
  43039. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43040. */
  43041. setEnabledRotationAxis(axis: string): void;
  43042. /**
  43043. * Enables/disables scaling
  43044. * @param enable if scaling should be enabled
  43045. */
  43046. setEnabledScaling(enable: boolean): void;
  43047. private _updateDummy;
  43048. /**
  43049. * Enables a pointer drag behavior on the bounding box of the gizmo
  43050. */
  43051. enableDragBehavior(): void;
  43052. /**
  43053. * Disposes of the gizmo
  43054. */
  43055. dispose(): void;
  43056. /**
  43057. * 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)
  43058. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43059. * @returns the bounding box mesh with the passed in mesh as a child
  43060. */
  43061. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43062. /**
  43063. * CustomMeshes are not supported by this gizmo
  43064. * @param mesh The mesh to replace the default mesh of the gizmo
  43065. */
  43066. setCustomMesh(mesh: Mesh): void;
  43067. }
  43068. }
  43069. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43070. import { Observable } from "babylonjs/Misc/observable";
  43071. import { Nullable } from "babylonjs/types";
  43072. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43074. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43075. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43076. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43077. import "babylonjs/Meshes/Builders/linesBuilder";
  43078. /**
  43079. * Single plane rotation gizmo
  43080. */
  43081. export class PlaneRotationGizmo extends Gizmo {
  43082. /**
  43083. * Drag behavior responsible for the gizmos dragging interactions
  43084. */
  43085. dragBehavior: PointerDragBehavior;
  43086. private _pointerObserver;
  43087. /**
  43088. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43089. */
  43090. snapDistance: number;
  43091. /**
  43092. * Event that fires each time the gizmo snaps to a new location.
  43093. * * snapDistance is the the change in distance
  43094. */
  43095. onSnapObservable: Observable<{
  43096. snapDistance: number;
  43097. }>;
  43098. /**
  43099. * Creates a PlaneRotationGizmo
  43100. * @param gizmoLayer The utility layer the gizmo will be added to
  43101. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43102. * @param color The color of the gizmo
  43103. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43104. */
  43105. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43106. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43107. /**
  43108. * Disposes of the gizmo
  43109. */
  43110. dispose(): void;
  43111. }
  43112. }
  43113. declare module "babylonjs/Gizmos/rotationGizmo" {
  43114. import { Observable } from "babylonjs/Misc/observable";
  43115. import { Nullable } from "babylonjs/types";
  43116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43117. import { Mesh } from "babylonjs/Meshes/mesh";
  43118. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43119. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43120. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43121. /**
  43122. * Gizmo that enables rotating a mesh along 3 axis
  43123. */
  43124. export class RotationGizmo extends Gizmo {
  43125. /**
  43126. * Internal gizmo used for interactions on the x axis
  43127. */
  43128. xGizmo: PlaneRotationGizmo;
  43129. /**
  43130. * Internal gizmo used for interactions on the y axis
  43131. */
  43132. yGizmo: PlaneRotationGizmo;
  43133. /**
  43134. * Internal gizmo used for interactions on the z axis
  43135. */
  43136. zGizmo: PlaneRotationGizmo;
  43137. /** Fires an event when any of it's sub gizmos are dragged */
  43138. onDragStartObservable: Observable<{}>;
  43139. /** Fires an event when any of it's sub gizmos are released from dragging */
  43140. onDragEndObservable: Observable<{}>;
  43141. attachedMesh: Nullable<AbstractMesh>;
  43142. /**
  43143. * Creates a RotationGizmo
  43144. * @param gizmoLayer The utility layer the gizmo will be added to
  43145. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43146. */
  43147. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43148. updateGizmoRotationToMatchAttachedMesh: boolean;
  43149. /**
  43150. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43151. */
  43152. snapDistance: number;
  43153. /**
  43154. * Ratio for the scale of the gizmo (Default: 1)
  43155. */
  43156. scaleRatio: number;
  43157. /**
  43158. * Disposes of the gizmo
  43159. */
  43160. dispose(): void;
  43161. /**
  43162. * CustomMeshes are not supported by this gizmo
  43163. * @param mesh The mesh to replace the default mesh of the gizmo
  43164. */
  43165. setCustomMesh(mesh: Mesh): void;
  43166. }
  43167. }
  43168. declare module "babylonjs/Gizmos/positionGizmo" {
  43169. import { Observable } from "babylonjs/Misc/observable";
  43170. import { Nullable } from "babylonjs/types";
  43171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43172. import { Mesh } from "babylonjs/Meshes/mesh";
  43173. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43174. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43175. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43176. /**
  43177. * Gizmo that enables dragging a mesh along 3 axis
  43178. */
  43179. export class PositionGizmo extends Gizmo {
  43180. /**
  43181. * Internal gizmo used for interactions on the x axis
  43182. */
  43183. xGizmo: AxisDragGizmo;
  43184. /**
  43185. * Internal gizmo used for interactions on the y axis
  43186. */
  43187. yGizmo: AxisDragGizmo;
  43188. /**
  43189. * Internal gizmo used for interactions on the z axis
  43190. */
  43191. zGizmo: AxisDragGizmo;
  43192. /** Fires an event when any of it's sub gizmos are dragged */
  43193. onDragStartObservable: Observable<{}>;
  43194. /** Fires an event when any of it's sub gizmos are released from dragging */
  43195. onDragEndObservable: Observable<{}>;
  43196. attachedMesh: Nullable<AbstractMesh>;
  43197. /**
  43198. * Creates a PositionGizmo
  43199. * @param gizmoLayer The utility layer the gizmo will be added to
  43200. */
  43201. constructor(gizmoLayer?: UtilityLayerRenderer);
  43202. updateGizmoRotationToMatchAttachedMesh: boolean;
  43203. /**
  43204. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43205. */
  43206. snapDistance: number;
  43207. /**
  43208. * Ratio for the scale of the gizmo (Default: 1)
  43209. */
  43210. scaleRatio: number;
  43211. /**
  43212. * Disposes of the gizmo
  43213. */
  43214. dispose(): void;
  43215. /**
  43216. * CustomMeshes are not supported by this gizmo
  43217. * @param mesh The mesh to replace the default mesh of the gizmo
  43218. */
  43219. setCustomMesh(mesh: Mesh): void;
  43220. }
  43221. }
  43222. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43223. import { Scene } from "babylonjs/scene";
  43224. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43225. import { Mesh } from "babylonjs/Meshes/mesh";
  43226. /**
  43227. * Class containing static functions to help procedurally build meshes
  43228. */
  43229. export class PolyhedronBuilder {
  43230. /**
  43231. * Creates a polyhedron mesh
  43232. * * 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
  43233. * * The parameter `size` (positive float, default 1) sets the polygon size
  43234. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43235. * * 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`
  43236. * * 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
  43237. * * 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)`)
  43238. * * 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
  43239. * * 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
  43240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43241. * * If you create a double-sided mesh, you can choose what parts of 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
  43242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43243. * @param name defines the name of the mesh
  43244. * @param options defines the options used to create the mesh
  43245. * @param scene defines the hosting scene
  43246. * @returns the polyhedron mesh
  43247. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43248. */
  43249. static CreatePolyhedron(name: string, options: {
  43250. type?: number;
  43251. size?: number;
  43252. sizeX?: number;
  43253. sizeY?: number;
  43254. sizeZ?: number;
  43255. custom?: any;
  43256. faceUV?: Vector4[];
  43257. faceColors?: Color4[];
  43258. flat?: boolean;
  43259. updatable?: boolean;
  43260. sideOrientation?: number;
  43261. frontUVs?: Vector4;
  43262. backUVs?: Vector4;
  43263. }, scene: Scene): Mesh;
  43264. }
  43265. }
  43266. declare module "babylonjs/Gizmos/scaleGizmo" {
  43267. import { Observable } from "babylonjs/Misc/observable";
  43268. import { Nullable } from "babylonjs/types";
  43269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43270. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43271. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43272. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43273. /**
  43274. * Gizmo that enables scaling a mesh along 3 axis
  43275. */
  43276. export class ScaleGizmo extends Gizmo {
  43277. /**
  43278. * Internal gizmo used for interactions on the x axis
  43279. */
  43280. xGizmo: AxisScaleGizmo;
  43281. /**
  43282. * Internal gizmo used for interactions on the y axis
  43283. */
  43284. yGizmo: AxisScaleGizmo;
  43285. /**
  43286. * Internal gizmo used for interactions on the z axis
  43287. */
  43288. zGizmo: AxisScaleGizmo;
  43289. /**
  43290. * Internal gizmo used to scale all axis equally
  43291. */
  43292. uniformScaleGizmo: AxisScaleGizmo;
  43293. /** Fires an event when any of it's sub gizmos are dragged */
  43294. onDragStartObservable: Observable<{}>;
  43295. /** Fires an event when any of it's sub gizmos are released from dragging */
  43296. onDragEndObservable: Observable<{}>;
  43297. attachedMesh: Nullable<AbstractMesh>;
  43298. /**
  43299. * Creates a ScaleGizmo
  43300. * @param gizmoLayer The utility layer the gizmo will be added to
  43301. */
  43302. constructor(gizmoLayer?: UtilityLayerRenderer);
  43303. updateGizmoRotationToMatchAttachedMesh: boolean;
  43304. /**
  43305. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43306. */
  43307. snapDistance: number;
  43308. /**
  43309. * Ratio for the scale of the gizmo (Default: 1)
  43310. */
  43311. scaleRatio: number;
  43312. /**
  43313. * Disposes of the gizmo
  43314. */
  43315. dispose(): void;
  43316. }
  43317. }
  43318. declare module "babylonjs/Gizmos/gizmoManager" {
  43319. import { Observable } from "babylonjs/Misc/observable";
  43320. import { Nullable } from "babylonjs/types";
  43321. import { Scene, IDisposable } from "babylonjs/scene";
  43322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43323. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43324. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43325. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43326. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43327. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43328. /**
  43329. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43330. */
  43331. export class GizmoManager implements IDisposable {
  43332. private scene;
  43333. /**
  43334. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43335. */
  43336. gizmos: {
  43337. positionGizmo: Nullable<PositionGizmo>;
  43338. rotationGizmo: Nullable<RotationGizmo>;
  43339. scaleGizmo: Nullable<ScaleGizmo>;
  43340. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43341. };
  43342. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43343. clearGizmoOnEmptyPointerEvent: boolean;
  43344. /** Fires an event when the manager is attached to a mesh */
  43345. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43346. private _gizmosEnabled;
  43347. private _pointerObserver;
  43348. private _attachedMesh;
  43349. private _boundingBoxColor;
  43350. private _defaultUtilityLayer;
  43351. private _defaultKeepDepthUtilityLayer;
  43352. /**
  43353. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43354. */
  43355. boundingBoxDragBehavior: SixDofDragBehavior;
  43356. /**
  43357. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43358. */
  43359. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43360. /**
  43361. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43362. */
  43363. usePointerToAttachGizmos: boolean;
  43364. /**
  43365. * Instatiates a gizmo manager
  43366. * @param scene the scene to overlay the gizmos on top of
  43367. */
  43368. constructor(scene: Scene);
  43369. /**
  43370. * Attaches a set of gizmos to the specified mesh
  43371. * @param mesh The mesh the gizmo's should be attached to
  43372. */
  43373. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43374. /**
  43375. * If the position gizmo is enabled
  43376. */
  43377. positionGizmoEnabled: boolean;
  43378. /**
  43379. * If the rotation gizmo is enabled
  43380. */
  43381. rotationGizmoEnabled: boolean;
  43382. /**
  43383. * If the scale gizmo is enabled
  43384. */
  43385. scaleGizmoEnabled: boolean;
  43386. /**
  43387. * If the boundingBox gizmo is enabled
  43388. */
  43389. boundingBoxGizmoEnabled: boolean;
  43390. /**
  43391. * Disposes of the gizmo manager
  43392. */
  43393. dispose(): void;
  43394. }
  43395. }
  43396. declare module "babylonjs/Gizmos/lightGizmo" {
  43397. import { Nullable } from "babylonjs/types";
  43398. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43399. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43400. import { Light } from "babylonjs/Lights/light";
  43401. /**
  43402. * Gizmo that enables viewing a light
  43403. */
  43404. export class LightGizmo extends Gizmo {
  43405. private _box;
  43406. /**
  43407. * Creates a LightGizmo
  43408. * @param gizmoLayer The utility layer the gizmo will be added to
  43409. */
  43410. constructor(gizmoLayer?: UtilityLayerRenderer);
  43411. private _light;
  43412. /**
  43413. * The light that the gizmo is attached to
  43414. */
  43415. light: Nullable<Light>;
  43416. /**
  43417. * @hidden
  43418. * Updates the gizmo to match the attached mesh's position/rotation
  43419. */
  43420. protected _update(): void;
  43421. }
  43422. }
  43423. declare module "babylonjs/Gizmos/index" {
  43424. export * from "babylonjs/Gizmos/axisDragGizmo";
  43425. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43426. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43427. export * from "babylonjs/Gizmos/gizmo";
  43428. export * from "babylonjs/Gizmos/gizmoManager";
  43429. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43430. export * from "babylonjs/Gizmos/positionGizmo";
  43431. export * from "babylonjs/Gizmos/rotationGizmo";
  43432. export * from "babylonjs/Gizmos/scaleGizmo";
  43433. export * from "babylonjs/Gizmos/lightGizmo";
  43434. }
  43435. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43436. /** @hidden */
  43437. export var backgroundFragmentDeclaration: {
  43438. name: string;
  43439. shader: string;
  43440. };
  43441. }
  43442. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43443. /** @hidden */
  43444. export var backgroundUboDeclaration: {
  43445. name: string;
  43446. shader: string;
  43447. };
  43448. }
  43449. declare module "babylonjs/Shaders/background.fragment" {
  43450. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43451. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43452. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43453. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43454. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43455. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43456. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43457. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43458. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43459. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43460. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43461. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43462. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43463. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43464. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43465. /** @hidden */
  43466. export var backgroundPixelShader: {
  43467. name: string;
  43468. shader: string;
  43469. };
  43470. }
  43471. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43472. /** @hidden */
  43473. export var backgroundVertexDeclaration: {
  43474. name: string;
  43475. shader: string;
  43476. };
  43477. }
  43478. declare module "babylonjs/Shaders/background.vertex" {
  43479. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43480. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43481. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43482. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43483. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43484. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43485. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43486. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43487. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43488. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43489. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43490. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43491. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43492. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43493. /** @hidden */
  43494. export var backgroundVertexShader: {
  43495. name: string;
  43496. shader: string;
  43497. };
  43498. }
  43499. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43500. import { Nullable, int, float } from "babylonjs/types";
  43501. import { Scene } from "babylonjs/scene";
  43502. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43503. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43505. import { Mesh } from "babylonjs/Meshes/mesh";
  43506. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43507. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43508. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43509. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43510. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43511. import "babylonjs/Shaders/background.fragment";
  43512. import "babylonjs/Shaders/background.vertex";
  43513. /**
  43514. * Background material used to create an efficient environement around your scene.
  43515. */
  43516. export class BackgroundMaterial extends PushMaterial {
  43517. /**
  43518. * Standard reflectance value at parallel view angle.
  43519. */
  43520. static StandardReflectance0: number;
  43521. /**
  43522. * Standard reflectance value at grazing angle.
  43523. */
  43524. static StandardReflectance90: number;
  43525. protected _primaryColor: Color3;
  43526. /**
  43527. * Key light Color (multiply against the environement texture)
  43528. */
  43529. primaryColor: Color3;
  43530. protected __perceptualColor: Nullable<Color3>;
  43531. /**
  43532. * Experimental Internal Use Only.
  43533. *
  43534. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43535. * This acts as a helper to set the primary color to a more "human friendly" value.
  43536. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43537. * output color as close as possible from the chosen value.
  43538. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43539. * part of lighting setup.)
  43540. */
  43541. _perceptualColor: Nullable<Color3>;
  43542. protected _primaryColorShadowLevel: float;
  43543. /**
  43544. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43545. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43546. */
  43547. primaryColorShadowLevel: float;
  43548. protected _primaryColorHighlightLevel: float;
  43549. /**
  43550. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43551. * The primary color is used at the level chosen to define what the white area would look.
  43552. */
  43553. primaryColorHighlightLevel: float;
  43554. protected _reflectionTexture: Nullable<BaseTexture>;
  43555. /**
  43556. * Reflection Texture used in the material.
  43557. * Should be author in a specific way for the best result (refer to the documentation).
  43558. */
  43559. reflectionTexture: Nullable<BaseTexture>;
  43560. protected _reflectionBlur: float;
  43561. /**
  43562. * Reflection Texture level of blur.
  43563. *
  43564. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43565. * texture twice.
  43566. */
  43567. reflectionBlur: float;
  43568. protected _diffuseTexture: Nullable<BaseTexture>;
  43569. /**
  43570. * Diffuse Texture used in the material.
  43571. * Should be author in a specific way for the best result (refer to the documentation).
  43572. */
  43573. diffuseTexture: Nullable<BaseTexture>;
  43574. protected _shadowLights: Nullable<IShadowLight[]>;
  43575. /**
  43576. * Specify the list of lights casting shadow on the material.
  43577. * All scene shadow lights will be included if null.
  43578. */
  43579. shadowLights: Nullable<IShadowLight[]>;
  43580. protected _shadowLevel: float;
  43581. /**
  43582. * Helps adjusting the shadow to a softer level if required.
  43583. * 0 means black shadows and 1 means no shadows.
  43584. */
  43585. shadowLevel: float;
  43586. protected _sceneCenter: Vector3;
  43587. /**
  43588. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43589. * It is usually zero but might be interesting to modify according to your setup.
  43590. */
  43591. sceneCenter: Vector3;
  43592. protected _opacityFresnel: boolean;
  43593. /**
  43594. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43595. * This helps ensuring a nice transition when the camera goes under the ground.
  43596. */
  43597. opacityFresnel: boolean;
  43598. protected _reflectionFresnel: boolean;
  43599. /**
  43600. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43601. * This helps adding a mirror texture on the ground.
  43602. */
  43603. reflectionFresnel: boolean;
  43604. protected _reflectionFalloffDistance: number;
  43605. /**
  43606. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43607. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43608. */
  43609. reflectionFalloffDistance: number;
  43610. protected _reflectionAmount: number;
  43611. /**
  43612. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43613. */
  43614. reflectionAmount: number;
  43615. protected _reflectionReflectance0: number;
  43616. /**
  43617. * This specifies the weight of the reflection at grazing angle.
  43618. */
  43619. reflectionReflectance0: number;
  43620. protected _reflectionReflectance90: number;
  43621. /**
  43622. * This specifies the weight of the reflection at a perpendicular point of view.
  43623. */
  43624. reflectionReflectance90: number;
  43625. /**
  43626. * Sets the reflection reflectance fresnel values according to the default standard
  43627. * empirically know to work well :-)
  43628. */
  43629. reflectionStandardFresnelWeight: number;
  43630. protected _useRGBColor: boolean;
  43631. /**
  43632. * Helps to directly use the maps channels instead of their level.
  43633. */
  43634. useRGBColor: boolean;
  43635. protected _enableNoise: boolean;
  43636. /**
  43637. * This helps reducing the banding effect that could occur on the background.
  43638. */
  43639. enableNoise: boolean;
  43640. /**
  43641. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43642. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43643. * Recommended to be keep at 1.0 except for special cases.
  43644. */
  43645. fovMultiplier: number;
  43646. private _fovMultiplier;
  43647. /**
  43648. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43649. */
  43650. useEquirectangularFOV: boolean;
  43651. private _maxSimultaneousLights;
  43652. /**
  43653. * Number of Simultaneous lights allowed on the material.
  43654. */
  43655. maxSimultaneousLights: int;
  43656. /**
  43657. * Default configuration related to image processing available in the Background Material.
  43658. */
  43659. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43660. /**
  43661. * Keep track of the image processing observer to allow dispose and replace.
  43662. */
  43663. private _imageProcessingObserver;
  43664. /**
  43665. * Attaches a new image processing configuration to the PBR Material.
  43666. * @param configuration (if null the scene configuration will be use)
  43667. */
  43668. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43669. /**
  43670. * Gets the image processing configuration used either in this material.
  43671. */
  43672. /**
  43673. * Sets the Default image processing configuration used either in the this material.
  43674. *
  43675. * If sets to null, the scene one is in use.
  43676. */
  43677. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43678. /**
  43679. * Gets wether the color curves effect is enabled.
  43680. */
  43681. /**
  43682. * Sets wether the color curves effect is enabled.
  43683. */
  43684. cameraColorCurvesEnabled: boolean;
  43685. /**
  43686. * Gets wether the color grading effect is enabled.
  43687. */
  43688. /**
  43689. * Gets wether the color grading effect is enabled.
  43690. */
  43691. cameraColorGradingEnabled: boolean;
  43692. /**
  43693. * Gets wether tonemapping is enabled or not.
  43694. */
  43695. /**
  43696. * Sets wether tonemapping is enabled or not
  43697. */
  43698. cameraToneMappingEnabled: boolean;
  43699. /**
  43700. * The camera exposure used on this material.
  43701. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43702. * This corresponds to a photographic exposure.
  43703. */
  43704. /**
  43705. * The camera exposure used on this material.
  43706. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43707. * This corresponds to a photographic exposure.
  43708. */
  43709. cameraExposure: float;
  43710. /**
  43711. * Gets The camera contrast used on this material.
  43712. */
  43713. /**
  43714. * Sets The camera contrast used on this material.
  43715. */
  43716. cameraContrast: float;
  43717. /**
  43718. * Gets the Color Grading 2D Lookup Texture.
  43719. */
  43720. /**
  43721. * Sets the Color Grading 2D Lookup Texture.
  43722. */
  43723. cameraColorGradingTexture: Nullable<BaseTexture>;
  43724. /**
  43725. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43726. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43727. * 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;
  43728. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43729. */
  43730. /**
  43731. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43732. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43733. * 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;
  43734. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43735. */
  43736. cameraColorCurves: Nullable<ColorCurves>;
  43737. /**
  43738. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43739. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43740. */
  43741. switchToBGR: boolean;
  43742. private _renderTargets;
  43743. private _reflectionControls;
  43744. private _white;
  43745. private _primaryShadowColor;
  43746. private _primaryHighlightColor;
  43747. /**
  43748. * Instantiates a Background Material in the given scene
  43749. * @param name The friendly name of the material
  43750. * @param scene The scene to add the material to
  43751. */
  43752. constructor(name: string, scene: Scene);
  43753. /**
  43754. * Gets a boolean indicating that current material needs to register RTT
  43755. */
  43756. readonly hasRenderTargetTextures: boolean;
  43757. /**
  43758. * The entire material has been created in order to prevent overdraw.
  43759. * @returns false
  43760. */
  43761. needAlphaTesting(): boolean;
  43762. /**
  43763. * The entire material has been created in order to prevent overdraw.
  43764. * @returns true if blending is enable
  43765. */
  43766. needAlphaBlending(): boolean;
  43767. /**
  43768. * Checks wether the material is ready to be rendered for a given mesh.
  43769. * @param mesh The mesh to render
  43770. * @param subMesh The submesh to check against
  43771. * @param useInstances Specify wether or not the material is used with instances
  43772. * @returns true if all the dependencies are ready (Textures, Effects...)
  43773. */
  43774. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43775. /**
  43776. * Compute the primary color according to the chosen perceptual color.
  43777. */
  43778. private _computePrimaryColorFromPerceptualColor;
  43779. /**
  43780. * Compute the highlights and shadow colors according to their chosen levels.
  43781. */
  43782. private _computePrimaryColors;
  43783. /**
  43784. * Build the uniform buffer used in the material.
  43785. */
  43786. buildUniformLayout(): void;
  43787. /**
  43788. * Unbind the material.
  43789. */
  43790. unbind(): void;
  43791. /**
  43792. * Bind only the world matrix to the material.
  43793. * @param world The world matrix to bind.
  43794. */
  43795. bindOnlyWorldMatrix(world: Matrix): void;
  43796. /**
  43797. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43798. * @param world The world matrix to bind.
  43799. * @param subMesh The submesh to bind for.
  43800. */
  43801. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43802. /**
  43803. * Dispose the material.
  43804. * @param forceDisposeEffect Force disposal of the associated effect.
  43805. * @param forceDisposeTextures Force disposal of the associated textures.
  43806. */
  43807. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43808. /**
  43809. * Clones the material.
  43810. * @param name The cloned name.
  43811. * @returns The cloned material.
  43812. */
  43813. clone(name: string): BackgroundMaterial;
  43814. /**
  43815. * Serializes the current material to its JSON representation.
  43816. * @returns The JSON representation.
  43817. */
  43818. serialize(): any;
  43819. /**
  43820. * Gets the class name of the material
  43821. * @returns "BackgroundMaterial"
  43822. */
  43823. getClassName(): string;
  43824. /**
  43825. * Parse a JSON input to create back a background material.
  43826. * @param source The JSON data to parse
  43827. * @param scene The scene to create the parsed material in
  43828. * @param rootUrl The root url of the assets the material depends upon
  43829. * @returns the instantiated BackgroundMaterial.
  43830. */
  43831. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43832. }
  43833. }
  43834. declare module "babylonjs/Helpers/environmentHelper" {
  43835. import { Observable } from "babylonjs/Misc/observable";
  43836. import { Nullable } from "babylonjs/types";
  43837. import { Scene } from "babylonjs/scene";
  43838. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43840. import { Mesh } from "babylonjs/Meshes/mesh";
  43841. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43842. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43843. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43844. import "babylonjs/Meshes/Builders/planeBuilder";
  43845. import "babylonjs/Meshes/Builders/boxBuilder";
  43846. /**
  43847. * Represents the different options available during the creation of
  43848. * a Environment helper.
  43849. *
  43850. * This can control the default ground, skybox and image processing setup of your scene.
  43851. */
  43852. export interface IEnvironmentHelperOptions {
  43853. /**
  43854. * Specifies wether or not to create a ground.
  43855. * True by default.
  43856. */
  43857. createGround: boolean;
  43858. /**
  43859. * Specifies the ground size.
  43860. * 15 by default.
  43861. */
  43862. groundSize: number;
  43863. /**
  43864. * The texture used on the ground for the main color.
  43865. * Comes from the BabylonJS CDN by default.
  43866. *
  43867. * Remarks: Can be either a texture or a url.
  43868. */
  43869. groundTexture: string | BaseTexture;
  43870. /**
  43871. * The color mixed in the ground texture by default.
  43872. * BabylonJS clearColor by default.
  43873. */
  43874. groundColor: Color3;
  43875. /**
  43876. * Specifies the ground opacity.
  43877. * 1 by default.
  43878. */
  43879. groundOpacity: number;
  43880. /**
  43881. * Enables the ground to receive shadows.
  43882. * True by default.
  43883. */
  43884. enableGroundShadow: boolean;
  43885. /**
  43886. * Helps preventing the shadow to be fully black on the ground.
  43887. * 0.5 by default.
  43888. */
  43889. groundShadowLevel: number;
  43890. /**
  43891. * Creates a mirror texture attach to the ground.
  43892. * false by default.
  43893. */
  43894. enableGroundMirror: boolean;
  43895. /**
  43896. * Specifies the ground mirror size ratio.
  43897. * 0.3 by default as the default kernel is 64.
  43898. */
  43899. groundMirrorSizeRatio: number;
  43900. /**
  43901. * Specifies the ground mirror blur kernel size.
  43902. * 64 by default.
  43903. */
  43904. groundMirrorBlurKernel: number;
  43905. /**
  43906. * Specifies the ground mirror visibility amount.
  43907. * 1 by default
  43908. */
  43909. groundMirrorAmount: number;
  43910. /**
  43911. * Specifies the ground mirror reflectance weight.
  43912. * This uses the standard weight of the background material to setup the fresnel effect
  43913. * of the mirror.
  43914. * 1 by default.
  43915. */
  43916. groundMirrorFresnelWeight: number;
  43917. /**
  43918. * Specifies the ground mirror Falloff distance.
  43919. * This can helps reducing the size of the reflection.
  43920. * 0 by Default.
  43921. */
  43922. groundMirrorFallOffDistance: number;
  43923. /**
  43924. * Specifies the ground mirror texture type.
  43925. * Unsigned Int by Default.
  43926. */
  43927. groundMirrorTextureType: number;
  43928. /**
  43929. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43930. * the shown objects.
  43931. */
  43932. groundYBias: number;
  43933. /**
  43934. * Specifies wether or not to create a skybox.
  43935. * True by default.
  43936. */
  43937. createSkybox: boolean;
  43938. /**
  43939. * Specifies the skybox size.
  43940. * 20 by default.
  43941. */
  43942. skyboxSize: number;
  43943. /**
  43944. * The texture used on the skybox for the main color.
  43945. * Comes from the BabylonJS CDN by default.
  43946. *
  43947. * Remarks: Can be either a texture or a url.
  43948. */
  43949. skyboxTexture: string | BaseTexture;
  43950. /**
  43951. * The color mixed in the skybox texture by default.
  43952. * BabylonJS clearColor by default.
  43953. */
  43954. skyboxColor: Color3;
  43955. /**
  43956. * The background rotation around the Y axis of the scene.
  43957. * This helps aligning the key lights of your scene with the background.
  43958. * 0 by default.
  43959. */
  43960. backgroundYRotation: number;
  43961. /**
  43962. * Compute automatically the size of the elements to best fit with the scene.
  43963. */
  43964. sizeAuto: boolean;
  43965. /**
  43966. * Default position of the rootMesh if autoSize is not true.
  43967. */
  43968. rootPosition: Vector3;
  43969. /**
  43970. * Sets up the image processing in the scene.
  43971. * true by default.
  43972. */
  43973. setupImageProcessing: boolean;
  43974. /**
  43975. * The texture used as your environment texture in the scene.
  43976. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43977. *
  43978. * Remarks: Can be either a texture or a url.
  43979. */
  43980. environmentTexture: string | BaseTexture;
  43981. /**
  43982. * The value of the exposure to apply to the scene.
  43983. * 0.6 by default if setupImageProcessing is true.
  43984. */
  43985. cameraExposure: number;
  43986. /**
  43987. * The value of the contrast to apply to the scene.
  43988. * 1.6 by default if setupImageProcessing is true.
  43989. */
  43990. cameraContrast: number;
  43991. /**
  43992. * Specifies wether or not tonemapping should be enabled in the scene.
  43993. * true by default if setupImageProcessing is true.
  43994. */
  43995. toneMappingEnabled: boolean;
  43996. }
  43997. /**
  43998. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43999. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44000. * It also helps with the default setup of your imageProcessing configuration.
  44001. */
  44002. export class EnvironmentHelper {
  44003. /**
  44004. * Default ground texture URL.
  44005. */
  44006. private static _groundTextureCDNUrl;
  44007. /**
  44008. * Default skybox texture URL.
  44009. */
  44010. private static _skyboxTextureCDNUrl;
  44011. /**
  44012. * Default environment texture URL.
  44013. */
  44014. private static _environmentTextureCDNUrl;
  44015. /**
  44016. * Creates the default options for the helper.
  44017. */
  44018. private static _getDefaultOptions;
  44019. private _rootMesh;
  44020. /**
  44021. * Gets the root mesh created by the helper.
  44022. */
  44023. readonly rootMesh: Mesh;
  44024. private _skybox;
  44025. /**
  44026. * Gets the skybox created by the helper.
  44027. */
  44028. readonly skybox: Nullable<Mesh>;
  44029. private _skyboxTexture;
  44030. /**
  44031. * Gets the skybox texture created by the helper.
  44032. */
  44033. readonly skyboxTexture: Nullable<BaseTexture>;
  44034. private _skyboxMaterial;
  44035. /**
  44036. * Gets the skybox material created by the helper.
  44037. */
  44038. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44039. private _ground;
  44040. /**
  44041. * Gets the ground mesh created by the helper.
  44042. */
  44043. readonly ground: Nullable<Mesh>;
  44044. private _groundTexture;
  44045. /**
  44046. * Gets the ground texture created by the helper.
  44047. */
  44048. readonly groundTexture: Nullable<BaseTexture>;
  44049. private _groundMirror;
  44050. /**
  44051. * Gets the ground mirror created by the helper.
  44052. */
  44053. readonly groundMirror: Nullable<MirrorTexture>;
  44054. /**
  44055. * Gets the ground mirror render list to helps pushing the meshes
  44056. * you wish in the ground reflection.
  44057. */
  44058. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44059. private _groundMaterial;
  44060. /**
  44061. * Gets the ground material created by the helper.
  44062. */
  44063. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44064. /**
  44065. * Stores the creation options.
  44066. */
  44067. private readonly _scene;
  44068. private _options;
  44069. /**
  44070. * This observable will be notified with any error during the creation of the environment,
  44071. * mainly texture creation errors.
  44072. */
  44073. onErrorObservable: Observable<{
  44074. message?: string;
  44075. exception?: any;
  44076. }>;
  44077. /**
  44078. * constructor
  44079. * @param options Defines the options we want to customize the helper
  44080. * @param scene The scene to add the material to
  44081. */
  44082. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44083. /**
  44084. * Updates the background according to the new options
  44085. * @param options
  44086. */
  44087. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44088. /**
  44089. * Sets the primary color of all the available elements.
  44090. * @param color the main color to affect to the ground and the background
  44091. */
  44092. setMainColor(color: Color3): void;
  44093. /**
  44094. * Setup the image processing according to the specified options.
  44095. */
  44096. private _setupImageProcessing;
  44097. /**
  44098. * Setup the environment texture according to the specified options.
  44099. */
  44100. private _setupEnvironmentTexture;
  44101. /**
  44102. * Setup the background according to the specified options.
  44103. */
  44104. private _setupBackground;
  44105. /**
  44106. * Get the scene sizes according to the setup.
  44107. */
  44108. private _getSceneSize;
  44109. /**
  44110. * Setup the ground according to the specified options.
  44111. */
  44112. private _setupGround;
  44113. /**
  44114. * Setup the ground material according to the specified options.
  44115. */
  44116. private _setupGroundMaterial;
  44117. /**
  44118. * Setup the ground diffuse texture according to the specified options.
  44119. */
  44120. private _setupGroundDiffuseTexture;
  44121. /**
  44122. * Setup the ground mirror texture according to the specified options.
  44123. */
  44124. private _setupGroundMirrorTexture;
  44125. /**
  44126. * Setup the ground to receive the mirror texture.
  44127. */
  44128. private _setupMirrorInGroundMaterial;
  44129. /**
  44130. * Setup the skybox according to the specified options.
  44131. */
  44132. private _setupSkybox;
  44133. /**
  44134. * Setup the skybox material according to the specified options.
  44135. */
  44136. private _setupSkyboxMaterial;
  44137. /**
  44138. * Setup the skybox reflection texture according to the specified options.
  44139. */
  44140. private _setupSkyboxReflectionTexture;
  44141. private _errorHandler;
  44142. /**
  44143. * Dispose all the elements created by the Helper.
  44144. */
  44145. dispose(): void;
  44146. }
  44147. }
  44148. declare module "babylonjs/Helpers/photoDome" {
  44149. import { Observable } from "babylonjs/Misc/observable";
  44150. import { Nullable } from "babylonjs/types";
  44151. import { Scene } from "babylonjs/scene";
  44152. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44153. import { Mesh } from "babylonjs/Meshes/mesh";
  44154. import { Texture } from "babylonjs/Materials/Textures/texture";
  44155. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44156. import "babylonjs/Meshes/Builders/sphereBuilder";
  44157. /**
  44158. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44159. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44160. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44161. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44162. */
  44163. export class PhotoDome extends TransformNode {
  44164. private _useDirectMapping;
  44165. /**
  44166. * The texture being displayed on the sphere
  44167. */
  44168. protected _photoTexture: Texture;
  44169. /**
  44170. * Gets or sets the texture being displayed on the sphere
  44171. */
  44172. photoTexture: Texture;
  44173. /**
  44174. * Observable raised when an error occured while loading the 360 image
  44175. */
  44176. onLoadErrorObservable: Observable<string>;
  44177. /**
  44178. * The skybox material
  44179. */
  44180. protected _material: BackgroundMaterial;
  44181. /**
  44182. * The surface used for the skybox
  44183. */
  44184. protected _mesh: Mesh;
  44185. /**
  44186. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44187. * Also see the options.resolution property.
  44188. */
  44189. fovMultiplier: number;
  44190. /**
  44191. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44192. * @param name Element's name, child elements will append suffixes for their own names.
  44193. * @param urlsOfPhoto defines the url of the photo to display
  44194. * @param options defines an object containing optional or exposed sub element properties
  44195. * @param onError defines a callback called when an error occured while loading the texture
  44196. */
  44197. constructor(name: string, urlOfPhoto: string, options: {
  44198. resolution?: number;
  44199. size?: number;
  44200. useDirectMapping?: boolean;
  44201. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44202. /**
  44203. * Releases resources associated with this node.
  44204. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44205. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44206. */
  44207. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44208. }
  44209. }
  44210. declare module "babylonjs/Misc/textureTools" {
  44211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44212. import { Texture } from "babylonjs/Materials/Textures/texture";
  44213. import { Scene } from "babylonjs/scene";
  44214. /**
  44215. * Class used to host texture specific utilities
  44216. */
  44217. export class TextureTools {
  44218. /**
  44219. * Uses the GPU to create a copy texture rescaled at a given size
  44220. * @param texture Texture to copy from
  44221. * @param width defines the desired width
  44222. * @param height defines the desired height
  44223. * @param useBilinearMode defines if bilinear mode has to be used
  44224. * @return the generated texture
  44225. */
  44226. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44227. /**
  44228. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44229. * @param scene defines the hosting scene
  44230. * @returns the environment BRDF texture
  44231. */
  44232. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44233. private static _environmentBRDFBase64Texture;
  44234. }
  44235. }
  44236. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44237. import { Nullable } from "babylonjs/types";
  44238. import { IAnimatable } from "babylonjs/Misc/tools";
  44239. import { Color3 } from "babylonjs/Maths/math";
  44240. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44241. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44242. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44243. import { Engine } from "babylonjs/Engines/engine";
  44244. import { Scene } from "babylonjs/scene";
  44245. /**
  44246. * @hidden
  44247. */
  44248. export interface IMaterialClearCoatDefines {
  44249. CLEARCOAT: boolean;
  44250. CLEARCOAT_DEFAULTIOR: boolean;
  44251. CLEARCOAT_TEXTURE: boolean;
  44252. CLEARCOAT_TEXTUREDIRECTUV: number;
  44253. CLEARCOAT_BUMP: boolean;
  44254. CLEARCOAT_BUMPDIRECTUV: number;
  44255. CLEARCOAT_TINT: boolean;
  44256. CLEARCOAT_TINT_TEXTURE: boolean;
  44257. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44258. /** @hidden */
  44259. _areTexturesDirty: boolean;
  44260. }
  44261. /**
  44262. * Define the code related to the clear coat parameters of the pbr material.
  44263. */
  44264. export class PBRClearCoatConfiguration {
  44265. /**
  44266. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44267. * The default fits with a polyurethane material.
  44268. */
  44269. private static readonly _DefaultIndiceOfRefraction;
  44270. private _isEnabled;
  44271. /**
  44272. * Defines if the clear coat is enabled in the material.
  44273. */
  44274. isEnabled: boolean;
  44275. /**
  44276. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44277. */
  44278. intensity: number;
  44279. /**
  44280. * Defines the clear coat layer roughness.
  44281. */
  44282. roughness: number;
  44283. private _indiceOfRefraction;
  44284. /**
  44285. * Defines the indice of refraction of the clear coat.
  44286. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44287. * The default fits with a polyurethane material.
  44288. * Changing the default value is more performance intensive.
  44289. */
  44290. indiceOfRefraction: number;
  44291. private _texture;
  44292. /**
  44293. * Stores the clear coat values in a texture.
  44294. */
  44295. texture: Nullable<BaseTexture>;
  44296. private _bumpTexture;
  44297. /**
  44298. * Define the clear coat specific bump texture.
  44299. */
  44300. bumpTexture: Nullable<BaseTexture>;
  44301. private _isTintEnabled;
  44302. /**
  44303. * Defines if the clear coat tint is enabled in the material.
  44304. */
  44305. isTintEnabled: boolean;
  44306. /**
  44307. * Defines if the clear coat tint is enabled in the material.
  44308. * This is only use if tint is enabled
  44309. */
  44310. tintColor: Color3;
  44311. /**
  44312. * Defines if the distance at which the tint color should be found in the
  44313. * clear coat media.
  44314. * This is only use if tint is enabled
  44315. */
  44316. tintColorAtDistance: number;
  44317. /**
  44318. * Defines the clear coat layer thickness.
  44319. * This is only use if tint is enabled
  44320. */
  44321. tintThickness: number;
  44322. private _tintTexture;
  44323. /**
  44324. * Stores the clear tint values in a texture.
  44325. * rgb is tint
  44326. * a is a thickness factor
  44327. */
  44328. tintTexture: Nullable<BaseTexture>;
  44329. /** @hidden */
  44330. private _internalMarkAllSubMeshesAsTexturesDirty;
  44331. /** @hidden */
  44332. _markAllSubMeshesAsTexturesDirty(): void;
  44333. /**
  44334. * Instantiate a new istance of clear coat configuration.
  44335. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44336. */
  44337. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44338. /**
  44339. * Specifies that the submesh is ready to be used.
  44340. * @param defines the list of "defines" to update.
  44341. * @param scene defines the scene the material belongs to.
  44342. * @param engine defines the engine the material belongs to.
  44343. * @param disableBumpMap defines wether the material disables bump or not.
  44344. * @returns - boolean indicating that the submesh is ready or not.
  44345. */
  44346. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44347. /**
  44348. * Checks to see if a texture is used in the material.
  44349. * @param defines the list of "defines" to update.
  44350. * @param scene defines the scene to the material belongs to.
  44351. */
  44352. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44353. /**
  44354. * Binds the material data.
  44355. * @param uniformBuffer defines the Uniform buffer to fill in.
  44356. * @param scene defines the scene the material belongs to.
  44357. * @param engine defines the engine the material belongs to.
  44358. * @param disableBumpMap defines wether the material disables bump or not.
  44359. * @param isFrozen defines wether the material is frozen or not.
  44360. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44361. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44362. */
  44363. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44364. /**
  44365. * Checks to see if a texture is used in the material.
  44366. * @param texture - Base texture to use.
  44367. * @returns - Boolean specifying if a texture is used in the material.
  44368. */
  44369. hasTexture(texture: BaseTexture): boolean;
  44370. /**
  44371. * Returns an array of the actively used textures.
  44372. * @param activeTextures Array of BaseTextures
  44373. */
  44374. getActiveTextures(activeTextures: BaseTexture[]): void;
  44375. /**
  44376. * Returns the animatable textures.
  44377. * @param animatables Array of animatable textures.
  44378. */
  44379. getAnimatables(animatables: IAnimatable[]): void;
  44380. /**
  44381. * Disposes the resources of the material.
  44382. * @param forceDisposeTextures - Forces the disposal of all textures.
  44383. */
  44384. dispose(forceDisposeTextures?: boolean): void;
  44385. /**
  44386. * Get the current class name of the texture useful for serialization or dynamic coding.
  44387. * @returns "PBRClearCoatConfiguration"
  44388. */
  44389. getClassName(): string;
  44390. /**
  44391. * Makes a duplicate of the current configuration into another one.
  44392. * @param clearCoatConfiguration define the config where to copy the info
  44393. */
  44394. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44395. /**
  44396. * Serializes this clear coat configuration.
  44397. * @returns - An object with the serialized config.
  44398. */
  44399. serialize(): any;
  44400. /**
  44401. * Parses a Clear Coat Configuration from a serialized object.
  44402. * @param source - Serialized object.
  44403. */
  44404. parse(source: any): void;
  44405. /**
  44406. * Add fallbacks to the effect fallbacks list.
  44407. * @param defines defines the Base texture to use.
  44408. * @param fallbacks defines the current fallback list.
  44409. * @param currentRank defines the current fallback rank.
  44410. * @returns the new fallback rank.
  44411. */
  44412. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44413. /**
  44414. * Add the required uniforms to the current list.
  44415. * @param uniforms defines the current uniform list.
  44416. */
  44417. static AddUniforms(uniforms: string[]): void;
  44418. /**
  44419. * Add the required samplers to the current list.
  44420. * @param samplers defines the current sampler list.
  44421. */
  44422. static AddSamplers(samplers: string[]): void;
  44423. /**
  44424. * Add the required uniforms to the current buffer.
  44425. * @param uniformBuffer defines the current uniform buffer.
  44426. */
  44427. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44428. }
  44429. }
  44430. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44431. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44432. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44434. /**
  44435. * @hidden
  44436. */
  44437. export interface IMaterialAnisotropicDefines {
  44438. ANISOTROPIC: boolean;
  44439. MAINUV1: boolean;
  44440. _areMiscDirty: boolean;
  44441. _needUVs: boolean;
  44442. }
  44443. /**
  44444. * Define the code related to the anisotropic parameters of the pbr material.
  44445. */
  44446. export class PBRAnisotropicConfiguration {
  44447. private _isEnabled;
  44448. /**
  44449. * Defines if the anisotropy is enabled in the material.
  44450. */
  44451. isEnabled: boolean;
  44452. /**
  44453. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44454. */
  44455. intensity: number;
  44456. /**
  44457. * Defines if the effect is along the tangents or bitangents.
  44458. * By default, the effect is "strectching" the highlights along the tangents.
  44459. */
  44460. followTangents: boolean;
  44461. /** @hidden */
  44462. private _internalMarkAllSubMeshesAsMiscDirty;
  44463. /** @hidden */
  44464. _markAllSubMeshesAsMiscDirty(): void;
  44465. /**
  44466. * Instantiate a new istance of clear coat configuration.
  44467. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44468. */
  44469. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44470. /**
  44471. * Checks to see if a texture is used in the material.
  44472. * @param defines the list of "defines" to update.
  44473. * @param mesh the mesh we are preparing the defines for.
  44474. */
  44475. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  44476. /**
  44477. * Binds the material data.
  44478. * @param uniformBuffer defines the Uniform buffer to fill in.
  44479. * @param isFrozen defines wether the material is frozen or not.
  44480. */
  44481. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  44482. /**
  44483. * Get the current class name of the texture useful for serialization or dynamic coding.
  44484. * @returns "PBRAnisotropicConfiguration"
  44485. */
  44486. getClassName(): string;
  44487. /**
  44488. * Makes a duplicate of the current configuration into another one.
  44489. * @param anisotropicConfiguration define the config where to copy the info
  44490. */
  44491. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44492. /**
  44493. * Serializes this clear coat configuration.
  44494. * @returns - An object with the serialized config.
  44495. */
  44496. serialize(): any;
  44497. /**
  44498. * Parses a Clear Coat Configuration from a serialized object.
  44499. * @param source - Serialized object.
  44500. */
  44501. parse(source: any): void;
  44502. /**
  44503. * Add fallbacks to the effect fallbacks list.
  44504. * @param defines defines the Base texture to use.
  44505. * @param fallbacks defines the current fallback list.
  44506. * @param currentRank defines the current fallback rank.
  44507. * @returns the new fallback rank.
  44508. */
  44509. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44510. /**
  44511. * Add the required uniforms to the current list.
  44512. * @param uniforms defines the current uniform list.
  44513. */
  44514. static AddUniforms(uniforms: string[]): void;
  44515. /**
  44516. * Add the required uniforms to the current buffer.
  44517. * @param uniformBuffer defines the current uniform buffer.
  44518. */
  44519. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44520. }
  44521. }
  44522. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44523. /**
  44524. * @hidden
  44525. */
  44526. export interface IMaterialBRDFDefines {
  44527. BRDF_V_HEIGHT_CORRELATED: boolean;
  44528. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44529. /** @hidden */
  44530. _areMiscDirty: boolean;
  44531. }
  44532. /**
  44533. * Define the code related to the BRDF parameters of the pbr material.
  44534. */
  44535. export class PBRBRDFConfiguration {
  44536. private _useEnergyConservation;
  44537. /**
  44538. * Defines if the material uses energy conservation.
  44539. */
  44540. useEnergyConservation: boolean;
  44541. private _useSmithVisibilityHeightCorrelated;
  44542. /**
  44543. * LEGACY Mode set to false
  44544. * Defines if the material uses height smith correlated visibility term.
  44545. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44546. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44547. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44548. * Not relying on height correlated will also disable energy conservation.
  44549. */
  44550. useSmithVisibilityHeightCorrelated: boolean;
  44551. /** @hidden */
  44552. private _internalMarkAllSubMeshesAsMiscDirty;
  44553. /** @hidden */
  44554. _markAllSubMeshesAsMiscDirty(): void;
  44555. /**
  44556. * Instantiate a new istance of clear coat configuration.
  44557. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44558. */
  44559. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44560. /**
  44561. * Checks to see if a texture is used in the material.
  44562. * @param defines the list of "defines" to update.
  44563. */
  44564. prepareDefines(defines: IMaterialBRDFDefines): void;
  44565. /**
  44566. * Get the current class name of the texture useful for serialization or dynamic coding.
  44567. * @returns "PBRClearCoatConfiguration"
  44568. */
  44569. getClassName(): string;
  44570. /**
  44571. * Makes a duplicate of the current configuration into another one.
  44572. * @param brdfConfiguration define the config where to copy the info
  44573. */
  44574. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44575. /**
  44576. * Serializes this BRDF configuration.
  44577. * @returns - An object with the serialized config.
  44578. */
  44579. serialize(): any;
  44580. /**
  44581. * Parses a BRDF Configuration from a serialized object.
  44582. * @param source - Serialized object.
  44583. */
  44584. parse(source: any): void;
  44585. }
  44586. }
  44587. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44588. /** @hidden */
  44589. export var pbrFragmentDeclaration: {
  44590. name: string;
  44591. shader: string;
  44592. };
  44593. }
  44594. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44595. /** @hidden */
  44596. export var pbrUboDeclaration: {
  44597. name: string;
  44598. shader: string;
  44599. };
  44600. }
  44601. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44602. /** @hidden */
  44603. export var pbrFunctions: {
  44604. name: string;
  44605. shader: string;
  44606. };
  44607. }
  44608. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44609. /** @hidden */
  44610. export var harmonicsFunctions: {
  44611. name: string;
  44612. shader: string;
  44613. };
  44614. }
  44615. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44616. /** @hidden */
  44617. export var pbrPreLightingFunctions: {
  44618. name: string;
  44619. shader: string;
  44620. };
  44621. }
  44622. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44623. /** @hidden */
  44624. export var pbrFalloffLightingFunctions: {
  44625. name: string;
  44626. shader: string;
  44627. };
  44628. }
  44629. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44630. /** @hidden */
  44631. export var pbrLightingFunctions: {
  44632. name: string;
  44633. shader: string;
  44634. };
  44635. }
  44636. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44637. /** @hidden */
  44638. export var pbrDebug: {
  44639. name: string;
  44640. shader: string;
  44641. };
  44642. }
  44643. declare module "babylonjs/Shaders/pbr.fragment" {
  44644. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44645. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44646. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44647. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44648. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44649. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44650. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44651. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44652. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44653. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44654. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44655. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44656. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44657. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44658. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44659. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44660. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44661. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44662. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44663. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44664. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44665. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44666. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44667. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44668. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  44669. /** @hidden */
  44670. export var pbrPixelShader: {
  44671. name: string;
  44672. shader: string;
  44673. };
  44674. }
  44675. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44676. /** @hidden */
  44677. export var pbrVertexDeclaration: {
  44678. name: string;
  44679. shader: string;
  44680. };
  44681. }
  44682. declare module "babylonjs/Shaders/pbr.vertex" {
  44683. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44684. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44685. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44686. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44687. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44688. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44689. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44690. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44691. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44692. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44693. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44694. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44695. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44696. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44697. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44698. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44699. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44700. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44701. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44702. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44703. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44704. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44705. /** @hidden */
  44706. export var pbrVertexShader: {
  44707. name: string;
  44708. shader: string;
  44709. };
  44710. }
  44711. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44712. import { IAnimatable } from "babylonjs/Misc/tools";
  44713. import { Nullable } from "babylonjs/types";
  44714. import { Scene } from "babylonjs/scene";
  44715. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44716. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44718. import { Mesh } from "babylonjs/Meshes/mesh";
  44719. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44720. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44721. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  44722. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44723. import { Material } from "babylonjs/Materials/material";
  44724. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44725. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44726. import "babylonjs/Shaders/pbr.fragment";
  44727. import "babylonjs/Shaders/pbr.vertex";
  44728. /**
  44729. * The Physically based material base class of BJS.
  44730. *
  44731. * This offers the main features of a standard PBR material.
  44732. * For more information, please refer to the documentation :
  44733. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44734. */
  44735. export abstract class PBRBaseMaterial extends PushMaterial {
  44736. /**
  44737. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44738. */
  44739. static readonly PBRMATERIAL_OPAQUE: number;
  44740. /**
  44741. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44742. */
  44743. static readonly PBRMATERIAL_ALPHATEST: number;
  44744. /**
  44745. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44746. */
  44747. static readonly PBRMATERIAL_ALPHABLEND: number;
  44748. /**
  44749. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44750. * They are also discarded below the alpha cutoff threshold to improve performances.
  44751. */
  44752. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44753. /**
  44754. * Defines the default value of how much AO map is occluding the analytical lights
  44755. * (point spot...).
  44756. */
  44757. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44758. /**
  44759. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44760. */
  44761. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44762. /**
  44763. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44764. * to enhance interoperability with other engines.
  44765. */
  44766. static readonly LIGHTFALLOFF_GLTF: number;
  44767. /**
  44768. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44769. * to enhance interoperability with other materials.
  44770. */
  44771. static readonly LIGHTFALLOFF_STANDARD: number;
  44772. /**
  44773. * Intensity of the direct lights e.g. the four lights available in your scene.
  44774. * This impacts both the direct diffuse and specular highlights.
  44775. */
  44776. protected _directIntensity: number;
  44777. /**
  44778. * Intensity of the emissive part of the material.
  44779. * This helps controlling the emissive effect without modifying the emissive color.
  44780. */
  44781. protected _emissiveIntensity: number;
  44782. /**
  44783. * Intensity of the environment e.g. how much the environment will light the object
  44784. * either through harmonics for rough material or through the refelction for shiny ones.
  44785. */
  44786. protected _environmentIntensity: number;
  44787. /**
  44788. * This is a special control allowing the reduction of the specular highlights coming from the
  44789. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44790. */
  44791. protected _specularIntensity: number;
  44792. /**
  44793. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44794. */
  44795. private _lightingInfos;
  44796. /**
  44797. * Debug Control allowing disabling the bump map on this material.
  44798. */
  44799. protected _disableBumpMap: boolean;
  44800. /**
  44801. * AKA Diffuse Texture in standard nomenclature.
  44802. */
  44803. protected _albedoTexture: BaseTexture;
  44804. /**
  44805. * AKA Occlusion Texture in other nomenclature.
  44806. */
  44807. protected _ambientTexture: BaseTexture;
  44808. /**
  44809. * AKA Occlusion Texture Intensity in other nomenclature.
  44810. */
  44811. protected _ambientTextureStrength: number;
  44812. /**
  44813. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44814. * 1 means it completely occludes it
  44815. * 0 mean it has no impact
  44816. */
  44817. protected _ambientTextureImpactOnAnalyticalLights: number;
  44818. /**
  44819. * Stores the alpha values in a texture.
  44820. */
  44821. protected _opacityTexture: BaseTexture;
  44822. /**
  44823. * Stores the reflection values in a texture.
  44824. */
  44825. protected _reflectionTexture: BaseTexture;
  44826. /**
  44827. * Stores the refraction values in a texture.
  44828. */
  44829. protected _refractionTexture: BaseTexture;
  44830. /**
  44831. * Stores the emissive values in a texture.
  44832. */
  44833. protected _emissiveTexture: BaseTexture;
  44834. /**
  44835. * AKA Specular texture in other nomenclature.
  44836. */
  44837. protected _reflectivityTexture: BaseTexture;
  44838. /**
  44839. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44840. */
  44841. protected _metallicTexture: BaseTexture;
  44842. /**
  44843. * Specifies the metallic scalar of the metallic/roughness workflow.
  44844. * Can also be used to scale the metalness values of the metallic texture.
  44845. */
  44846. protected _metallic: Nullable<number>;
  44847. /**
  44848. * Specifies the roughness scalar of the metallic/roughness workflow.
  44849. * Can also be used to scale the roughness values of the metallic texture.
  44850. */
  44851. protected _roughness: Nullable<number>;
  44852. /**
  44853. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44854. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44855. */
  44856. protected _microSurfaceTexture: BaseTexture;
  44857. /**
  44858. * Stores surface normal data used to displace a mesh in a texture.
  44859. */
  44860. protected _bumpTexture: BaseTexture;
  44861. /**
  44862. * Stores the pre-calculated light information of a mesh in a texture.
  44863. */
  44864. protected _lightmapTexture: BaseTexture;
  44865. /**
  44866. * The color of a material in ambient lighting.
  44867. */
  44868. protected _ambientColor: Color3;
  44869. /**
  44870. * AKA Diffuse Color in other nomenclature.
  44871. */
  44872. protected _albedoColor: Color3;
  44873. /**
  44874. * AKA Specular Color in other nomenclature.
  44875. */
  44876. protected _reflectivityColor: Color3;
  44877. /**
  44878. * The color applied when light is reflected from a material.
  44879. */
  44880. protected _reflectionColor: Color3;
  44881. /**
  44882. * The color applied when light is emitted from a material.
  44883. */
  44884. protected _emissiveColor: Color3;
  44885. /**
  44886. * AKA Glossiness in other nomenclature.
  44887. */
  44888. protected _microSurface: number;
  44889. /**
  44890. * source material index of refraction (IOR)' / 'destination material IOR.
  44891. */
  44892. protected _indexOfRefraction: number;
  44893. /**
  44894. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44895. */
  44896. protected _invertRefractionY: boolean;
  44897. /**
  44898. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44899. * Materials half opaque for instance using refraction could benefit from this control.
  44900. */
  44901. protected _linkRefractionWithTransparency: boolean;
  44902. /**
  44903. * Specifies that the material will use the light map as a show map.
  44904. */
  44905. protected _useLightmapAsShadowmap: boolean;
  44906. /**
  44907. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44908. * makes the reflect vector face the model (under horizon).
  44909. */
  44910. protected _useHorizonOcclusion: boolean;
  44911. /**
  44912. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44913. * too much the area relying on ambient texture to define their ambient occlusion.
  44914. */
  44915. protected _useRadianceOcclusion: boolean;
  44916. /**
  44917. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44918. */
  44919. protected _useAlphaFromAlbedoTexture: boolean;
  44920. /**
  44921. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44922. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44923. */
  44924. protected _useSpecularOverAlpha: boolean;
  44925. /**
  44926. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44927. */
  44928. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44929. /**
  44930. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44931. */
  44932. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44933. /**
  44934. * Specifies if the metallic texture contains the roughness information in its green channel.
  44935. */
  44936. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44937. /**
  44938. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44939. */
  44940. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44941. /**
  44942. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44943. */
  44944. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44945. /**
  44946. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44947. */
  44948. protected _useAmbientInGrayScale: boolean;
  44949. /**
  44950. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44951. * The material will try to infer what glossiness each pixel should be.
  44952. */
  44953. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44954. /**
  44955. * Defines the falloff type used in this material.
  44956. * It by default is Physical.
  44957. */
  44958. protected _lightFalloff: number;
  44959. /**
  44960. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44961. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44962. */
  44963. protected _useRadianceOverAlpha: boolean;
  44964. /**
  44965. * Allows using an object space normal map (instead of tangent space).
  44966. */
  44967. protected _useObjectSpaceNormalMap: boolean;
  44968. /**
  44969. * Allows using the bump map in parallax mode.
  44970. */
  44971. protected _useParallax: boolean;
  44972. /**
  44973. * Allows using the bump map in parallax occlusion mode.
  44974. */
  44975. protected _useParallaxOcclusion: boolean;
  44976. /**
  44977. * Controls the scale bias of the parallax mode.
  44978. */
  44979. protected _parallaxScaleBias: number;
  44980. /**
  44981. * If sets to true, disables all the lights affecting the material.
  44982. */
  44983. protected _disableLighting: boolean;
  44984. /**
  44985. * Number of Simultaneous lights allowed on the material.
  44986. */
  44987. protected _maxSimultaneousLights: number;
  44988. /**
  44989. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44990. */
  44991. protected _invertNormalMapX: boolean;
  44992. /**
  44993. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44994. */
  44995. protected _invertNormalMapY: boolean;
  44996. /**
  44997. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44998. */
  44999. protected _twoSidedLighting: boolean;
  45000. /**
  45001. * Defines the alpha limits in alpha test mode.
  45002. */
  45003. protected _alphaCutOff: number;
  45004. /**
  45005. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45006. */
  45007. protected _forceAlphaTest: boolean;
  45008. /**
  45009. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45010. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45011. */
  45012. protected _useAlphaFresnel: boolean;
  45013. /**
  45014. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45015. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45016. */
  45017. protected _useLinearAlphaFresnel: boolean;
  45018. /**
  45019. * The transparency mode of the material.
  45020. */
  45021. protected _transparencyMode: Nullable<number>;
  45022. /**
  45023. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45024. * from cos thetav and roughness:
  45025. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45026. */
  45027. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45028. /**
  45029. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45030. */
  45031. protected _forceIrradianceInFragment: boolean;
  45032. /**
  45033. * Force normal to face away from face.
  45034. */
  45035. protected _forceNormalForward: boolean;
  45036. /**
  45037. * Enables specular anti aliasing in the PBR shader.
  45038. * It will both interacts on the Geometry for analytical and IBL lighting.
  45039. * It also prefilter the roughness map based on the bump values.
  45040. */
  45041. protected _enableSpecularAntiAliasing: boolean;
  45042. /**
  45043. * Default configuration related to image processing available in the PBR Material.
  45044. */
  45045. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45046. /**
  45047. * Keep track of the image processing observer to allow dispose and replace.
  45048. */
  45049. private _imageProcessingObserver;
  45050. /**
  45051. * Attaches a new image processing configuration to the PBR Material.
  45052. * @param configuration
  45053. */
  45054. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45055. /**
  45056. * Stores the available render targets.
  45057. */
  45058. private _renderTargets;
  45059. /**
  45060. * Sets the global ambient color for the material used in lighting calculations.
  45061. */
  45062. private _globalAmbientColor;
  45063. /**
  45064. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45065. */
  45066. private _useLogarithmicDepth;
  45067. /**
  45068. * If set to true, no lighting calculations will be applied.
  45069. */
  45070. private _unlit;
  45071. private _debugMode;
  45072. /**
  45073. * @hidden
  45074. * This is reserved for the inspector.
  45075. * Defines the material debug mode.
  45076. * It helps seeing only some components of the material while troubleshooting.
  45077. */
  45078. debugMode: number;
  45079. /**
  45080. * @hidden
  45081. * This is reserved for the inspector.
  45082. * Specify from where on screen the debug mode should start.
  45083. * The value goes from -1 (full screen) to 1 (not visible)
  45084. * It helps with side by side comparison against the final render
  45085. * This defaults to -1
  45086. */
  45087. private debugLimit;
  45088. /**
  45089. * @hidden
  45090. * This is reserved for the inspector.
  45091. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45092. * You can use the factor to better multiply the final value.
  45093. */
  45094. private debugFactor;
  45095. /**
  45096. * Defines the clear coat layer parameters for the material.
  45097. */
  45098. readonly clearCoat: PBRClearCoatConfiguration;
  45099. /**
  45100. * Defines the anisotropic parameters for the material.
  45101. */
  45102. readonly anisotropy: PBRAnisotropicConfiguration;
  45103. /**
  45104. * Defines the BRDF parameters for the material.
  45105. */
  45106. readonly brdf: PBRBRDFConfiguration;
  45107. /**
  45108. * Instantiates a new PBRMaterial instance.
  45109. *
  45110. * @param name The material name
  45111. * @param scene The scene the material will be use in.
  45112. */
  45113. constructor(name: string, scene: Scene);
  45114. /**
  45115. * Gets a boolean indicating that current material needs to register RTT
  45116. */
  45117. readonly hasRenderTargetTextures: boolean;
  45118. /**
  45119. * Gets the name of the material class.
  45120. */
  45121. getClassName(): string;
  45122. /**
  45123. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45124. */
  45125. /**
  45126. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45127. */
  45128. useLogarithmicDepth: boolean;
  45129. /**
  45130. * Gets the current transparency mode.
  45131. */
  45132. /**
  45133. * Sets the transparency mode of the material.
  45134. *
  45135. * | Value | Type | Description |
  45136. * | ----- | ----------------------------------- | ----------- |
  45137. * | 0 | OPAQUE | |
  45138. * | 1 | ALPHATEST | |
  45139. * | 2 | ALPHABLEND | |
  45140. * | 3 | ALPHATESTANDBLEND | |
  45141. *
  45142. */
  45143. transparencyMode: Nullable<number>;
  45144. /**
  45145. * Returns true if alpha blending should be disabled.
  45146. */
  45147. private readonly _disableAlphaBlending;
  45148. /**
  45149. * Specifies whether or not this material should be rendered in alpha blend mode.
  45150. */
  45151. needAlphaBlending(): boolean;
  45152. /**
  45153. * Specifies if the mesh will require alpha blending.
  45154. * @param mesh - BJS mesh.
  45155. */
  45156. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45157. /**
  45158. * Specifies whether or not this material should be rendered in alpha test mode.
  45159. */
  45160. needAlphaTesting(): boolean;
  45161. /**
  45162. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45163. */
  45164. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45165. /**
  45166. * Gets the texture used for the alpha test.
  45167. */
  45168. getAlphaTestTexture(): BaseTexture;
  45169. /**
  45170. * Specifies that the submesh is ready to be used.
  45171. * @param mesh - BJS mesh.
  45172. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45173. * @param useInstances - Specifies that instances should be used.
  45174. * @returns - boolean indicating that the submesh is ready or not.
  45175. */
  45176. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45177. /**
  45178. * Specifies if the material uses metallic roughness workflow.
  45179. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45180. */
  45181. isMetallicWorkflow(): boolean;
  45182. private _prepareEffect;
  45183. private _prepareDefines;
  45184. /**
  45185. * Force shader compilation
  45186. */
  45187. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45188. clipPlane: boolean;
  45189. }>): void;
  45190. /**
  45191. * Initializes the uniform buffer layout for the shader.
  45192. */
  45193. buildUniformLayout(): void;
  45194. /**
  45195. * Unbinds the textures.
  45196. */
  45197. unbind(): void;
  45198. /**
  45199. * Binds the submesh data.
  45200. * @param world - The world matrix.
  45201. * @param mesh - The BJS mesh.
  45202. * @param subMesh - A submesh of the BJS mesh.
  45203. */
  45204. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45205. /**
  45206. * Returns the animatable textures.
  45207. * @returns - Array of animatable textures.
  45208. */
  45209. getAnimatables(): IAnimatable[];
  45210. /**
  45211. * Returns the texture used for reflections.
  45212. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45213. */
  45214. private _getReflectionTexture;
  45215. /**
  45216. * Returns the texture used for refraction or null if none is used.
  45217. * @returns - Refection texture if present. If no refraction texture and refraction
  45218. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45219. */
  45220. private _getRefractionTexture;
  45221. /**
  45222. * Returns an array of the actively used textures.
  45223. * @returns - Array of BaseTextures
  45224. */
  45225. getActiveTextures(): BaseTexture[];
  45226. /**
  45227. * Checks to see if a texture is used in the material.
  45228. * @param texture - Base texture to use.
  45229. * @returns - Boolean specifying if a texture is used in the material.
  45230. */
  45231. hasTexture(texture: BaseTexture): boolean;
  45232. /**
  45233. * Disposes the resources of the material.
  45234. * @param forceDisposeEffect - Forces the disposal of effects.
  45235. * @param forceDisposeTextures - Forces the disposal of all textures.
  45236. */
  45237. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45238. }
  45239. }
  45240. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45241. import { Nullable } from "babylonjs/types";
  45242. import { Scene } from "babylonjs/scene";
  45243. import { Color3 } from "babylonjs/Maths/math";
  45244. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45245. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45247. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45248. /**
  45249. * The Physically based material of BJS.
  45250. *
  45251. * This offers the main features of a standard PBR material.
  45252. * For more information, please refer to the documentation :
  45253. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45254. */
  45255. export class PBRMaterial extends PBRBaseMaterial {
  45256. /**
  45257. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45258. */
  45259. static readonly PBRMATERIAL_OPAQUE: number;
  45260. /**
  45261. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45262. */
  45263. static readonly PBRMATERIAL_ALPHATEST: number;
  45264. /**
  45265. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45266. */
  45267. static readonly PBRMATERIAL_ALPHABLEND: number;
  45268. /**
  45269. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45270. * They are also discarded below the alpha cutoff threshold to improve performances.
  45271. */
  45272. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45273. /**
  45274. * Defines the default value of how much AO map is occluding the analytical lights
  45275. * (point spot...).
  45276. */
  45277. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45278. /**
  45279. * Intensity of the direct lights e.g. the four lights available in your scene.
  45280. * This impacts both the direct diffuse and specular highlights.
  45281. */
  45282. directIntensity: number;
  45283. /**
  45284. * Intensity of the emissive part of the material.
  45285. * This helps controlling the emissive effect without modifying the emissive color.
  45286. */
  45287. emissiveIntensity: number;
  45288. /**
  45289. * Intensity of the environment e.g. how much the environment will light the object
  45290. * either through harmonics for rough material or through the refelction for shiny ones.
  45291. */
  45292. environmentIntensity: number;
  45293. /**
  45294. * This is a special control allowing the reduction of the specular highlights coming from the
  45295. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45296. */
  45297. specularIntensity: number;
  45298. /**
  45299. * Debug Control allowing disabling the bump map on this material.
  45300. */
  45301. disableBumpMap: boolean;
  45302. /**
  45303. * AKA Diffuse Texture in standard nomenclature.
  45304. */
  45305. albedoTexture: BaseTexture;
  45306. /**
  45307. * AKA Occlusion Texture in other nomenclature.
  45308. */
  45309. ambientTexture: BaseTexture;
  45310. /**
  45311. * AKA Occlusion Texture Intensity in other nomenclature.
  45312. */
  45313. ambientTextureStrength: number;
  45314. /**
  45315. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45316. * 1 means it completely occludes it
  45317. * 0 mean it has no impact
  45318. */
  45319. ambientTextureImpactOnAnalyticalLights: number;
  45320. /**
  45321. * Stores the alpha values in a texture.
  45322. */
  45323. opacityTexture: BaseTexture;
  45324. /**
  45325. * Stores the reflection values in a texture.
  45326. */
  45327. reflectionTexture: Nullable<BaseTexture>;
  45328. /**
  45329. * Stores the emissive values in a texture.
  45330. */
  45331. emissiveTexture: BaseTexture;
  45332. /**
  45333. * AKA Specular texture in other nomenclature.
  45334. */
  45335. reflectivityTexture: BaseTexture;
  45336. /**
  45337. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45338. */
  45339. metallicTexture: BaseTexture;
  45340. /**
  45341. * Specifies the metallic scalar of the metallic/roughness workflow.
  45342. * Can also be used to scale the metalness values of the metallic texture.
  45343. */
  45344. metallic: Nullable<number>;
  45345. /**
  45346. * Specifies the roughness scalar of the metallic/roughness workflow.
  45347. * Can also be used to scale the roughness values of the metallic texture.
  45348. */
  45349. roughness: Nullable<number>;
  45350. /**
  45351. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45352. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45353. */
  45354. microSurfaceTexture: BaseTexture;
  45355. /**
  45356. * Stores surface normal data used to displace a mesh in a texture.
  45357. */
  45358. bumpTexture: BaseTexture;
  45359. /**
  45360. * Stores the pre-calculated light information of a mesh in a texture.
  45361. */
  45362. lightmapTexture: BaseTexture;
  45363. /**
  45364. * Stores the refracted light information in a texture.
  45365. */
  45366. refractionTexture: BaseTexture;
  45367. /**
  45368. * The color of a material in ambient lighting.
  45369. */
  45370. ambientColor: Color3;
  45371. /**
  45372. * AKA Diffuse Color in other nomenclature.
  45373. */
  45374. albedoColor: Color3;
  45375. /**
  45376. * AKA Specular Color in other nomenclature.
  45377. */
  45378. reflectivityColor: Color3;
  45379. /**
  45380. * The color reflected from the material.
  45381. */
  45382. reflectionColor: Color3;
  45383. /**
  45384. * The color emitted from the material.
  45385. */
  45386. emissiveColor: Color3;
  45387. /**
  45388. * AKA Glossiness in other nomenclature.
  45389. */
  45390. microSurface: number;
  45391. /**
  45392. * source material index of refraction (IOR)' / 'destination material IOR.
  45393. */
  45394. indexOfRefraction: number;
  45395. /**
  45396. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45397. */
  45398. invertRefractionY: boolean;
  45399. /**
  45400. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45401. * Materials half opaque for instance using refraction could benefit from this control.
  45402. */
  45403. linkRefractionWithTransparency: boolean;
  45404. /**
  45405. * If true, the light map contains occlusion information instead of lighting info.
  45406. */
  45407. useLightmapAsShadowmap: boolean;
  45408. /**
  45409. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45410. */
  45411. useAlphaFromAlbedoTexture: boolean;
  45412. /**
  45413. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45414. */
  45415. forceAlphaTest: boolean;
  45416. /**
  45417. * Defines the alpha limits in alpha test mode.
  45418. */
  45419. alphaCutOff: number;
  45420. /**
  45421. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45422. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45423. */
  45424. useSpecularOverAlpha: boolean;
  45425. /**
  45426. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45427. */
  45428. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45429. /**
  45430. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45431. */
  45432. useRoughnessFromMetallicTextureAlpha: boolean;
  45433. /**
  45434. * Specifies if the metallic texture contains the roughness information in its green channel.
  45435. */
  45436. useRoughnessFromMetallicTextureGreen: boolean;
  45437. /**
  45438. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45439. */
  45440. useMetallnessFromMetallicTextureBlue: boolean;
  45441. /**
  45442. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45443. */
  45444. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45445. /**
  45446. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45447. */
  45448. useAmbientInGrayScale: boolean;
  45449. /**
  45450. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45451. * The material will try to infer what glossiness each pixel should be.
  45452. */
  45453. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45454. /**
  45455. * BJS is using an harcoded light falloff based on a manually sets up range.
  45456. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45457. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45458. */
  45459. /**
  45460. * BJS is using an harcoded light falloff based on a manually sets up range.
  45461. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45462. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45463. */
  45464. usePhysicalLightFalloff: boolean;
  45465. /**
  45466. * In order to support the falloff compatibility with gltf, a special mode has been added
  45467. * to reproduce the gltf light falloff.
  45468. */
  45469. /**
  45470. * In order to support the falloff compatibility with gltf, a special mode has been added
  45471. * to reproduce the gltf light falloff.
  45472. */
  45473. useGLTFLightFalloff: boolean;
  45474. /**
  45475. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45476. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45477. */
  45478. useRadianceOverAlpha: boolean;
  45479. /**
  45480. * Allows using an object space normal map (instead of tangent space).
  45481. */
  45482. useObjectSpaceNormalMap: boolean;
  45483. /**
  45484. * Allows using the bump map in parallax mode.
  45485. */
  45486. useParallax: boolean;
  45487. /**
  45488. * Allows using the bump map in parallax occlusion mode.
  45489. */
  45490. useParallaxOcclusion: boolean;
  45491. /**
  45492. * Controls the scale bias of the parallax mode.
  45493. */
  45494. parallaxScaleBias: number;
  45495. /**
  45496. * If sets to true, disables all the lights affecting the material.
  45497. */
  45498. disableLighting: boolean;
  45499. /**
  45500. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45501. */
  45502. forceIrradianceInFragment: boolean;
  45503. /**
  45504. * Number of Simultaneous lights allowed on the material.
  45505. */
  45506. maxSimultaneousLights: number;
  45507. /**
  45508. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45509. */
  45510. invertNormalMapX: boolean;
  45511. /**
  45512. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45513. */
  45514. invertNormalMapY: boolean;
  45515. /**
  45516. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45517. */
  45518. twoSidedLighting: boolean;
  45519. /**
  45520. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45521. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45522. */
  45523. useAlphaFresnel: boolean;
  45524. /**
  45525. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45526. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45527. */
  45528. useLinearAlphaFresnel: boolean;
  45529. /**
  45530. * Let user defines the brdf lookup texture used for IBL.
  45531. * A default 8bit version is embedded but you could point at :
  45532. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45533. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45534. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45535. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45536. */
  45537. environmentBRDFTexture: Nullable<BaseTexture>;
  45538. /**
  45539. * Force normal to face away from face.
  45540. */
  45541. forceNormalForward: boolean;
  45542. /**
  45543. * Enables specular anti aliasing in the PBR shader.
  45544. * It will both interacts on the Geometry for analytical and IBL lighting.
  45545. * It also prefilter the roughness map based on the bump values.
  45546. */
  45547. enableSpecularAntiAliasing: boolean;
  45548. /**
  45549. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45550. * makes the reflect vector face the model (under horizon).
  45551. */
  45552. useHorizonOcclusion: boolean;
  45553. /**
  45554. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45555. * too much the area relying on ambient texture to define their ambient occlusion.
  45556. */
  45557. useRadianceOcclusion: boolean;
  45558. /**
  45559. * If set to true, no lighting calculations will be applied.
  45560. */
  45561. unlit: boolean;
  45562. /**
  45563. * Gets the image processing configuration used either in this material.
  45564. */
  45565. /**
  45566. * Sets the Default image processing configuration used either in the this material.
  45567. *
  45568. * If sets to null, the scene one is in use.
  45569. */
  45570. imageProcessingConfiguration: ImageProcessingConfiguration;
  45571. /**
  45572. * Gets wether the color curves effect is enabled.
  45573. */
  45574. /**
  45575. * Sets wether the color curves effect is enabled.
  45576. */
  45577. cameraColorCurvesEnabled: boolean;
  45578. /**
  45579. * Gets wether the color grading effect is enabled.
  45580. */
  45581. /**
  45582. * Gets wether the color grading effect is enabled.
  45583. */
  45584. cameraColorGradingEnabled: boolean;
  45585. /**
  45586. * Gets wether tonemapping is enabled or not.
  45587. */
  45588. /**
  45589. * Sets wether tonemapping is enabled or not
  45590. */
  45591. cameraToneMappingEnabled: boolean;
  45592. /**
  45593. * The camera exposure used on this material.
  45594. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45595. * This corresponds to a photographic exposure.
  45596. */
  45597. /**
  45598. * The camera exposure used on this material.
  45599. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45600. * This corresponds to a photographic exposure.
  45601. */
  45602. cameraExposure: number;
  45603. /**
  45604. * Gets The camera contrast used on this material.
  45605. */
  45606. /**
  45607. * Sets The camera contrast used on this material.
  45608. */
  45609. cameraContrast: number;
  45610. /**
  45611. * Gets the Color Grading 2D Lookup Texture.
  45612. */
  45613. /**
  45614. * Sets the Color Grading 2D Lookup Texture.
  45615. */
  45616. cameraColorGradingTexture: Nullable<BaseTexture>;
  45617. /**
  45618. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45619. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45620. * 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;
  45621. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45622. */
  45623. /**
  45624. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45625. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45626. * 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;
  45627. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45628. */
  45629. cameraColorCurves: Nullable<ColorCurves>;
  45630. /**
  45631. * Instantiates a new PBRMaterial instance.
  45632. *
  45633. * @param name The material name
  45634. * @param scene The scene the material will be use in.
  45635. */
  45636. constructor(name: string, scene: Scene);
  45637. /**
  45638. * Returns the name of this material class.
  45639. */
  45640. getClassName(): string;
  45641. /**
  45642. * Makes a duplicate of the current material.
  45643. * @param name - name to use for the new material.
  45644. */
  45645. clone(name: string): PBRMaterial;
  45646. /**
  45647. * Serializes this PBR Material.
  45648. * @returns - An object with the serialized material.
  45649. */
  45650. serialize(): any;
  45651. /**
  45652. * Parses a PBR Material from a serialized object.
  45653. * @param source - Serialized object.
  45654. * @param scene - BJS scene instance.
  45655. * @param rootUrl - url for the scene object
  45656. * @returns - PBRMaterial
  45657. */
  45658. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45659. }
  45660. }
  45661. declare module "babylonjs/Helpers/sceneHelpers" {
  45662. import { Nullable } from "babylonjs/types";
  45663. import { Mesh } from "babylonjs/Meshes/mesh";
  45664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45665. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  45666. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45667. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  45668. import "babylonjs/Meshes/Builders/boxBuilder";
  45669. /** @hidden */
  45670. export var _forceSceneHelpersToBundle: boolean;
  45671. module "babylonjs/scene" {
  45672. interface Scene {
  45673. /**
  45674. * Creates a default light for the scene.
  45675. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45676. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45677. */
  45678. createDefaultLight(replace?: boolean): void;
  45679. /**
  45680. * Creates a default camera for the scene.
  45681. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45682. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45683. * @param replace has default false, when true replaces the active camera in the scene
  45684. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45685. */
  45686. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45687. /**
  45688. * Creates a default camera and a default light.
  45689. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45690. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45691. * @param replace has the default false, when true replaces the active camera/light in the scene
  45692. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45693. */
  45694. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45695. /**
  45696. * Creates a new sky box
  45697. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45698. * @param environmentTexture defines the texture to use as environment texture
  45699. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45700. * @param scale defines the overall scale of the skybox
  45701. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45702. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45703. * @returns a new mesh holding the sky box
  45704. */
  45705. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45706. /**
  45707. * Creates a new environment
  45708. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45709. * @param options defines the options you can use to configure the environment
  45710. * @returns the new EnvironmentHelper
  45711. */
  45712. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45713. /**
  45714. * Creates a new VREXperienceHelper
  45715. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45716. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45717. * @returns a new VREXperienceHelper
  45718. */
  45719. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45720. /**
  45721. * Creates a new XREXperienceHelper
  45722. * @see http://doc.babylonjs.com/how_to/webxr
  45723. * @returns a promise for a new XREXperienceHelper
  45724. */
  45725. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45726. }
  45727. }
  45728. }
  45729. declare module "babylonjs/Helpers/videoDome" {
  45730. import { Scene } from "babylonjs/scene";
  45731. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45732. import { Mesh } from "babylonjs/Meshes/mesh";
  45733. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45734. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45735. import "babylonjs/Meshes/Builders/sphereBuilder";
  45736. /**
  45737. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45738. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45739. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45740. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45741. */
  45742. export class VideoDome extends TransformNode {
  45743. /**
  45744. * Define the video source as a Monoscopic panoramic 360 video.
  45745. */
  45746. static readonly MODE_MONOSCOPIC: number;
  45747. /**
  45748. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45749. */
  45750. static readonly MODE_TOPBOTTOM: number;
  45751. /**
  45752. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45753. */
  45754. static readonly MODE_SIDEBYSIDE: number;
  45755. private _useDirectMapping;
  45756. /**
  45757. * The video texture being displayed on the sphere
  45758. */
  45759. protected _videoTexture: VideoTexture;
  45760. /**
  45761. * Gets the video texture being displayed on the sphere
  45762. */
  45763. readonly videoTexture: VideoTexture;
  45764. /**
  45765. * The skybox material
  45766. */
  45767. protected _material: BackgroundMaterial;
  45768. /**
  45769. * The surface used for the skybox
  45770. */
  45771. protected _mesh: Mesh;
  45772. /**
  45773. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45774. * Also see the options.resolution property.
  45775. */
  45776. fovMultiplier: number;
  45777. private _videoMode;
  45778. /**
  45779. * Gets or set the current video mode for the video. It can be:
  45780. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45781. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45782. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45783. */
  45784. videoMode: number;
  45785. /**
  45786. * Oberserver used in Stereoscopic VR Mode.
  45787. */
  45788. private _onBeforeCameraRenderObserver;
  45789. /**
  45790. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45791. * @param name Element's name, child elements will append suffixes for their own names.
  45792. * @param urlsOrVideo defines the url(s) or the video element to use
  45793. * @param options An object containing optional or exposed sub element properties
  45794. */
  45795. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45796. resolution?: number;
  45797. clickToPlay?: boolean;
  45798. autoPlay?: boolean;
  45799. loop?: boolean;
  45800. size?: number;
  45801. poster?: string;
  45802. useDirectMapping?: boolean;
  45803. }, scene: Scene);
  45804. private _changeVideoMode;
  45805. /**
  45806. * Releases resources associated with this node.
  45807. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45808. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45809. */
  45810. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45811. }
  45812. }
  45813. declare module "babylonjs/Helpers/index" {
  45814. export * from "babylonjs/Helpers/environmentHelper";
  45815. export * from "babylonjs/Helpers/photoDome";
  45816. export * from "babylonjs/Helpers/sceneHelpers";
  45817. export * from "babylonjs/Helpers/videoDome";
  45818. }
  45819. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45820. import { PerfCounter } from "babylonjs/Misc/tools";
  45821. import { IDisposable } from "babylonjs/scene";
  45822. import { Engine } from "babylonjs/Engines/engine";
  45823. /**
  45824. * This class can be used to get instrumentation data from a Babylon engine
  45825. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45826. */
  45827. export class EngineInstrumentation implements IDisposable {
  45828. /**
  45829. * Define the instrumented engine.
  45830. */
  45831. engine: Engine;
  45832. private _captureGPUFrameTime;
  45833. private _gpuFrameTimeToken;
  45834. private _gpuFrameTime;
  45835. private _captureShaderCompilationTime;
  45836. private _shaderCompilationTime;
  45837. private _onBeginFrameObserver;
  45838. private _onEndFrameObserver;
  45839. private _onBeforeShaderCompilationObserver;
  45840. private _onAfterShaderCompilationObserver;
  45841. /**
  45842. * Gets the perf counter used for GPU frame time
  45843. */
  45844. readonly gpuFrameTimeCounter: PerfCounter;
  45845. /**
  45846. * Gets the GPU frame time capture status
  45847. */
  45848. /**
  45849. * Enable or disable the GPU frame time capture
  45850. */
  45851. captureGPUFrameTime: boolean;
  45852. /**
  45853. * Gets the perf counter used for shader compilation time
  45854. */
  45855. readonly shaderCompilationTimeCounter: PerfCounter;
  45856. /**
  45857. * Gets the shader compilation time capture status
  45858. */
  45859. /**
  45860. * Enable or disable the shader compilation time capture
  45861. */
  45862. captureShaderCompilationTime: boolean;
  45863. /**
  45864. * Instantiates a new engine instrumentation.
  45865. * This class can be used to get instrumentation data from a Babylon engine
  45866. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45867. * @param engine Defines the engine to instrument
  45868. */
  45869. constructor(
  45870. /**
  45871. * Define the instrumented engine.
  45872. */
  45873. engine: Engine);
  45874. /**
  45875. * Dispose and release associated resources.
  45876. */
  45877. dispose(): void;
  45878. }
  45879. }
  45880. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45881. import { PerfCounter } from "babylonjs/Misc/tools";
  45882. import { Scene, IDisposable } from "babylonjs/scene";
  45883. /**
  45884. * This class can be used to get instrumentation data from a Babylon engine
  45885. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45886. */
  45887. export class SceneInstrumentation implements IDisposable {
  45888. /**
  45889. * Defines the scene to instrument
  45890. */
  45891. scene: Scene;
  45892. private _captureActiveMeshesEvaluationTime;
  45893. private _activeMeshesEvaluationTime;
  45894. private _captureRenderTargetsRenderTime;
  45895. private _renderTargetsRenderTime;
  45896. private _captureFrameTime;
  45897. private _frameTime;
  45898. private _captureRenderTime;
  45899. private _renderTime;
  45900. private _captureInterFrameTime;
  45901. private _interFrameTime;
  45902. private _captureParticlesRenderTime;
  45903. private _particlesRenderTime;
  45904. private _captureSpritesRenderTime;
  45905. private _spritesRenderTime;
  45906. private _capturePhysicsTime;
  45907. private _physicsTime;
  45908. private _captureAnimationsTime;
  45909. private _animationsTime;
  45910. private _captureCameraRenderTime;
  45911. private _cameraRenderTime;
  45912. private _onBeforeActiveMeshesEvaluationObserver;
  45913. private _onAfterActiveMeshesEvaluationObserver;
  45914. private _onBeforeRenderTargetsRenderObserver;
  45915. private _onAfterRenderTargetsRenderObserver;
  45916. private _onAfterRenderObserver;
  45917. private _onBeforeDrawPhaseObserver;
  45918. private _onAfterDrawPhaseObserver;
  45919. private _onBeforeAnimationsObserver;
  45920. private _onBeforeParticlesRenderingObserver;
  45921. private _onAfterParticlesRenderingObserver;
  45922. private _onBeforeSpritesRenderingObserver;
  45923. private _onAfterSpritesRenderingObserver;
  45924. private _onBeforePhysicsObserver;
  45925. private _onAfterPhysicsObserver;
  45926. private _onAfterAnimationsObserver;
  45927. private _onBeforeCameraRenderObserver;
  45928. private _onAfterCameraRenderObserver;
  45929. /**
  45930. * Gets the perf counter used for active meshes evaluation time
  45931. */
  45932. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45933. /**
  45934. * Gets the active meshes evaluation time capture status
  45935. */
  45936. /**
  45937. * Enable or disable the active meshes evaluation time capture
  45938. */
  45939. captureActiveMeshesEvaluationTime: boolean;
  45940. /**
  45941. * Gets the perf counter used for render targets render time
  45942. */
  45943. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45944. /**
  45945. * Gets the render targets render time capture status
  45946. */
  45947. /**
  45948. * Enable or disable the render targets render time capture
  45949. */
  45950. captureRenderTargetsRenderTime: boolean;
  45951. /**
  45952. * Gets the perf counter used for particles render time
  45953. */
  45954. readonly particlesRenderTimeCounter: PerfCounter;
  45955. /**
  45956. * Gets the particles render time capture status
  45957. */
  45958. /**
  45959. * Enable or disable the particles render time capture
  45960. */
  45961. captureParticlesRenderTime: boolean;
  45962. /**
  45963. * Gets the perf counter used for sprites render time
  45964. */
  45965. readonly spritesRenderTimeCounter: PerfCounter;
  45966. /**
  45967. * Gets the sprites render time capture status
  45968. */
  45969. /**
  45970. * Enable or disable the sprites render time capture
  45971. */
  45972. captureSpritesRenderTime: boolean;
  45973. /**
  45974. * Gets the perf counter used for physics time
  45975. */
  45976. readonly physicsTimeCounter: PerfCounter;
  45977. /**
  45978. * Gets the physics time capture status
  45979. */
  45980. /**
  45981. * Enable or disable the physics time capture
  45982. */
  45983. capturePhysicsTime: boolean;
  45984. /**
  45985. * Gets the perf counter used for animations time
  45986. */
  45987. readonly animationsTimeCounter: PerfCounter;
  45988. /**
  45989. * Gets the animations time capture status
  45990. */
  45991. /**
  45992. * Enable or disable the animations time capture
  45993. */
  45994. captureAnimationsTime: boolean;
  45995. /**
  45996. * Gets the perf counter used for frame time capture
  45997. */
  45998. readonly frameTimeCounter: PerfCounter;
  45999. /**
  46000. * Gets the frame time capture status
  46001. */
  46002. /**
  46003. * Enable or disable the frame time capture
  46004. */
  46005. captureFrameTime: boolean;
  46006. /**
  46007. * Gets the perf counter used for inter-frames time capture
  46008. */
  46009. readonly interFrameTimeCounter: PerfCounter;
  46010. /**
  46011. * Gets the inter-frames time capture status
  46012. */
  46013. /**
  46014. * Enable or disable the inter-frames time capture
  46015. */
  46016. captureInterFrameTime: boolean;
  46017. /**
  46018. * Gets the perf counter used for render time capture
  46019. */
  46020. readonly renderTimeCounter: PerfCounter;
  46021. /**
  46022. * Gets the render time capture status
  46023. */
  46024. /**
  46025. * Enable or disable the render time capture
  46026. */
  46027. captureRenderTime: boolean;
  46028. /**
  46029. * Gets the perf counter used for camera render time capture
  46030. */
  46031. readonly cameraRenderTimeCounter: PerfCounter;
  46032. /**
  46033. * Gets the camera render time capture status
  46034. */
  46035. /**
  46036. * Enable or disable the camera render time capture
  46037. */
  46038. captureCameraRenderTime: boolean;
  46039. /**
  46040. * Gets the perf counter used for draw calls
  46041. */
  46042. readonly drawCallsCounter: PerfCounter;
  46043. /**
  46044. * Gets the perf counter used for texture collisions
  46045. */
  46046. readonly textureCollisionsCounter: PerfCounter;
  46047. /**
  46048. * Instantiates a new scene instrumentation.
  46049. * This class can be used to get instrumentation data from a Babylon engine
  46050. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46051. * @param scene Defines the scene to instrument
  46052. */
  46053. constructor(
  46054. /**
  46055. * Defines the scene to instrument
  46056. */
  46057. scene: Scene);
  46058. /**
  46059. * Dispose and release associated resources.
  46060. */
  46061. dispose(): void;
  46062. }
  46063. }
  46064. declare module "babylonjs/Instrumentation/index" {
  46065. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46066. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46067. export * from "babylonjs/Instrumentation/timeToken";
  46068. }
  46069. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46070. /** @hidden */
  46071. export var glowMapGenerationPixelShader: {
  46072. name: string;
  46073. shader: string;
  46074. };
  46075. }
  46076. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46077. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46078. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46079. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46080. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46081. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46082. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46083. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46084. /** @hidden */
  46085. export var glowMapGenerationVertexShader: {
  46086. name: string;
  46087. shader: string;
  46088. };
  46089. }
  46090. declare module "babylonjs/Layers/effectLayer" {
  46091. import { Observable } from "babylonjs/Misc/observable";
  46092. import { Nullable } from "babylonjs/types";
  46093. import { Camera } from "babylonjs/Cameras/camera";
  46094. import { Scene } from "babylonjs/scene";
  46095. import { Color4, ISize } from "babylonjs/Maths/math";
  46096. import { Engine } from "babylonjs/Engines/engine";
  46097. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46099. import { Mesh } from "babylonjs/Meshes/mesh";
  46100. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46102. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46103. import { Effect } from "babylonjs/Materials/effect";
  46104. import { Material } from "babylonjs/Materials/material";
  46105. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46106. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46107. /**
  46108. * Effect layer options. This helps customizing the behaviour
  46109. * of the effect layer.
  46110. */
  46111. export interface IEffectLayerOptions {
  46112. /**
  46113. * Multiplication factor apply to the canvas size to compute the render target size
  46114. * used to generated the objects (the smaller the faster).
  46115. */
  46116. mainTextureRatio: number;
  46117. /**
  46118. * Enforces a fixed size texture to ensure effect stability across devices.
  46119. */
  46120. mainTextureFixedSize?: number;
  46121. /**
  46122. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46123. */
  46124. alphaBlendingMode: number;
  46125. /**
  46126. * The camera attached to the layer.
  46127. */
  46128. camera: Nullable<Camera>;
  46129. /**
  46130. * The rendering group to draw the layer in.
  46131. */
  46132. renderingGroupId: number;
  46133. }
  46134. /**
  46135. * The effect layer Helps adding post process effect blended with the main pass.
  46136. *
  46137. * This can be for instance use to generate glow or higlight effects on the scene.
  46138. *
  46139. * The effect layer class can not be used directly and is intented to inherited from to be
  46140. * customized per effects.
  46141. */
  46142. export abstract class EffectLayer {
  46143. private _vertexBuffers;
  46144. private _indexBuffer;
  46145. private _cachedDefines;
  46146. private _effectLayerMapGenerationEffect;
  46147. private _effectLayerOptions;
  46148. private _mergeEffect;
  46149. protected _scene: Scene;
  46150. protected _engine: Engine;
  46151. protected _maxSize: number;
  46152. protected _mainTextureDesiredSize: ISize;
  46153. protected _mainTexture: RenderTargetTexture;
  46154. protected _shouldRender: boolean;
  46155. protected _postProcesses: PostProcess[];
  46156. protected _textures: BaseTexture[];
  46157. protected _emissiveTextureAndColor: {
  46158. texture: Nullable<BaseTexture>;
  46159. color: Color4;
  46160. };
  46161. /**
  46162. * The name of the layer
  46163. */
  46164. name: string;
  46165. /**
  46166. * The clear color of the texture used to generate the glow map.
  46167. */
  46168. neutralColor: Color4;
  46169. /**
  46170. * Specifies wether the highlight layer is enabled or not.
  46171. */
  46172. isEnabled: boolean;
  46173. /**
  46174. * Gets the camera attached to the layer.
  46175. */
  46176. readonly camera: Nullable<Camera>;
  46177. /**
  46178. * Gets the rendering group id the layer should render in.
  46179. */
  46180. readonly renderingGroupId: number;
  46181. /**
  46182. * An event triggered when the effect layer has been disposed.
  46183. */
  46184. onDisposeObservable: Observable<EffectLayer>;
  46185. /**
  46186. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46187. */
  46188. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46189. /**
  46190. * An event triggered when the generated texture is being merged in the scene.
  46191. */
  46192. onBeforeComposeObservable: Observable<EffectLayer>;
  46193. /**
  46194. * An event triggered when the generated texture has been merged in the scene.
  46195. */
  46196. onAfterComposeObservable: Observable<EffectLayer>;
  46197. /**
  46198. * An event triggered when the efffect layer changes its size.
  46199. */
  46200. onSizeChangedObservable: Observable<EffectLayer>;
  46201. /** @hidden */
  46202. static _SceneComponentInitialization: (scene: Scene) => void;
  46203. /**
  46204. * Instantiates a new effect Layer and references it in the scene.
  46205. * @param name The name of the layer
  46206. * @param scene The scene to use the layer in
  46207. */
  46208. constructor(
  46209. /** The Friendly of the effect in the scene */
  46210. name: string, scene: Scene);
  46211. /**
  46212. * Get the effect name of the layer.
  46213. * @return The effect name
  46214. */
  46215. abstract getEffectName(): string;
  46216. /**
  46217. * Checks for the readiness of the element composing the layer.
  46218. * @param subMesh the mesh to check for
  46219. * @param useInstances specify wether or not to use instances to render the mesh
  46220. * @return true if ready otherwise, false
  46221. */
  46222. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46223. /**
  46224. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46225. * @returns true if the effect requires stencil during the main canvas render pass.
  46226. */
  46227. abstract needStencil(): boolean;
  46228. /**
  46229. * Create the merge effect. This is the shader use to blit the information back
  46230. * to the main canvas at the end of the scene rendering.
  46231. * @returns The effect containing the shader used to merge the effect on the main canvas
  46232. */
  46233. protected abstract _createMergeEffect(): Effect;
  46234. /**
  46235. * Creates the render target textures and post processes used in the effect layer.
  46236. */
  46237. protected abstract _createTextureAndPostProcesses(): void;
  46238. /**
  46239. * Implementation specific of rendering the generating effect on the main canvas.
  46240. * @param effect The effect used to render through
  46241. */
  46242. protected abstract _internalRender(effect: Effect): void;
  46243. /**
  46244. * Sets the required values for both the emissive texture and and the main color.
  46245. */
  46246. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46247. /**
  46248. * Free any resources and references associated to a mesh.
  46249. * Internal use
  46250. * @param mesh The mesh to free.
  46251. */
  46252. abstract _disposeMesh(mesh: Mesh): void;
  46253. /**
  46254. * Serializes this layer (Glow or Highlight for example)
  46255. * @returns a serialized layer object
  46256. */
  46257. abstract serialize?(): any;
  46258. /**
  46259. * Initializes the effect layer with the required options.
  46260. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46261. */
  46262. protected _init(options: Partial<IEffectLayerOptions>): void;
  46263. /**
  46264. * Generates the index buffer of the full screen quad blending to the main canvas.
  46265. */
  46266. private _generateIndexBuffer;
  46267. /**
  46268. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46269. */
  46270. private _genrateVertexBuffer;
  46271. /**
  46272. * Sets the main texture desired size which is the closest power of two
  46273. * of the engine canvas size.
  46274. */
  46275. private _setMainTextureSize;
  46276. /**
  46277. * Creates the main texture for the effect layer.
  46278. */
  46279. protected _createMainTexture(): void;
  46280. /**
  46281. * Adds specific effects defines.
  46282. * @param defines The defines to add specifics to.
  46283. */
  46284. protected _addCustomEffectDefines(defines: string[]): void;
  46285. /**
  46286. * Checks for the readiness of the element composing the layer.
  46287. * @param subMesh the mesh to check for
  46288. * @param useInstances specify wether or not to use instances to render the mesh
  46289. * @param emissiveTexture the associated emissive texture used to generate the glow
  46290. * @return true if ready otherwise, false
  46291. */
  46292. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46293. /**
  46294. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46295. */
  46296. render(): void;
  46297. /**
  46298. * Determine if a given mesh will be used in the current effect.
  46299. * @param mesh mesh to test
  46300. * @returns true if the mesh will be used
  46301. */
  46302. hasMesh(mesh: AbstractMesh): boolean;
  46303. /**
  46304. * Returns true if the layer contains information to display, otherwise false.
  46305. * @returns true if the glow layer should be rendered
  46306. */
  46307. shouldRender(): boolean;
  46308. /**
  46309. * Returns true if the mesh should render, otherwise false.
  46310. * @param mesh The mesh to render
  46311. * @returns true if it should render otherwise false
  46312. */
  46313. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46314. /**
  46315. * Returns true if the mesh can be rendered, otherwise false.
  46316. * @param mesh The mesh to render
  46317. * @param material The material used on the mesh
  46318. * @returns true if it can be rendered otherwise false
  46319. */
  46320. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46321. /**
  46322. * Returns true if the mesh should render, otherwise false.
  46323. * @param mesh The mesh to render
  46324. * @returns true if it should render otherwise false
  46325. */
  46326. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46327. /**
  46328. * Renders the submesh passed in parameter to the generation map.
  46329. */
  46330. protected _renderSubMesh(subMesh: SubMesh): void;
  46331. /**
  46332. * Rebuild the required buffers.
  46333. * @hidden Internal use only.
  46334. */
  46335. _rebuild(): void;
  46336. /**
  46337. * Dispose only the render target textures and post process.
  46338. */
  46339. private _disposeTextureAndPostProcesses;
  46340. /**
  46341. * Dispose the highlight layer and free resources.
  46342. */
  46343. dispose(): void;
  46344. /**
  46345. * Gets the class name of the effect layer
  46346. * @returns the string with the class name of the effect layer
  46347. */
  46348. getClassName(): string;
  46349. /**
  46350. * Creates an effect layer from parsed effect layer data
  46351. * @param parsedEffectLayer defines effect layer data
  46352. * @param scene defines the current scene
  46353. * @param rootUrl defines the root URL containing the effect layer information
  46354. * @returns a parsed effect Layer
  46355. */
  46356. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46357. }
  46358. }
  46359. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  46360. import { Scene } from "babylonjs/scene";
  46361. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46362. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46363. import { AbstractScene } from "babylonjs/abstractScene";
  46364. module "babylonjs/abstractScene" {
  46365. interface AbstractScene {
  46366. /**
  46367. * The list of effect layers (highlights/glow) added to the scene
  46368. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46369. * @see http://doc.babylonjs.com/how_to/glow_layer
  46370. */
  46371. effectLayers: Array<EffectLayer>;
  46372. /**
  46373. * Removes the given effect layer from this scene.
  46374. * @param toRemove defines the effect layer to remove
  46375. * @returns the index of the removed effect layer
  46376. */
  46377. removeEffectLayer(toRemove: EffectLayer): number;
  46378. /**
  46379. * Adds the given effect layer to this scene
  46380. * @param newEffectLayer defines the effect layer to add
  46381. */
  46382. addEffectLayer(newEffectLayer: EffectLayer): void;
  46383. }
  46384. }
  46385. /**
  46386. * Defines the layer scene component responsible to manage any effect layers
  46387. * in a given scene.
  46388. */
  46389. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46390. /**
  46391. * The component name helpfull to identify the component in the list of scene components.
  46392. */
  46393. readonly name: string;
  46394. /**
  46395. * The scene the component belongs to.
  46396. */
  46397. scene: Scene;
  46398. private _engine;
  46399. private _renderEffects;
  46400. private _needStencil;
  46401. private _previousStencilState;
  46402. /**
  46403. * Creates a new instance of the component for the given scene
  46404. * @param scene Defines the scene to register the component in
  46405. */
  46406. constructor(scene: Scene);
  46407. /**
  46408. * Registers the component in a given scene
  46409. */
  46410. register(): void;
  46411. /**
  46412. * Rebuilds the elements related to this component in case of
  46413. * context lost for instance.
  46414. */
  46415. rebuild(): void;
  46416. /**
  46417. * Serializes the component data to the specified json object
  46418. * @param serializationObject The object to serialize to
  46419. */
  46420. serialize(serializationObject: any): void;
  46421. /**
  46422. * Adds all the element from the container to the scene
  46423. * @param container the container holding the elements
  46424. */
  46425. addFromContainer(container: AbstractScene): void;
  46426. /**
  46427. * Removes all the elements in the container from the scene
  46428. * @param container contains the elements to remove
  46429. */
  46430. removeFromContainer(container: AbstractScene): void;
  46431. /**
  46432. * Disposes the component and the associated ressources.
  46433. */
  46434. dispose(): void;
  46435. private _isReadyForMesh;
  46436. private _renderMainTexture;
  46437. private _setStencil;
  46438. private _setStencilBack;
  46439. private _draw;
  46440. private _drawCamera;
  46441. private _drawRenderingGroup;
  46442. }
  46443. }
  46444. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  46445. /** @hidden */
  46446. export var glowMapMergePixelShader: {
  46447. name: string;
  46448. shader: string;
  46449. };
  46450. }
  46451. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  46452. /** @hidden */
  46453. export var glowMapMergeVertexShader: {
  46454. name: string;
  46455. shader: string;
  46456. };
  46457. }
  46458. declare module "babylonjs/Layers/glowLayer" {
  46459. import { Nullable } from "babylonjs/types";
  46460. import { Camera } from "babylonjs/Cameras/camera";
  46461. import { Scene } from "babylonjs/scene";
  46462. import { Color4 } from "babylonjs/Maths/math";
  46463. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46465. import { Mesh } from "babylonjs/Meshes/mesh";
  46466. import { Texture } from "babylonjs/Materials/Textures/texture";
  46467. import { Effect } from "babylonjs/Materials/effect";
  46468. import { Material } from "babylonjs/Materials/material";
  46469. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46470. import "babylonjs/Shaders/glowMapMerge.fragment";
  46471. import "babylonjs/Shaders/glowMapMerge.vertex";
  46472. module "babylonjs/abstractScene" {
  46473. interface AbstractScene {
  46474. /**
  46475. * Return a the first highlight layer of the scene with a given name.
  46476. * @param name The name of the highlight layer to look for.
  46477. * @return The highlight layer if found otherwise null.
  46478. */
  46479. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46480. }
  46481. }
  46482. /**
  46483. * Glow layer options. This helps customizing the behaviour
  46484. * of the glow layer.
  46485. */
  46486. export interface IGlowLayerOptions {
  46487. /**
  46488. * Multiplication factor apply to the canvas size to compute the render target size
  46489. * used to generated the glowing objects (the smaller the faster).
  46490. */
  46491. mainTextureRatio: number;
  46492. /**
  46493. * Enforces a fixed size texture to ensure resize independant blur.
  46494. */
  46495. mainTextureFixedSize?: number;
  46496. /**
  46497. * How big is the kernel of the blur texture.
  46498. */
  46499. blurKernelSize: number;
  46500. /**
  46501. * The camera attached to the layer.
  46502. */
  46503. camera: Nullable<Camera>;
  46504. /**
  46505. * Enable MSAA by chosing the number of samples.
  46506. */
  46507. mainTextureSamples?: number;
  46508. /**
  46509. * The rendering group to draw the layer in.
  46510. */
  46511. renderingGroupId: number;
  46512. }
  46513. /**
  46514. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46515. *
  46516. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46517. * glowy meshes to your scene.
  46518. *
  46519. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46520. */
  46521. export class GlowLayer extends EffectLayer {
  46522. /**
  46523. * Effect Name of the layer.
  46524. */
  46525. static readonly EffectName: string;
  46526. /**
  46527. * The default blur kernel size used for the glow.
  46528. */
  46529. static DefaultBlurKernelSize: number;
  46530. /**
  46531. * The default texture size ratio used for the glow.
  46532. */
  46533. static DefaultTextureRatio: number;
  46534. /**
  46535. * Sets the kernel size of the blur.
  46536. */
  46537. /**
  46538. * Gets the kernel size of the blur.
  46539. */
  46540. blurKernelSize: number;
  46541. /**
  46542. * Sets the glow intensity.
  46543. */
  46544. /**
  46545. * Gets the glow intensity.
  46546. */
  46547. intensity: number;
  46548. private _options;
  46549. private _intensity;
  46550. private _horizontalBlurPostprocess1;
  46551. private _verticalBlurPostprocess1;
  46552. private _horizontalBlurPostprocess2;
  46553. private _verticalBlurPostprocess2;
  46554. private _blurTexture1;
  46555. private _blurTexture2;
  46556. private _postProcesses1;
  46557. private _postProcesses2;
  46558. private _includedOnlyMeshes;
  46559. private _excludedMeshes;
  46560. /**
  46561. * Callback used to let the user override the color selection on a per mesh basis
  46562. */
  46563. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46564. /**
  46565. * Callback used to let the user override the texture selection on a per mesh basis
  46566. */
  46567. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46568. /**
  46569. * Instantiates a new glow Layer and references it to the scene.
  46570. * @param name The name of the layer
  46571. * @param scene The scene to use the layer in
  46572. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46573. */
  46574. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46575. /**
  46576. * Get the effect name of the layer.
  46577. * @return The effect name
  46578. */
  46579. getEffectName(): string;
  46580. /**
  46581. * Create the merge effect. This is the shader use to blit the information back
  46582. * to the main canvas at the end of the scene rendering.
  46583. */
  46584. protected _createMergeEffect(): Effect;
  46585. /**
  46586. * Creates the render target textures and post processes used in the glow layer.
  46587. */
  46588. protected _createTextureAndPostProcesses(): void;
  46589. /**
  46590. * Checks for the readiness of the element composing the layer.
  46591. * @param subMesh the mesh to check for
  46592. * @param useInstances specify wether or not to use instances to render the mesh
  46593. * @param emissiveTexture the associated emissive texture used to generate the glow
  46594. * @return true if ready otherwise, false
  46595. */
  46596. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46597. /**
  46598. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46599. */
  46600. needStencil(): boolean;
  46601. /**
  46602. * Returns true if the mesh can be rendered, otherwise false.
  46603. * @param mesh The mesh to render
  46604. * @param material The material used on the mesh
  46605. * @returns true if it can be rendered otherwise false
  46606. */
  46607. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46608. /**
  46609. * Implementation specific of rendering the generating effect on the main canvas.
  46610. * @param effect The effect used to render through
  46611. */
  46612. protected _internalRender(effect: Effect): void;
  46613. /**
  46614. * Sets the required values for both the emissive texture and and the main color.
  46615. */
  46616. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46617. /**
  46618. * Returns true if the mesh should render, otherwise false.
  46619. * @param mesh The mesh to render
  46620. * @returns true if it should render otherwise false
  46621. */
  46622. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46623. /**
  46624. * Adds specific effects defines.
  46625. * @param defines The defines to add specifics to.
  46626. */
  46627. protected _addCustomEffectDefines(defines: string[]): void;
  46628. /**
  46629. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46630. * @param mesh The mesh to exclude from the glow layer
  46631. */
  46632. addExcludedMesh(mesh: Mesh): void;
  46633. /**
  46634. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46635. * @param mesh The mesh to remove
  46636. */
  46637. removeExcludedMesh(mesh: Mesh): void;
  46638. /**
  46639. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46640. * @param mesh The mesh to include in the glow layer
  46641. */
  46642. addIncludedOnlyMesh(mesh: Mesh): void;
  46643. /**
  46644. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46645. * @param mesh The mesh to remove
  46646. */
  46647. removeIncludedOnlyMesh(mesh: Mesh): void;
  46648. /**
  46649. * Determine if a given mesh will be used in the glow layer
  46650. * @param mesh The mesh to test
  46651. * @returns true if the mesh will be highlighted by the current glow layer
  46652. */
  46653. hasMesh(mesh: AbstractMesh): boolean;
  46654. /**
  46655. * Free any resources and references associated to a mesh.
  46656. * Internal use
  46657. * @param mesh The mesh to free.
  46658. * @hidden
  46659. */
  46660. _disposeMesh(mesh: Mesh): void;
  46661. /**
  46662. * Gets the class name of the effect layer
  46663. * @returns the string with the class name of the effect layer
  46664. */
  46665. getClassName(): string;
  46666. /**
  46667. * Serializes this glow layer
  46668. * @returns a serialized glow layer object
  46669. */
  46670. serialize(): any;
  46671. /**
  46672. * Creates a Glow Layer from parsed glow layer data
  46673. * @param parsedGlowLayer defines glow layer data
  46674. * @param scene defines the current scene
  46675. * @param rootUrl defines the root URL containing the glow layer information
  46676. * @returns a parsed Glow Layer
  46677. */
  46678. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46679. }
  46680. }
  46681. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  46682. /** @hidden */
  46683. export var glowBlurPostProcessPixelShader: {
  46684. name: string;
  46685. shader: string;
  46686. };
  46687. }
  46688. declare module "babylonjs/Layers/highlightLayer" {
  46689. import { Observable } from "babylonjs/Misc/observable";
  46690. import { Nullable } from "babylonjs/types";
  46691. import { Camera } from "babylonjs/Cameras/camera";
  46692. import { Scene } from "babylonjs/scene";
  46693. import { Color3, Color4 } from "babylonjs/Maths/math";
  46694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46696. import { Mesh } from "babylonjs/Meshes/mesh";
  46697. import { Effect } from "babylonjs/Materials/effect";
  46698. import { Material } from "babylonjs/Materials/material";
  46699. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46700. import "babylonjs/Shaders/glowMapMerge.fragment";
  46701. import "babylonjs/Shaders/glowMapMerge.vertex";
  46702. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  46703. module "babylonjs/abstractScene" {
  46704. interface AbstractScene {
  46705. /**
  46706. * Return a the first highlight layer of the scene with a given name.
  46707. * @param name The name of the highlight layer to look for.
  46708. * @return The highlight layer if found otherwise null.
  46709. */
  46710. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46711. }
  46712. }
  46713. /**
  46714. * Highlight layer options. This helps customizing the behaviour
  46715. * of the highlight layer.
  46716. */
  46717. export interface IHighlightLayerOptions {
  46718. /**
  46719. * Multiplication factor apply to the canvas size to compute the render target size
  46720. * used to generated the glowing objects (the smaller the faster).
  46721. */
  46722. mainTextureRatio: number;
  46723. /**
  46724. * Enforces a fixed size texture to ensure resize independant blur.
  46725. */
  46726. mainTextureFixedSize?: number;
  46727. /**
  46728. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46729. * of the picture to blur (the smaller the faster).
  46730. */
  46731. blurTextureSizeRatio: number;
  46732. /**
  46733. * How big in texel of the blur texture is the vertical blur.
  46734. */
  46735. blurVerticalSize: number;
  46736. /**
  46737. * How big in texel of the blur texture is the horizontal blur.
  46738. */
  46739. blurHorizontalSize: number;
  46740. /**
  46741. * Alpha blending mode used to apply the blur. Default is combine.
  46742. */
  46743. alphaBlendingMode: number;
  46744. /**
  46745. * The camera attached to the layer.
  46746. */
  46747. camera: Nullable<Camera>;
  46748. /**
  46749. * Should we display highlight as a solid stroke?
  46750. */
  46751. isStroke?: boolean;
  46752. /**
  46753. * The rendering group to draw the layer in.
  46754. */
  46755. renderingGroupId: number;
  46756. }
  46757. /**
  46758. * The highlight layer Helps adding a glow effect around a mesh.
  46759. *
  46760. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46761. * glowy meshes to your scene.
  46762. *
  46763. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46764. */
  46765. export class HighlightLayer extends EffectLayer {
  46766. name: string;
  46767. /**
  46768. * Effect Name of the highlight layer.
  46769. */
  46770. static readonly EffectName: string;
  46771. /**
  46772. * The neutral color used during the preparation of the glow effect.
  46773. * This is black by default as the blend operation is a blend operation.
  46774. */
  46775. static NeutralColor: Color4;
  46776. /**
  46777. * Stencil value used for glowing meshes.
  46778. */
  46779. static GlowingMeshStencilReference: number;
  46780. /**
  46781. * Stencil value used for the other meshes in the scene.
  46782. */
  46783. static NormalMeshStencilReference: number;
  46784. /**
  46785. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46786. */
  46787. innerGlow: boolean;
  46788. /**
  46789. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46790. */
  46791. outerGlow: boolean;
  46792. /**
  46793. * Specifies the horizontal size of the blur.
  46794. */
  46795. /**
  46796. * Gets the horizontal size of the blur.
  46797. */
  46798. blurHorizontalSize: number;
  46799. /**
  46800. * Specifies the vertical size of the blur.
  46801. */
  46802. /**
  46803. * Gets the vertical size of the blur.
  46804. */
  46805. blurVerticalSize: number;
  46806. /**
  46807. * An event triggered when the highlight layer is being blurred.
  46808. */
  46809. onBeforeBlurObservable: Observable<HighlightLayer>;
  46810. /**
  46811. * An event triggered when the highlight layer has been blurred.
  46812. */
  46813. onAfterBlurObservable: Observable<HighlightLayer>;
  46814. private _instanceGlowingMeshStencilReference;
  46815. private _options;
  46816. private _downSamplePostprocess;
  46817. private _horizontalBlurPostprocess;
  46818. private _verticalBlurPostprocess;
  46819. private _blurTexture;
  46820. private _meshes;
  46821. private _excludedMeshes;
  46822. /**
  46823. * Instantiates a new highlight Layer and references it to the scene..
  46824. * @param name The name of the layer
  46825. * @param scene The scene to use the layer in
  46826. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46827. */
  46828. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46829. /**
  46830. * Get the effect name of the layer.
  46831. * @return The effect name
  46832. */
  46833. getEffectName(): string;
  46834. /**
  46835. * Create the merge effect. This is the shader use to blit the information back
  46836. * to the main canvas at the end of the scene rendering.
  46837. */
  46838. protected _createMergeEffect(): Effect;
  46839. /**
  46840. * Creates the render target textures and post processes used in the highlight layer.
  46841. */
  46842. protected _createTextureAndPostProcesses(): void;
  46843. /**
  46844. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46845. */
  46846. needStencil(): boolean;
  46847. /**
  46848. * Checks for the readiness of the element composing the layer.
  46849. * @param subMesh the mesh to check for
  46850. * @param useInstances specify wether or not to use instances to render the mesh
  46851. * @param emissiveTexture the associated emissive texture used to generate the glow
  46852. * @return true if ready otherwise, false
  46853. */
  46854. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46855. /**
  46856. * Implementation specific of rendering the generating effect on the main canvas.
  46857. * @param effect The effect used to render through
  46858. */
  46859. protected _internalRender(effect: Effect): void;
  46860. /**
  46861. * Returns true if the layer contains information to display, otherwise false.
  46862. */
  46863. shouldRender(): boolean;
  46864. /**
  46865. * Returns true if the mesh should render, otherwise false.
  46866. * @param mesh The mesh to render
  46867. * @returns true if it should render otherwise false
  46868. */
  46869. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46870. /**
  46871. * Sets the required values for both the emissive texture and and the main color.
  46872. */
  46873. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46874. /**
  46875. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46876. * @param mesh The mesh to exclude from the highlight layer
  46877. */
  46878. addExcludedMesh(mesh: Mesh): void;
  46879. /**
  46880. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46881. * @param mesh The mesh to highlight
  46882. */
  46883. removeExcludedMesh(mesh: Mesh): void;
  46884. /**
  46885. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46886. * @param mesh mesh to test
  46887. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46888. */
  46889. hasMesh(mesh: AbstractMesh): boolean;
  46890. /**
  46891. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46892. * @param mesh The mesh to highlight
  46893. * @param color The color of the highlight
  46894. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46895. */
  46896. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46897. /**
  46898. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46899. * @param mesh The mesh to highlight
  46900. */
  46901. removeMesh(mesh: Mesh): void;
  46902. /**
  46903. * Force the stencil to the normal expected value for none glowing parts
  46904. */
  46905. private _defaultStencilReference;
  46906. /**
  46907. * Free any resources and references associated to a mesh.
  46908. * Internal use
  46909. * @param mesh The mesh to free.
  46910. * @hidden
  46911. */
  46912. _disposeMesh(mesh: Mesh): void;
  46913. /**
  46914. * Dispose the highlight layer and free resources.
  46915. */
  46916. dispose(): void;
  46917. /**
  46918. * Gets the class name of the effect layer
  46919. * @returns the string with the class name of the effect layer
  46920. */
  46921. getClassName(): string;
  46922. /**
  46923. * Serializes this Highlight layer
  46924. * @returns a serialized Highlight layer object
  46925. */
  46926. serialize(): any;
  46927. /**
  46928. * Creates a Highlight layer from parsed Highlight layer data
  46929. * @param parsedHightlightLayer defines the Highlight layer data
  46930. * @param scene defines the current scene
  46931. * @param rootUrl defines the root URL containing the Highlight layer information
  46932. * @returns a parsed Highlight layer
  46933. */
  46934. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46935. }
  46936. }
  46937. declare module "babylonjs/Layers/index" {
  46938. export * from "babylonjs/Layers/effectLayer";
  46939. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46940. export * from "babylonjs/Layers/glowLayer";
  46941. export * from "babylonjs/Layers/highlightLayer";
  46942. export * from "babylonjs/Layers/layer";
  46943. export * from "babylonjs/Layers/layerSceneComponent";
  46944. }
  46945. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46946. /** @hidden */
  46947. export var lensFlarePixelShader: {
  46948. name: string;
  46949. shader: string;
  46950. };
  46951. }
  46952. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46953. /** @hidden */
  46954. export var lensFlareVertexShader: {
  46955. name: string;
  46956. shader: string;
  46957. };
  46958. }
  46959. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46960. import { Scene } from "babylonjs/scene";
  46961. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46963. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46964. import "babylonjs/Shaders/lensFlare.fragment";
  46965. import "babylonjs/Shaders/lensFlare.vertex";
  46966. /**
  46967. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46968. * It is usually composed of several `lensFlare`.
  46969. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46970. */
  46971. export class LensFlareSystem {
  46972. /**
  46973. * Define the name of the lens flare system
  46974. */
  46975. name: string;
  46976. /**
  46977. * List of lens flares used in this system.
  46978. */
  46979. lensFlares: LensFlare[];
  46980. /**
  46981. * Define a limit from the border the lens flare can be visible.
  46982. */
  46983. borderLimit: number;
  46984. /**
  46985. * Define a viewport border we do not want to see the lens flare in.
  46986. */
  46987. viewportBorder: number;
  46988. /**
  46989. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46990. */
  46991. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46992. /**
  46993. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46994. */
  46995. layerMask: number;
  46996. /**
  46997. * Define the id of the lens flare system in the scene.
  46998. * (equal to name by default)
  46999. */
  47000. id: string;
  47001. private _scene;
  47002. private _emitter;
  47003. private _vertexBuffers;
  47004. private _indexBuffer;
  47005. private _effect;
  47006. private _positionX;
  47007. private _positionY;
  47008. private _isEnabled;
  47009. /** @hidden */
  47010. static _SceneComponentInitialization: (scene: Scene) => void;
  47011. /**
  47012. * Instantiates a lens flare system.
  47013. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47014. * It is usually composed of several `lensFlare`.
  47015. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47016. * @param name Define the name of the lens flare system in the scene
  47017. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47018. * @param scene Define the scene the lens flare system belongs to
  47019. */
  47020. constructor(
  47021. /**
  47022. * Define the name of the lens flare system
  47023. */
  47024. name: string, emitter: any, scene: Scene);
  47025. /**
  47026. * Define if the lens flare system is enabled.
  47027. */
  47028. isEnabled: boolean;
  47029. /**
  47030. * Get the scene the effects belongs to.
  47031. * @returns the scene holding the lens flare system
  47032. */
  47033. getScene(): Scene;
  47034. /**
  47035. * Get the emitter of the lens flare system.
  47036. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47037. * @returns the emitter of the lens flare system
  47038. */
  47039. getEmitter(): any;
  47040. /**
  47041. * Set the emitter of the lens flare system.
  47042. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47043. * @param newEmitter Define the new emitter of the system
  47044. */
  47045. setEmitter(newEmitter: any): void;
  47046. /**
  47047. * Get the lens flare system emitter position.
  47048. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47049. * @returns the position
  47050. */
  47051. getEmitterPosition(): Vector3;
  47052. /**
  47053. * @hidden
  47054. */
  47055. computeEffectivePosition(globalViewport: Viewport): boolean;
  47056. /** @hidden */
  47057. _isVisible(): boolean;
  47058. /**
  47059. * @hidden
  47060. */
  47061. render(): boolean;
  47062. /**
  47063. * Dispose and release the lens flare with its associated resources.
  47064. */
  47065. dispose(): void;
  47066. /**
  47067. * Parse a lens flare system from a JSON repressentation
  47068. * @param parsedLensFlareSystem Define the JSON to parse
  47069. * @param scene Define the scene the parsed system should be instantiated in
  47070. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47071. * @returns the parsed system
  47072. */
  47073. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47074. /**
  47075. * Serialize the current Lens Flare System into a JSON representation.
  47076. * @returns the serialized JSON
  47077. */
  47078. serialize(): any;
  47079. }
  47080. }
  47081. declare module "babylonjs/LensFlares/lensFlare" {
  47082. import { Nullable } from "babylonjs/types";
  47083. import { Color3 } from "babylonjs/Maths/math";
  47084. import { Texture } from "babylonjs/Materials/Textures/texture";
  47085. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47086. /**
  47087. * This represents one of the lens effect in a `lensFlareSystem`.
  47088. * It controls one of the indiviual texture used in the effect.
  47089. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47090. */
  47091. export class LensFlare {
  47092. /**
  47093. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47094. */
  47095. size: number;
  47096. /**
  47097. * 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.
  47098. */
  47099. position: number;
  47100. /**
  47101. * Define the lens color.
  47102. */
  47103. color: Color3;
  47104. /**
  47105. * Define the lens texture.
  47106. */
  47107. texture: Nullable<Texture>;
  47108. /**
  47109. * Define the alpha mode to render this particular lens.
  47110. */
  47111. alphaMode: number;
  47112. private _system;
  47113. /**
  47114. * Creates a new Lens Flare.
  47115. * This represents one of the lens effect in a `lensFlareSystem`.
  47116. * It controls one of the indiviual texture used in the effect.
  47117. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47118. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47119. * @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.
  47120. * @param color Define the lens color
  47121. * @param imgUrl Define the lens texture url
  47122. * @param system Define the `lensFlareSystem` this flare is part of
  47123. * @returns The newly created Lens Flare
  47124. */
  47125. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47126. /**
  47127. * Instantiates a new Lens Flare.
  47128. * This represents one of the lens effect in a `lensFlareSystem`.
  47129. * It controls one of the indiviual texture used in the effect.
  47130. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47131. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47132. * @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.
  47133. * @param color Define the lens color
  47134. * @param imgUrl Define the lens texture url
  47135. * @param system Define the `lensFlareSystem` this flare is part of
  47136. */
  47137. constructor(
  47138. /**
  47139. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47140. */
  47141. size: number,
  47142. /**
  47143. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  47144. */
  47145. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47146. /**
  47147. * Dispose and release the lens flare with its associated resources.
  47148. */
  47149. dispose(): void;
  47150. }
  47151. }
  47152. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47153. import { Nullable } from "babylonjs/types";
  47154. import { Scene } from "babylonjs/scene";
  47155. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47156. import { AbstractScene } from "babylonjs/abstractScene";
  47157. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47158. module "babylonjs/abstractScene" {
  47159. interface AbstractScene {
  47160. /**
  47161. * The list of lens flare system added to the scene
  47162. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47163. */
  47164. lensFlareSystems: Array<LensFlareSystem>;
  47165. /**
  47166. * Removes the given lens flare system from this scene.
  47167. * @param toRemove The lens flare system to remove
  47168. * @returns The index of the removed lens flare system
  47169. */
  47170. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47171. /**
  47172. * Adds the given lens flare system to this scene
  47173. * @param newLensFlareSystem The lens flare system to add
  47174. */
  47175. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47176. /**
  47177. * Gets a lens flare system using its name
  47178. * @param name defines the name to look for
  47179. * @returns the lens flare system or null if not found
  47180. */
  47181. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47182. /**
  47183. * Gets a lens flare system using its id
  47184. * @param id defines the id to look for
  47185. * @returns the lens flare system or null if not found
  47186. */
  47187. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47188. }
  47189. }
  47190. /**
  47191. * Defines the lens flare scene component responsible to manage any lens flares
  47192. * in a given scene.
  47193. */
  47194. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47195. /**
  47196. * The component name helpfull to identify the component in the list of scene components.
  47197. */
  47198. readonly name: string;
  47199. /**
  47200. * The scene the component belongs to.
  47201. */
  47202. scene: Scene;
  47203. /**
  47204. * Creates a new instance of the component for the given scene
  47205. * @param scene Defines the scene to register the component in
  47206. */
  47207. constructor(scene: Scene);
  47208. /**
  47209. * Registers the component in a given scene
  47210. */
  47211. register(): void;
  47212. /**
  47213. * Rebuilds the elements related to this component in case of
  47214. * context lost for instance.
  47215. */
  47216. rebuild(): void;
  47217. /**
  47218. * Adds all the element from the container to the scene
  47219. * @param container the container holding the elements
  47220. */
  47221. addFromContainer(container: AbstractScene): void;
  47222. /**
  47223. * Removes all the elements in the container from the scene
  47224. * @param container contains the elements to remove
  47225. */
  47226. removeFromContainer(container: AbstractScene): void;
  47227. /**
  47228. * Serializes the component data to the specified json object
  47229. * @param serializationObject The object to serialize to
  47230. */
  47231. serialize(serializationObject: any): void;
  47232. /**
  47233. * Disposes the component and the associated ressources.
  47234. */
  47235. dispose(): void;
  47236. private _draw;
  47237. }
  47238. }
  47239. declare module "babylonjs/LensFlares/index" {
  47240. export * from "babylonjs/LensFlares/lensFlare";
  47241. export * from "babylonjs/LensFlares/lensFlareSystem";
  47242. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47243. }
  47244. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47245. import { Scene } from "babylonjs/scene";
  47246. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47247. import { AbstractScene } from "babylonjs/abstractScene";
  47248. /**
  47249. * Defines the shadow generator component responsible to manage any shadow generators
  47250. * in a given scene.
  47251. */
  47252. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47253. /**
  47254. * The component name helpfull to identify the component in the list of scene components.
  47255. */
  47256. readonly name: string;
  47257. /**
  47258. * The scene the component belongs to.
  47259. */
  47260. scene: Scene;
  47261. /**
  47262. * Creates a new instance of the component for the given scene
  47263. * @param scene Defines the scene to register the component in
  47264. */
  47265. constructor(scene: Scene);
  47266. /**
  47267. * Registers the component in a given scene
  47268. */
  47269. register(): void;
  47270. /**
  47271. * Rebuilds the elements related to this component in case of
  47272. * context lost for instance.
  47273. */
  47274. rebuild(): void;
  47275. /**
  47276. * Serializes the component data to the specified json object
  47277. * @param serializationObject The object to serialize to
  47278. */
  47279. serialize(serializationObject: any): void;
  47280. /**
  47281. * Adds all the element from the container to the scene
  47282. * @param container the container holding the elements
  47283. */
  47284. addFromContainer(container: AbstractScene): void;
  47285. /**
  47286. * Removes all the elements in the container from the scene
  47287. * @param container contains the elements to remove
  47288. */
  47289. removeFromContainer(container: AbstractScene): void;
  47290. /**
  47291. * Rebuilds the elements related to this component in case of
  47292. * context lost for instance.
  47293. */
  47294. dispose(): void;
  47295. private _gatherRenderTargets;
  47296. }
  47297. }
  47298. declare module "babylonjs/Lights/Shadows/index" {
  47299. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  47300. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  47301. }
  47302. declare module "babylonjs/Lights/directionalLight" {
  47303. import { Camera } from "babylonjs/Cameras/camera";
  47304. import { Scene } from "babylonjs/scene";
  47305. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47307. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47308. import { Effect } from "babylonjs/Materials/effect";
  47309. /**
  47310. * A directional light is defined by a direction (what a surprise!).
  47311. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47312. * 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.
  47313. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47314. */
  47315. export class DirectionalLight extends ShadowLight {
  47316. private _shadowFrustumSize;
  47317. /**
  47318. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47319. */
  47320. /**
  47321. * Specifies a fix frustum size for the shadow generation.
  47322. */
  47323. shadowFrustumSize: number;
  47324. private _shadowOrthoScale;
  47325. /**
  47326. * Gets the shadow projection scale against the optimal computed one.
  47327. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47328. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47329. */
  47330. /**
  47331. * Sets the shadow projection scale against the optimal computed one.
  47332. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47333. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47334. */
  47335. shadowOrthoScale: number;
  47336. /**
  47337. * Automatically compute the projection matrix to best fit (including all the casters)
  47338. * on each frame.
  47339. */
  47340. autoUpdateExtends: boolean;
  47341. private _orthoLeft;
  47342. private _orthoRight;
  47343. private _orthoTop;
  47344. private _orthoBottom;
  47345. /**
  47346. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47347. * The directional light is emitted from everywhere in the given direction.
  47348. * It can cast shadows.
  47349. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47350. * @param name The friendly name of the light
  47351. * @param direction The direction of the light
  47352. * @param scene The scene the light belongs to
  47353. */
  47354. constructor(name: string, direction: Vector3, scene: Scene);
  47355. /**
  47356. * Returns the string "DirectionalLight".
  47357. * @return The class name
  47358. */
  47359. getClassName(): string;
  47360. /**
  47361. * Returns the integer 1.
  47362. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47363. */
  47364. getTypeID(): number;
  47365. /**
  47366. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47367. * Returns the DirectionalLight Shadow projection matrix.
  47368. */
  47369. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47370. /**
  47371. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47372. * Returns the DirectionalLight Shadow projection matrix.
  47373. */
  47374. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47375. /**
  47376. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47377. * Returns the DirectionalLight Shadow projection matrix.
  47378. */
  47379. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47380. protected _buildUniformLayout(): void;
  47381. /**
  47382. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47383. * @param effect The effect to update
  47384. * @param lightIndex The index of the light in the effect to update
  47385. * @returns The directional light
  47386. */
  47387. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47388. /**
  47389. * Gets the minZ used for shadow according to both the scene and the light.
  47390. *
  47391. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47392. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47393. * @param activeCamera The camera we are returning the min for
  47394. * @returns the depth min z
  47395. */
  47396. getDepthMinZ(activeCamera: Camera): number;
  47397. /**
  47398. * Gets the maxZ used for shadow according to both the scene and the light.
  47399. *
  47400. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47401. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47402. * @param activeCamera The camera we are returning the max for
  47403. * @returns the depth max z
  47404. */
  47405. getDepthMaxZ(activeCamera: Camera): number;
  47406. /**
  47407. * Prepares the list of defines specific to the light type.
  47408. * @param defines the list of defines
  47409. * @param lightIndex defines the index of the light for the effect
  47410. */
  47411. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47412. }
  47413. }
  47414. declare module "babylonjs/Lights/pointLight" {
  47415. import { Scene } from "babylonjs/scene";
  47416. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47418. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47419. import { Effect } from "babylonjs/Materials/effect";
  47420. /**
  47421. * A point light is a light defined by an unique point in world space.
  47422. * The light is emitted in every direction from this point.
  47423. * A good example of a point light is a standard light bulb.
  47424. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47425. */
  47426. export class PointLight extends ShadowLight {
  47427. private _shadowAngle;
  47428. /**
  47429. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47430. * This specifies what angle the shadow will use to be created.
  47431. *
  47432. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47433. */
  47434. /**
  47435. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47436. * This specifies what angle the shadow will use to be created.
  47437. *
  47438. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47439. */
  47440. shadowAngle: number;
  47441. /**
  47442. * Gets the direction if it has been set.
  47443. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47444. */
  47445. /**
  47446. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47447. */
  47448. direction: Vector3;
  47449. /**
  47450. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47451. * A PointLight emits the light in every direction.
  47452. * It can cast shadows.
  47453. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47454. * ```javascript
  47455. * var pointLight = new PointLight("pl", camera.position, scene);
  47456. * ```
  47457. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47458. * @param name The light friendly name
  47459. * @param position The position of the point light in the scene
  47460. * @param scene The scene the lights belongs to
  47461. */
  47462. constructor(name: string, position: Vector3, scene: Scene);
  47463. /**
  47464. * Returns the string "PointLight"
  47465. * @returns the class name
  47466. */
  47467. getClassName(): string;
  47468. /**
  47469. * Returns the integer 0.
  47470. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47471. */
  47472. getTypeID(): number;
  47473. /**
  47474. * Specifies wether or not the shadowmap should be a cube texture.
  47475. * @returns true if the shadowmap needs to be a cube texture.
  47476. */
  47477. needCube(): boolean;
  47478. /**
  47479. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47480. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47481. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47482. */
  47483. getShadowDirection(faceIndex?: number): Vector3;
  47484. /**
  47485. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47486. * - fov = PI / 2
  47487. * - aspect ratio : 1.0
  47488. * - z-near and far equal to the active camera minZ and maxZ.
  47489. * Returns the PointLight.
  47490. */
  47491. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47492. protected _buildUniformLayout(): void;
  47493. /**
  47494. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47495. * @param effect The effect to update
  47496. * @param lightIndex The index of the light in the effect to update
  47497. * @returns The point light
  47498. */
  47499. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47500. /**
  47501. * Prepares the list of defines specific to the light type.
  47502. * @param defines the list of defines
  47503. * @param lightIndex defines the index of the light for the effect
  47504. */
  47505. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47506. }
  47507. }
  47508. declare module "babylonjs/Lights/spotLight" {
  47509. import { Nullable } from "babylonjs/types";
  47510. import { Scene } from "babylonjs/scene";
  47511. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47513. import { Effect } from "babylonjs/Materials/effect";
  47514. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47515. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47516. /**
  47517. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47518. * These values define a cone of light starting from the position, emitting toward the direction.
  47519. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47520. * and the exponent defines the speed of the decay of the light with distance (reach).
  47521. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47522. */
  47523. export class SpotLight extends ShadowLight {
  47524. private _angle;
  47525. private _innerAngle;
  47526. private _cosHalfAngle;
  47527. private _lightAngleScale;
  47528. private _lightAngleOffset;
  47529. /**
  47530. * Gets the cone angle of the spot light in Radians.
  47531. */
  47532. /**
  47533. * Sets the cone angle of the spot light in Radians.
  47534. */
  47535. angle: number;
  47536. /**
  47537. * Only used in gltf falloff mode, this defines the angle where
  47538. * the directional falloff will start before cutting at angle which could be seen
  47539. * as outer angle.
  47540. */
  47541. /**
  47542. * Only used in gltf falloff mode, this defines the angle where
  47543. * the directional falloff will start before cutting at angle which could be seen
  47544. * as outer angle.
  47545. */
  47546. innerAngle: number;
  47547. private _shadowAngleScale;
  47548. /**
  47549. * Allows scaling the angle of the light for shadow generation only.
  47550. */
  47551. /**
  47552. * Allows scaling the angle of the light for shadow generation only.
  47553. */
  47554. shadowAngleScale: number;
  47555. /**
  47556. * The light decay speed with the distance from the emission spot.
  47557. */
  47558. exponent: number;
  47559. private _projectionTextureMatrix;
  47560. /**
  47561. * Allows reading the projecton texture
  47562. */
  47563. readonly projectionTextureMatrix: Matrix;
  47564. protected _projectionTextureLightNear: number;
  47565. /**
  47566. * Gets the near clip of the Spotlight for texture projection.
  47567. */
  47568. /**
  47569. * Sets the near clip of the Spotlight for texture projection.
  47570. */
  47571. projectionTextureLightNear: number;
  47572. protected _projectionTextureLightFar: number;
  47573. /**
  47574. * Gets the far clip of the Spotlight for texture projection.
  47575. */
  47576. /**
  47577. * Sets the far clip of the Spotlight for texture projection.
  47578. */
  47579. projectionTextureLightFar: number;
  47580. protected _projectionTextureUpDirection: Vector3;
  47581. /**
  47582. * Gets the Up vector of the Spotlight for texture projection.
  47583. */
  47584. /**
  47585. * Sets the Up vector of the Spotlight for texture projection.
  47586. */
  47587. projectionTextureUpDirection: Vector3;
  47588. private _projectionTexture;
  47589. /**
  47590. * Gets the projection texture of the light.
  47591. */
  47592. /**
  47593. * Sets the projection texture of the light.
  47594. */
  47595. projectionTexture: Nullable<BaseTexture>;
  47596. private _projectionTextureViewLightDirty;
  47597. private _projectionTextureProjectionLightDirty;
  47598. private _projectionTextureDirty;
  47599. private _projectionTextureViewTargetVector;
  47600. private _projectionTextureViewLightMatrix;
  47601. private _projectionTextureProjectionLightMatrix;
  47602. private _projectionTextureScalingMatrix;
  47603. /**
  47604. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47605. * It can cast shadows.
  47606. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47607. * @param name The light friendly name
  47608. * @param position The position of the spot light in the scene
  47609. * @param direction The direction of the light in the scene
  47610. * @param angle The cone angle of the light in Radians
  47611. * @param exponent The light decay speed with the distance from the emission spot
  47612. * @param scene The scene the lights belongs to
  47613. */
  47614. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47615. /**
  47616. * Returns the string "SpotLight".
  47617. * @returns the class name
  47618. */
  47619. getClassName(): string;
  47620. /**
  47621. * Returns the integer 2.
  47622. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47623. */
  47624. getTypeID(): number;
  47625. /**
  47626. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47627. */
  47628. protected _setDirection(value: Vector3): void;
  47629. /**
  47630. * Overrides the position setter to recompute the projection texture view light Matrix.
  47631. */
  47632. protected _setPosition(value: Vector3): void;
  47633. /**
  47634. * 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.
  47635. * Returns the SpotLight.
  47636. */
  47637. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47638. protected _computeProjectionTextureViewLightMatrix(): void;
  47639. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47640. /**
  47641. * Main function for light texture projection matrix computing.
  47642. */
  47643. protected _computeProjectionTextureMatrix(): void;
  47644. protected _buildUniformLayout(): void;
  47645. private _computeAngleValues;
  47646. /**
  47647. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47648. * @param effect The effect to update
  47649. * @param lightIndex The index of the light in the effect to update
  47650. * @returns The spot light
  47651. */
  47652. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47653. /**
  47654. * Disposes the light and the associated resources.
  47655. */
  47656. dispose(): void;
  47657. /**
  47658. * Prepares the list of defines specific to the light type.
  47659. * @param defines the list of defines
  47660. * @param lightIndex defines the index of the light for the effect
  47661. */
  47662. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47663. }
  47664. }
  47665. declare module "babylonjs/Lights/index" {
  47666. export * from "babylonjs/Lights/light";
  47667. export * from "babylonjs/Lights/shadowLight";
  47668. export * from "babylonjs/Lights/Shadows/index";
  47669. export * from "babylonjs/Lights/directionalLight";
  47670. export * from "babylonjs/Lights/hemisphericLight";
  47671. export * from "babylonjs/Lights/pointLight";
  47672. export * from "babylonjs/Lights/spotLight";
  47673. }
  47674. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  47675. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47676. /**
  47677. * Header information of HDR texture files.
  47678. */
  47679. export interface HDRInfo {
  47680. /**
  47681. * The height of the texture in pixels.
  47682. */
  47683. height: number;
  47684. /**
  47685. * The width of the texture in pixels.
  47686. */
  47687. width: number;
  47688. /**
  47689. * The index of the beginning of the data in the binary file.
  47690. */
  47691. dataPosition: number;
  47692. }
  47693. /**
  47694. * This groups tools to convert HDR texture to native colors array.
  47695. */
  47696. export class HDRTools {
  47697. private static Ldexp;
  47698. private static Rgbe2float;
  47699. private static readStringLine;
  47700. /**
  47701. * Reads header information from an RGBE texture stored in a native array.
  47702. * More information on this format are available here:
  47703. * https://en.wikipedia.org/wiki/RGBE_image_format
  47704. *
  47705. * @param uint8array The binary file stored in native array.
  47706. * @return The header information.
  47707. */
  47708. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47709. /**
  47710. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47711. * This RGBE texture needs to store the information as a panorama.
  47712. *
  47713. * More information on this format are available here:
  47714. * https://en.wikipedia.org/wiki/RGBE_image_format
  47715. *
  47716. * @param buffer The binary file stored in an array buffer.
  47717. * @param size The expected size of the extracted cubemap.
  47718. * @return The Cube Map information.
  47719. */
  47720. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47721. /**
  47722. * Returns the pixels data extracted from an RGBE texture.
  47723. * This pixels will be stored left to right up to down in the R G B order in one array.
  47724. *
  47725. * More information on this format are available here:
  47726. * https://en.wikipedia.org/wiki/RGBE_image_format
  47727. *
  47728. * @param uint8array The binary file stored in an array buffer.
  47729. * @param hdrInfo The header information of the file.
  47730. * @return The pixels data in RGB right to left up to down order.
  47731. */
  47732. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47733. private static RGBE_ReadPixels_RLE;
  47734. }
  47735. }
  47736. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  47737. import { Nullable } from "babylonjs/types";
  47738. import { Scene } from "babylonjs/scene";
  47739. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47741. /**
  47742. * This represents a texture coming from an HDR input.
  47743. *
  47744. * The only supported format is currently panorama picture stored in RGBE format.
  47745. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47746. */
  47747. export class HDRCubeTexture extends BaseTexture {
  47748. private static _facesMapping;
  47749. private _generateHarmonics;
  47750. private _noMipmap;
  47751. private _textureMatrix;
  47752. private _size;
  47753. private _onLoad;
  47754. private _onError;
  47755. /**
  47756. * The texture URL.
  47757. */
  47758. url: string;
  47759. /**
  47760. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47761. */
  47762. coordinatesMode: number;
  47763. protected _isBlocking: boolean;
  47764. /**
  47765. * Sets wether or not the texture is blocking during loading.
  47766. */
  47767. /**
  47768. * Gets wether or not the texture is blocking during loading.
  47769. */
  47770. isBlocking: boolean;
  47771. protected _rotationY: number;
  47772. /**
  47773. * Sets texture matrix rotation angle around Y axis in radians.
  47774. */
  47775. /**
  47776. * Gets texture matrix rotation angle around Y axis radians.
  47777. */
  47778. rotationY: number;
  47779. /**
  47780. * Gets or sets the center of the bounding box associated with the cube texture
  47781. * It must define where the camera used to render the texture was set
  47782. */
  47783. boundingBoxPosition: Vector3;
  47784. private _boundingBoxSize;
  47785. /**
  47786. * Gets or sets the size of the bounding box associated with the cube texture
  47787. * When defined, the cubemap will switch to local mode
  47788. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47789. * @example https://www.babylonjs-playground.com/#RNASML
  47790. */
  47791. boundingBoxSize: Vector3;
  47792. /**
  47793. * Instantiates an HDRTexture from the following parameters.
  47794. *
  47795. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47796. * @param scene The scene the texture will be used in
  47797. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47798. * @param noMipmap Forces to not generate the mipmap if true
  47799. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47800. * @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)
  47801. * @param reserved Reserved flag for internal use.
  47802. */
  47803. 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>);
  47804. /**
  47805. * Get the current class name of the texture useful for serialization or dynamic coding.
  47806. * @returns "HDRCubeTexture"
  47807. */
  47808. getClassName(): string;
  47809. /**
  47810. * Occurs when the file is raw .hdr file.
  47811. */
  47812. private loadTexture;
  47813. clone(): HDRCubeTexture;
  47814. delayLoad(): void;
  47815. /**
  47816. * Get the texture reflection matrix used to rotate/transform the reflection.
  47817. * @returns the reflection matrix
  47818. */
  47819. getReflectionTextureMatrix(): Matrix;
  47820. /**
  47821. * Set the texture reflection matrix used to rotate/transform the reflection.
  47822. * @param value Define the reflection matrix to set
  47823. */
  47824. setReflectionTextureMatrix(value: Matrix): void;
  47825. /**
  47826. * Parses a JSON representation of an HDR Texture in order to create the texture
  47827. * @param parsedTexture Define the JSON representation
  47828. * @param scene Define the scene the texture should be created in
  47829. * @param rootUrl Define the root url in case we need to load relative dependencies
  47830. * @returns the newly created texture after parsing
  47831. */
  47832. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47833. serialize(): any;
  47834. }
  47835. }
  47836. declare module "babylonjs/Physics/physicsEngine" {
  47837. import { Nullable } from "babylonjs/types";
  47838. import { Vector3 } from "babylonjs/Maths/math";
  47839. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47840. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47841. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47842. /**
  47843. * Class used to control physics engine
  47844. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47845. */
  47846. export class PhysicsEngine implements IPhysicsEngine {
  47847. private _physicsPlugin;
  47848. /**
  47849. * Global value used to control the smallest number supported by the simulation
  47850. */
  47851. static Epsilon: number;
  47852. private _impostors;
  47853. private _joints;
  47854. /**
  47855. * Gets the gravity vector used by the simulation
  47856. */
  47857. gravity: Vector3;
  47858. /**
  47859. * Factory used to create the default physics plugin.
  47860. * @returns The default physics plugin
  47861. */
  47862. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47863. /**
  47864. * Creates a new Physics Engine
  47865. * @param gravity defines the gravity vector used by the simulation
  47866. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47867. */
  47868. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47869. /**
  47870. * Sets the gravity vector used by the simulation
  47871. * @param gravity defines the gravity vector to use
  47872. */
  47873. setGravity(gravity: Vector3): void;
  47874. /**
  47875. * Set the time step of the physics engine.
  47876. * Default is 1/60.
  47877. * To slow it down, enter 1/600 for example.
  47878. * To speed it up, 1/30
  47879. * @param newTimeStep defines the new timestep to apply to this world.
  47880. */
  47881. setTimeStep(newTimeStep?: number): void;
  47882. /**
  47883. * Get the time step of the physics engine.
  47884. * @returns the current time step
  47885. */
  47886. getTimeStep(): number;
  47887. /**
  47888. * Release all resources
  47889. */
  47890. dispose(): void;
  47891. /**
  47892. * Gets the name of the current physics plugin
  47893. * @returns the name of the plugin
  47894. */
  47895. getPhysicsPluginName(): string;
  47896. /**
  47897. * Adding a new impostor for the impostor tracking.
  47898. * This will be done by the impostor itself.
  47899. * @param impostor the impostor to add
  47900. */
  47901. addImpostor(impostor: PhysicsImpostor): void;
  47902. /**
  47903. * Remove an impostor from the engine.
  47904. * This impostor and its mesh will not longer be updated by the physics engine.
  47905. * @param impostor the impostor to remove
  47906. */
  47907. removeImpostor(impostor: PhysicsImpostor): void;
  47908. /**
  47909. * Add a joint to the physics engine
  47910. * @param mainImpostor defines the main impostor to which the joint is added.
  47911. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47912. * @param joint defines the joint that will connect both impostors.
  47913. */
  47914. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47915. /**
  47916. * Removes a joint from the simulation
  47917. * @param mainImpostor defines the impostor used with the joint
  47918. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47919. * @param joint defines the joint to remove
  47920. */
  47921. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47922. /**
  47923. * Called by the scene. No need to call it.
  47924. * @param delta defines the timespam between frames
  47925. */
  47926. _step(delta: number): void;
  47927. /**
  47928. * Gets the current plugin used to run the simulation
  47929. * @returns current plugin
  47930. */
  47931. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47932. /**
  47933. * Gets the list of physic impostors
  47934. * @returns an array of PhysicsImpostor
  47935. */
  47936. getImpostors(): Array<PhysicsImpostor>;
  47937. /**
  47938. * Gets the impostor for a physics enabled object
  47939. * @param object defines the object impersonated by the impostor
  47940. * @returns the PhysicsImpostor or null if not found
  47941. */
  47942. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47943. /**
  47944. * Gets the impostor for a physics body object
  47945. * @param body defines physics body used by the impostor
  47946. * @returns the PhysicsImpostor or null if not found
  47947. */
  47948. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47949. }
  47950. }
  47951. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47952. import { Nullable } from "babylonjs/types";
  47953. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47955. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47956. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47957. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47958. /** @hidden */
  47959. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47960. private _useDeltaForWorldStep;
  47961. world: any;
  47962. name: string;
  47963. private _physicsMaterials;
  47964. private _fixedTimeStep;
  47965. BJSCANNON: any;
  47966. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47967. setGravity(gravity: Vector3): void;
  47968. setTimeStep(timeStep: number): void;
  47969. getTimeStep(): number;
  47970. executeStep(delta: number): void;
  47971. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47972. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47973. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47974. private _processChildMeshes;
  47975. removePhysicsBody(impostor: PhysicsImpostor): void;
  47976. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47977. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47978. private _addMaterial;
  47979. private _checkWithEpsilon;
  47980. private _createShape;
  47981. private _createHeightmap;
  47982. private _minus90X;
  47983. private _plus90X;
  47984. private _tmpPosition;
  47985. private _tmpDeltaPosition;
  47986. private _tmpUnityRotation;
  47987. private _updatePhysicsBodyTransformation;
  47988. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47989. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47990. isSupported(): boolean;
  47991. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47992. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47993. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47994. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47995. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47996. getBodyMass(impostor: PhysicsImpostor): number;
  47997. getBodyFriction(impostor: PhysicsImpostor): number;
  47998. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47999. getBodyRestitution(impostor: PhysicsImpostor): number;
  48000. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48001. sleepBody(impostor: PhysicsImpostor): void;
  48002. wakeUpBody(impostor: PhysicsImpostor): void;
  48003. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48004. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48005. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48006. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48007. getRadius(impostor: PhysicsImpostor): number;
  48008. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48009. dispose(): void;
  48010. private _extendNamespace;
  48011. }
  48012. }
  48013. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48014. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48015. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48016. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48018. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48019. import { Nullable } from "babylonjs/types";
  48020. /** @hidden */
  48021. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48022. world: any;
  48023. name: string;
  48024. BJSOIMO: any;
  48025. constructor(iterations?: number, oimoInjection?: any);
  48026. setGravity(gravity: Vector3): void;
  48027. setTimeStep(timeStep: number): void;
  48028. getTimeStep(): number;
  48029. private _tmpImpostorsArray;
  48030. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48031. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48032. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48033. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48034. private _tmpPositionVector;
  48035. removePhysicsBody(impostor: PhysicsImpostor): void;
  48036. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48037. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48038. isSupported(): boolean;
  48039. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48040. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48041. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48042. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48043. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48044. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48045. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48046. getBodyMass(impostor: PhysicsImpostor): number;
  48047. getBodyFriction(impostor: PhysicsImpostor): number;
  48048. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48049. getBodyRestitution(impostor: PhysicsImpostor): number;
  48050. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48051. sleepBody(impostor: PhysicsImpostor): void;
  48052. wakeUpBody(impostor: PhysicsImpostor): void;
  48053. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48054. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48055. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48056. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48057. getRadius(impostor: PhysicsImpostor): number;
  48058. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48059. dispose(): void;
  48060. }
  48061. }
  48062. declare module "babylonjs/Probes/reflectionProbe" {
  48063. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48064. import { Vector3 } from "babylonjs/Maths/math";
  48065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48066. import { Nullable } from "babylonjs/types";
  48067. import { Scene } from "babylonjs/scene";
  48068. module "babylonjs/abstractScene" {
  48069. interface AbstractScene {
  48070. /**
  48071. * The list of reflection probes added to the scene
  48072. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48073. */
  48074. reflectionProbes: Array<ReflectionProbe>;
  48075. /**
  48076. * Removes the given reflection probe from this scene.
  48077. * @param toRemove The reflection probe to remove
  48078. * @returns The index of the removed reflection probe
  48079. */
  48080. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48081. /**
  48082. * Adds the given reflection probe to this scene.
  48083. * @param newReflectionProbe The reflection probe to add
  48084. */
  48085. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48086. }
  48087. }
  48088. /**
  48089. * Class used to generate realtime reflection / refraction cube textures
  48090. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48091. */
  48092. export class ReflectionProbe {
  48093. /** defines the name of the probe */
  48094. name: string;
  48095. private _scene;
  48096. private _renderTargetTexture;
  48097. private _projectionMatrix;
  48098. private _viewMatrix;
  48099. private _target;
  48100. private _add;
  48101. private _attachedMesh;
  48102. private _invertYAxis;
  48103. /** Gets or sets probe position (center of the cube map) */
  48104. position: Vector3;
  48105. /**
  48106. * Creates a new reflection probe
  48107. * @param name defines the name of the probe
  48108. * @param size defines the texture resolution (for each face)
  48109. * @param scene defines the hosting scene
  48110. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48111. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48112. */
  48113. constructor(
  48114. /** defines the name of the probe */
  48115. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48116. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48117. samples: number;
  48118. /** Gets or sets the refresh rate to use (on every frame by default) */
  48119. refreshRate: number;
  48120. /**
  48121. * Gets the hosting scene
  48122. * @returns a Scene
  48123. */
  48124. getScene(): Scene;
  48125. /** Gets the internal CubeTexture used to render to */
  48126. readonly cubeTexture: RenderTargetTexture;
  48127. /** Gets the list of meshes to render */
  48128. readonly renderList: Nullable<AbstractMesh[]>;
  48129. /**
  48130. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48131. * @param mesh defines the mesh to attach to
  48132. */
  48133. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48134. /**
  48135. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48136. * @param renderingGroupId The rendering group id corresponding to its index
  48137. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48138. */
  48139. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48140. /**
  48141. * Clean all associated resources
  48142. */
  48143. dispose(): void;
  48144. /**
  48145. * Converts the reflection probe information to a readable string for debug purpose.
  48146. * @param fullDetails Supports for multiple levels of logging within scene loading
  48147. * @returns the human readable reflection probe info
  48148. */
  48149. toString(fullDetails?: boolean): string;
  48150. /**
  48151. * Get the class name of the relfection probe.
  48152. * @returns "ReflectionProbe"
  48153. */
  48154. getClassName(): string;
  48155. /**
  48156. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48157. * @returns The JSON representation of the texture
  48158. */
  48159. serialize(): any;
  48160. /**
  48161. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48162. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48163. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48164. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48165. * @returns The parsed reflection probe if successful
  48166. */
  48167. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48168. }
  48169. }
  48170. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48171. /** @hidden */
  48172. export var _BabylonLoaderRegistered: boolean;
  48173. }
  48174. declare module "babylonjs/Loading/Plugins/index" {
  48175. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48176. }
  48177. declare module "babylonjs/Loading/index" {
  48178. export * from "babylonjs/Loading/loadingScreen";
  48179. export * from "babylonjs/Loading/Plugins/index";
  48180. export * from "babylonjs/Loading/sceneLoader";
  48181. export * from "babylonjs/Loading/sceneLoaderFlags";
  48182. }
  48183. declare module "babylonjs/Materials/Background/index" {
  48184. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48185. }
  48186. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48187. import { Scene } from "babylonjs/scene";
  48188. import { Color3 } from "babylonjs/Maths/math";
  48189. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48190. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48191. /**
  48192. * The Physically based simple base material of BJS.
  48193. *
  48194. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48195. * It is used as the base class for both the specGloss and metalRough conventions.
  48196. */
  48197. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48198. /**
  48199. * Number of Simultaneous lights allowed on the material.
  48200. */
  48201. maxSimultaneousLights: number;
  48202. /**
  48203. * If sets to true, disables all the lights affecting the material.
  48204. */
  48205. disableLighting: boolean;
  48206. /**
  48207. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48208. */
  48209. environmentTexture: BaseTexture;
  48210. /**
  48211. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48212. */
  48213. invertNormalMapX: boolean;
  48214. /**
  48215. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48216. */
  48217. invertNormalMapY: boolean;
  48218. /**
  48219. * Normal map used in the model.
  48220. */
  48221. normalTexture: BaseTexture;
  48222. /**
  48223. * Emissivie color used to self-illuminate the model.
  48224. */
  48225. emissiveColor: Color3;
  48226. /**
  48227. * Emissivie texture used to self-illuminate the model.
  48228. */
  48229. emissiveTexture: BaseTexture;
  48230. /**
  48231. * Occlusion Channel Strenght.
  48232. */
  48233. occlusionStrength: number;
  48234. /**
  48235. * Occlusion Texture of the material (adding extra occlusion effects).
  48236. */
  48237. occlusionTexture: BaseTexture;
  48238. /**
  48239. * Defines the alpha limits in alpha test mode.
  48240. */
  48241. alphaCutOff: number;
  48242. /**
  48243. * Gets the current double sided mode.
  48244. */
  48245. /**
  48246. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48247. */
  48248. doubleSided: boolean;
  48249. /**
  48250. * Stores the pre-calculated light information of a mesh in a texture.
  48251. */
  48252. lightmapTexture: BaseTexture;
  48253. /**
  48254. * If true, the light map contains occlusion information instead of lighting info.
  48255. */
  48256. useLightmapAsShadowmap: boolean;
  48257. /**
  48258. * Instantiates a new PBRMaterial instance.
  48259. *
  48260. * @param name The material name
  48261. * @param scene The scene the material will be use in.
  48262. */
  48263. constructor(name: string, scene: Scene);
  48264. getClassName(): string;
  48265. }
  48266. }
  48267. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  48268. import { Scene } from "babylonjs/scene";
  48269. import { Color3 } from "babylonjs/Maths/math";
  48270. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48271. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48272. /**
  48273. * The PBR material of BJS following the metal roughness convention.
  48274. *
  48275. * This fits to the PBR convention in the GLTF definition:
  48276. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48277. */
  48278. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48279. /**
  48280. * The base color has two different interpretations depending on the value of metalness.
  48281. * When the material is a metal, the base color is the specific measured reflectance value
  48282. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48283. * of the material.
  48284. */
  48285. baseColor: Color3;
  48286. /**
  48287. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48288. * well as opacity information in the alpha channel.
  48289. */
  48290. baseTexture: BaseTexture;
  48291. /**
  48292. * Specifies the metallic scalar value of the material.
  48293. * Can also be used to scale the metalness values of the metallic texture.
  48294. */
  48295. metallic: number;
  48296. /**
  48297. * Specifies the roughness scalar value of the material.
  48298. * Can also be used to scale the roughness values of the metallic texture.
  48299. */
  48300. roughness: number;
  48301. /**
  48302. * Texture containing both the metallic value in the B channel and the
  48303. * roughness value in the G channel to keep better precision.
  48304. */
  48305. metallicRoughnessTexture: BaseTexture;
  48306. /**
  48307. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48308. *
  48309. * @param name The material name
  48310. * @param scene The scene the material will be use in.
  48311. */
  48312. constructor(name: string, scene: Scene);
  48313. /**
  48314. * Return the currrent class name of the material.
  48315. */
  48316. getClassName(): string;
  48317. /**
  48318. * Makes a duplicate of the current material.
  48319. * @param name - name to use for the new material.
  48320. */
  48321. clone(name: string): PBRMetallicRoughnessMaterial;
  48322. /**
  48323. * Serialize the material to a parsable JSON object.
  48324. */
  48325. serialize(): any;
  48326. /**
  48327. * Parses a JSON object correponding to the serialize function.
  48328. */
  48329. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48330. }
  48331. }
  48332. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  48333. import { Scene } from "babylonjs/scene";
  48334. import { Color3 } from "babylonjs/Maths/math";
  48335. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48336. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48337. /**
  48338. * The PBR material of BJS following the specular glossiness convention.
  48339. *
  48340. * This fits to the PBR convention in the GLTF definition:
  48341. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48342. */
  48343. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48344. /**
  48345. * Specifies the diffuse color of the material.
  48346. */
  48347. diffuseColor: Color3;
  48348. /**
  48349. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48350. * channel.
  48351. */
  48352. diffuseTexture: BaseTexture;
  48353. /**
  48354. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48355. */
  48356. specularColor: Color3;
  48357. /**
  48358. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48359. */
  48360. glossiness: number;
  48361. /**
  48362. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48363. */
  48364. specularGlossinessTexture: BaseTexture;
  48365. /**
  48366. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48367. *
  48368. * @param name The material name
  48369. * @param scene The scene the material will be use in.
  48370. */
  48371. constructor(name: string, scene: Scene);
  48372. /**
  48373. * Return the currrent class name of the material.
  48374. */
  48375. getClassName(): string;
  48376. /**
  48377. * Makes a duplicate of the current material.
  48378. * @param name - name to use for the new material.
  48379. */
  48380. clone(name: string): PBRSpecularGlossinessMaterial;
  48381. /**
  48382. * Serialize the material to a parsable JSON object.
  48383. */
  48384. serialize(): any;
  48385. /**
  48386. * Parses a JSON object correponding to the serialize function.
  48387. */
  48388. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48389. }
  48390. }
  48391. declare module "babylonjs/Materials/PBR/index" {
  48392. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48393. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48394. export * from "babylonjs/Materials/PBR/pbrMaterial";
  48395. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  48396. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  48397. }
  48398. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  48399. import { Nullable } from "babylonjs/types";
  48400. import { Scene } from "babylonjs/scene";
  48401. import { Matrix } from "babylonjs/Maths/math";
  48402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48403. /**
  48404. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48405. * It can help converting any input color in a desired output one. This can then be used to create effects
  48406. * from sepia, black and white to sixties or futuristic rendering...
  48407. *
  48408. * The only supported format is currently 3dl.
  48409. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48410. */
  48411. export class ColorGradingTexture extends BaseTexture {
  48412. /**
  48413. * The current texture matrix. (will always be identity in color grading texture)
  48414. */
  48415. private _textureMatrix;
  48416. /**
  48417. * The texture URL.
  48418. */
  48419. url: string;
  48420. /**
  48421. * Empty line regex stored for GC.
  48422. */
  48423. private static _noneEmptyLineRegex;
  48424. private _engine;
  48425. /**
  48426. * Instantiates a ColorGradingTexture from the following parameters.
  48427. *
  48428. * @param url The location of the color gradind data (currently only supporting 3dl)
  48429. * @param scene The scene the texture will be used in
  48430. */
  48431. constructor(url: string, scene: Scene);
  48432. /**
  48433. * Returns the texture matrix used in most of the material.
  48434. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48435. */
  48436. getTextureMatrix(): Matrix;
  48437. /**
  48438. * Occurs when the file being loaded is a .3dl LUT file.
  48439. */
  48440. private load3dlTexture;
  48441. /**
  48442. * Starts the loading process of the texture.
  48443. */
  48444. private loadTexture;
  48445. /**
  48446. * Clones the color gradind texture.
  48447. */
  48448. clone(): ColorGradingTexture;
  48449. /**
  48450. * Called during delayed load for textures.
  48451. */
  48452. delayLoad(): void;
  48453. /**
  48454. * Parses a color grading texture serialized by Babylon.
  48455. * @param parsedTexture The texture information being parsedTexture
  48456. * @param scene The scene to load the texture in
  48457. * @param rootUrl The root url of the data assets to load
  48458. * @return A color gradind texture
  48459. */
  48460. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48461. /**
  48462. * Serializes the LUT texture to json format.
  48463. */
  48464. serialize(): any;
  48465. }
  48466. }
  48467. declare module "babylonjs/Misc/dds" {
  48468. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48469. import { Engine } from "babylonjs/Engines/engine";
  48470. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48471. import { Nullable } from "babylonjs/types";
  48472. import { Scene } from "babylonjs/scene";
  48473. /**
  48474. * Direct draw surface info
  48475. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48476. */
  48477. export interface DDSInfo {
  48478. /**
  48479. * Width of the texture
  48480. */
  48481. width: number;
  48482. /**
  48483. * Width of the texture
  48484. */
  48485. height: number;
  48486. /**
  48487. * Number of Mipmaps for the texture
  48488. * @see https://en.wikipedia.org/wiki/Mipmap
  48489. */
  48490. mipmapCount: number;
  48491. /**
  48492. * If the textures format is a known fourCC format
  48493. * @see https://www.fourcc.org/
  48494. */
  48495. isFourCC: boolean;
  48496. /**
  48497. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48498. */
  48499. isRGB: boolean;
  48500. /**
  48501. * If the texture is a lumincance format
  48502. */
  48503. isLuminance: boolean;
  48504. /**
  48505. * If this is a cube texture
  48506. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48507. */
  48508. isCube: boolean;
  48509. /**
  48510. * If the texture is a compressed format eg. FOURCC_DXT1
  48511. */
  48512. isCompressed: boolean;
  48513. /**
  48514. * The dxgiFormat of the texture
  48515. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48516. */
  48517. dxgiFormat: number;
  48518. /**
  48519. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48520. */
  48521. textureType: number;
  48522. /**
  48523. * Sphericle polynomial created for the dds texture
  48524. */
  48525. sphericalPolynomial?: SphericalPolynomial;
  48526. }
  48527. /**
  48528. * Class used to provide DDS decompression tools
  48529. */
  48530. export class DDSTools {
  48531. /**
  48532. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48533. */
  48534. static StoreLODInAlphaChannel: boolean;
  48535. /**
  48536. * Gets DDS information from an array buffer
  48537. * @param arrayBuffer defines the array buffer to read data from
  48538. * @returns the DDS information
  48539. */
  48540. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48541. private static _FloatView;
  48542. private static _Int32View;
  48543. private static _ToHalfFloat;
  48544. private static _FromHalfFloat;
  48545. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48546. private static _GetHalfFloatRGBAArrayBuffer;
  48547. private static _GetFloatRGBAArrayBuffer;
  48548. private static _GetFloatAsUIntRGBAArrayBuffer;
  48549. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48550. private static _GetRGBAArrayBuffer;
  48551. private static _ExtractLongWordOrder;
  48552. private static _GetRGBArrayBuffer;
  48553. private static _GetLuminanceArrayBuffer;
  48554. /**
  48555. * Uploads DDS Levels to a Babylon Texture
  48556. * @hidden
  48557. */
  48558. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48559. }
  48560. module "babylonjs/Engines/engine" {
  48561. interface Engine {
  48562. /**
  48563. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48564. * @param rootUrl defines the url where the file to load is located
  48565. * @param scene defines the current scene
  48566. * @param lodScale defines scale to apply to the mip map selection
  48567. * @param lodOffset defines offset to apply to the mip map selection
  48568. * @param onLoad defines an optional callback raised when the texture is loaded
  48569. * @param onError defines an optional callback raised if there is an issue to load the texture
  48570. * @param format defines the format of the data
  48571. * @param forcedExtension defines the extension to use to pick the right loader
  48572. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48573. * @returns the cube texture as an InternalTexture
  48574. */
  48575. 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;
  48576. }
  48577. }
  48578. }
  48579. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48580. import { Nullable } from "babylonjs/types";
  48581. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48582. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48583. /**
  48584. * Implementation of the DDS Texture Loader.
  48585. * @hidden
  48586. */
  48587. export class _DDSTextureLoader implements IInternalTextureLoader {
  48588. /**
  48589. * Defines wether the loader supports cascade loading the different faces.
  48590. */
  48591. readonly supportCascades: boolean;
  48592. /**
  48593. * This returns if the loader support the current file information.
  48594. * @param extension defines the file extension of the file being loaded
  48595. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48596. * @param fallback defines the fallback internal texture if any
  48597. * @param isBase64 defines whether the texture is encoded as a base64
  48598. * @param isBuffer defines whether the texture data are stored as a buffer
  48599. * @returns true if the loader can load the specified file
  48600. */
  48601. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48602. /**
  48603. * Transform the url before loading if required.
  48604. * @param rootUrl the url of the texture
  48605. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48606. * @returns the transformed texture
  48607. */
  48608. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48609. /**
  48610. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48611. * @param rootUrl the url of the texture
  48612. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48613. * @returns the fallback texture
  48614. */
  48615. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48616. /**
  48617. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48618. * @param data contains the texture data
  48619. * @param texture defines the BabylonJS internal texture
  48620. * @param createPolynomials will be true if polynomials have been requested
  48621. * @param onLoad defines the callback to trigger once the texture is ready
  48622. * @param onError defines the callback to trigger in case of error
  48623. */
  48624. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48625. /**
  48626. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48627. * @param data contains the texture data
  48628. * @param texture defines the BabylonJS internal texture
  48629. * @param callback defines the method to call once ready to upload
  48630. */
  48631. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48632. }
  48633. }
  48634. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48635. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48636. /** @hidden */
  48637. export var rgbdEncodePixelShader: {
  48638. name: string;
  48639. shader: string;
  48640. };
  48641. }
  48642. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48643. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48644. /** @hidden */
  48645. export var rgbdDecodePixelShader: {
  48646. name: string;
  48647. shader: string;
  48648. };
  48649. }
  48650. declare module "babylonjs/Misc/environmentTextureTools" {
  48651. import { Nullable } from "babylonjs/types";
  48652. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48653. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48654. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48655. import "babylonjs/Shaders/rgbdEncode.fragment";
  48656. import "babylonjs/Shaders/rgbdDecode.fragment";
  48657. /**
  48658. * Raw texture data and descriptor sufficient for WebGL texture upload
  48659. */
  48660. export interface EnvironmentTextureInfo {
  48661. /**
  48662. * Version of the environment map
  48663. */
  48664. version: number;
  48665. /**
  48666. * Width of image
  48667. */
  48668. width: number;
  48669. /**
  48670. * Irradiance information stored in the file.
  48671. */
  48672. irradiance: any;
  48673. /**
  48674. * Specular information stored in the file.
  48675. */
  48676. specular: any;
  48677. }
  48678. /**
  48679. * Sets of helpers addressing the serialization and deserialization of environment texture
  48680. * stored in a BabylonJS env file.
  48681. * Those files are usually stored as .env files.
  48682. */
  48683. export class EnvironmentTextureTools {
  48684. /**
  48685. * Magic number identifying the env file.
  48686. */
  48687. private static _MagicBytes;
  48688. /**
  48689. * Gets the environment info from an env file.
  48690. * @param data The array buffer containing the .env bytes.
  48691. * @returns the environment file info (the json header) if successfully parsed.
  48692. */
  48693. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48694. /**
  48695. * Creates an environment texture from a loaded cube texture.
  48696. * @param texture defines the cube texture to convert in env file
  48697. * @return a promise containing the environment data if succesfull.
  48698. */
  48699. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48700. /**
  48701. * Creates a JSON representation of the spherical data.
  48702. * @param texture defines the texture containing the polynomials
  48703. * @return the JSON representation of the spherical info
  48704. */
  48705. private static _CreateEnvTextureIrradiance;
  48706. /**
  48707. * Uploads the texture info contained in the env file to the GPU.
  48708. * @param texture defines the internal texture to upload to
  48709. * @param arrayBuffer defines the buffer cotaining the data to load
  48710. * @param info defines the texture info retrieved through the GetEnvInfo method
  48711. * @returns a promise
  48712. */
  48713. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48714. /**
  48715. * Uploads the levels of image data to the GPU.
  48716. * @param texture defines the internal texture to upload to
  48717. * @param imageData defines the array buffer views of image data [mipmap][face]
  48718. * @returns a promise
  48719. */
  48720. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48721. /**
  48722. * Uploads spherical polynomials information to the texture.
  48723. * @param texture defines the texture we are trying to upload the information to
  48724. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48725. */
  48726. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48727. /** @hidden */
  48728. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48729. }
  48730. }
  48731. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48732. import { Nullable } from "babylonjs/types";
  48733. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48734. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48735. /**
  48736. * Implementation of the ENV Texture Loader.
  48737. * @hidden
  48738. */
  48739. export class _ENVTextureLoader implements IInternalTextureLoader {
  48740. /**
  48741. * Defines wether the loader supports cascade loading the different faces.
  48742. */
  48743. readonly supportCascades: boolean;
  48744. /**
  48745. * This returns if the loader support the current file information.
  48746. * @param extension defines the file extension of the file being loaded
  48747. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48748. * @param fallback defines the fallback internal texture if any
  48749. * @param isBase64 defines whether the texture is encoded as a base64
  48750. * @param isBuffer defines whether the texture data are stored as a buffer
  48751. * @returns true if the loader can load the specified file
  48752. */
  48753. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48754. /**
  48755. * Transform the url before loading if required.
  48756. * @param rootUrl the url of the texture
  48757. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48758. * @returns the transformed texture
  48759. */
  48760. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48761. /**
  48762. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48763. * @param rootUrl the url of the texture
  48764. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48765. * @returns the fallback texture
  48766. */
  48767. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48768. /**
  48769. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48770. * @param data contains the texture data
  48771. * @param texture defines the BabylonJS internal texture
  48772. * @param createPolynomials will be true if polynomials have been requested
  48773. * @param onLoad defines the callback to trigger once the texture is ready
  48774. * @param onError defines the callback to trigger in case of error
  48775. */
  48776. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48777. /**
  48778. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48779. * @param data contains the texture data
  48780. * @param texture defines the BabylonJS internal texture
  48781. * @param callback defines the method to call once ready to upload
  48782. */
  48783. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48784. }
  48785. }
  48786. declare module "babylonjs/Misc/khronosTextureContainer" {
  48787. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48788. /**
  48789. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48790. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48791. */
  48792. export class KhronosTextureContainer {
  48793. /** contents of the KTX container file */
  48794. arrayBuffer: any;
  48795. private static HEADER_LEN;
  48796. private static COMPRESSED_2D;
  48797. private static COMPRESSED_3D;
  48798. private static TEX_2D;
  48799. private static TEX_3D;
  48800. /**
  48801. * Gets the openGL type
  48802. */
  48803. glType: number;
  48804. /**
  48805. * Gets the openGL type size
  48806. */
  48807. glTypeSize: number;
  48808. /**
  48809. * Gets the openGL format
  48810. */
  48811. glFormat: number;
  48812. /**
  48813. * Gets the openGL internal format
  48814. */
  48815. glInternalFormat: number;
  48816. /**
  48817. * Gets the base internal format
  48818. */
  48819. glBaseInternalFormat: number;
  48820. /**
  48821. * Gets image width in pixel
  48822. */
  48823. pixelWidth: number;
  48824. /**
  48825. * Gets image height in pixel
  48826. */
  48827. pixelHeight: number;
  48828. /**
  48829. * Gets image depth in pixels
  48830. */
  48831. pixelDepth: number;
  48832. /**
  48833. * Gets the number of array elements
  48834. */
  48835. numberOfArrayElements: number;
  48836. /**
  48837. * Gets the number of faces
  48838. */
  48839. numberOfFaces: number;
  48840. /**
  48841. * Gets the number of mipmap levels
  48842. */
  48843. numberOfMipmapLevels: number;
  48844. /**
  48845. * Gets the bytes of key value data
  48846. */
  48847. bytesOfKeyValueData: number;
  48848. /**
  48849. * Gets the load type
  48850. */
  48851. loadType: number;
  48852. /**
  48853. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48854. */
  48855. isInvalid: boolean;
  48856. /**
  48857. * Creates a new KhronosTextureContainer
  48858. * @param arrayBuffer contents of the KTX container file
  48859. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48860. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48861. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48862. */
  48863. constructor(
  48864. /** contents of the KTX container file */
  48865. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48866. /**
  48867. * Uploads KTX content to a Babylon Texture.
  48868. * It is assumed that the texture has already been created & is currently bound
  48869. * @hidden
  48870. */
  48871. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48872. private _upload2DCompressedLevels;
  48873. }
  48874. }
  48875. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48876. import { Nullable } from "babylonjs/types";
  48877. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48878. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48879. /**
  48880. * Implementation of the KTX Texture Loader.
  48881. * @hidden
  48882. */
  48883. export class _KTXTextureLoader implements IInternalTextureLoader {
  48884. /**
  48885. * Defines wether the loader supports cascade loading the different faces.
  48886. */
  48887. readonly supportCascades: boolean;
  48888. /**
  48889. * This returns if the loader support the current file information.
  48890. * @param extension defines the file extension of the file being loaded
  48891. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48892. * @param fallback defines the fallback internal texture if any
  48893. * @param isBase64 defines whether the texture is encoded as a base64
  48894. * @param isBuffer defines whether the texture data are stored as a buffer
  48895. * @returns true if the loader can load the specified file
  48896. */
  48897. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48898. /**
  48899. * Transform the url before loading if required.
  48900. * @param rootUrl the url of the texture
  48901. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48902. * @returns the transformed texture
  48903. */
  48904. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48905. /**
  48906. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48907. * @param rootUrl the url of the texture
  48908. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48909. * @returns the fallback texture
  48910. */
  48911. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48912. /**
  48913. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48914. * @param data contains the texture data
  48915. * @param texture defines the BabylonJS internal texture
  48916. * @param createPolynomials will be true if polynomials have been requested
  48917. * @param onLoad defines the callback to trigger once the texture is ready
  48918. * @param onError defines the callback to trigger in case of error
  48919. */
  48920. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48921. /**
  48922. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48923. * @param data contains the texture data
  48924. * @param texture defines the BabylonJS internal texture
  48925. * @param callback defines the method to call once ready to upload
  48926. */
  48927. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48928. }
  48929. }
  48930. declare module "babylonjs/Misc/tga" {
  48931. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48932. /**
  48933. * Based on jsTGALoader - Javascript loader for TGA file
  48934. * By Vincent Thibault
  48935. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48936. */
  48937. export class TGATools {
  48938. private static _TYPE_INDEXED;
  48939. private static _TYPE_RGB;
  48940. private static _TYPE_GREY;
  48941. private static _TYPE_RLE_INDEXED;
  48942. private static _TYPE_RLE_RGB;
  48943. private static _TYPE_RLE_GREY;
  48944. private static _ORIGIN_MASK;
  48945. private static _ORIGIN_SHIFT;
  48946. private static _ORIGIN_BL;
  48947. private static _ORIGIN_BR;
  48948. private static _ORIGIN_UL;
  48949. private static _ORIGIN_UR;
  48950. /**
  48951. * Gets the header of a TGA file
  48952. * @param data defines the TGA data
  48953. * @returns the header
  48954. */
  48955. static GetTGAHeader(data: Uint8Array): any;
  48956. /**
  48957. * Uploads TGA content to a Babylon Texture
  48958. * @hidden
  48959. */
  48960. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48961. /** @hidden */
  48962. 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;
  48963. /** @hidden */
  48964. 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;
  48965. /** @hidden */
  48966. 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;
  48967. /** @hidden */
  48968. 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;
  48969. /** @hidden */
  48970. 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;
  48971. /** @hidden */
  48972. 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;
  48973. }
  48974. }
  48975. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48976. import { Nullable } from "babylonjs/types";
  48977. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48978. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48979. /**
  48980. * Implementation of the TGA Texture Loader.
  48981. * @hidden
  48982. */
  48983. export class _TGATextureLoader implements IInternalTextureLoader {
  48984. /**
  48985. * Defines wether the loader supports cascade loading the different faces.
  48986. */
  48987. readonly supportCascades: boolean;
  48988. /**
  48989. * This returns if the loader support the current file information.
  48990. * @param extension defines the file extension of the file being loaded
  48991. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48992. * @param fallback defines the fallback internal texture if any
  48993. * @param isBase64 defines whether the texture is encoded as a base64
  48994. * @param isBuffer defines whether the texture data are stored as a buffer
  48995. * @returns true if the loader can load the specified file
  48996. */
  48997. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48998. /**
  48999. * Transform the url before loading if required.
  49000. * @param rootUrl the url of the texture
  49001. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49002. * @returns the transformed texture
  49003. */
  49004. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49005. /**
  49006. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49007. * @param rootUrl the url of the texture
  49008. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49009. * @returns the fallback texture
  49010. */
  49011. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49012. /**
  49013. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49014. * @param data contains the texture data
  49015. * @param texture defines the BabylonJS internal texture
  49016. * @param createPolynomials will be true if polynomials have been requested
  49017. * @param onLoad defines the callback to trigger once the texture is ready
  49018. * @param onError defines the callback to trigger in case of error
  49019. */
  49020. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49021. /**
  49022. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49023. * @param data contains the texture data
  49024. * @param texture defines the BabylonJS internal texture
  49025. * @param callback defines the method to call once ready to upload
  49026. */
  49027. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49028. }
  49029. }
  49030. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49031. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49032. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49033. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49034. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49035. }
  49036. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49037. import { Scene } from "babylonjs/scene";
  49038. import { Texture } from "babylonjs/Materials/Textures/texture";
  49039. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49040. /**
  49041. * 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.
  49042. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49043. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49044. */
  49045. export class CustomProceduralTexture extends ProceduralTexture {
  49046. private _animate;
  49047. private _time;
  49048. private _config;
  49049. private _texturePath;
  49050. /**
  49051. * Instantiates a new Custom Procedural Texture.
  49052. * 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.
  49053. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49054. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49055. * @param name Define the name of the texture
  49056. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49057. * @param size Define the size of the texture to create
  49058. * @param scene Define the scene the texture belongs to
  49059. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49060. * @param generateMipMaps Define if the texture should creates mip maps or not
  49061. */
  49062. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49063. private _loadJson;
  49064. /**
  49065. * Is the texture ready to be used ? (rendered at least once)
  49066. * @returns true if ready, otherwise, false.
  49067. */
  49068. isReady(): boolean;
  49069. /**
  49070. * Render the texture to its associated render target.
  49071. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49072. */
  49073. render(useCameraPostProcess?: boolean): void;
  49074. /**
  49075. * Update the list of dependant textures samplers in the shader.
  49076. */
  49077. updateTextures(): void;
  49078. /**
  49079. * Update the uniform values of the procedural texture in the shader.
  49080. */
  49081. updateShaderUniforms(): void;
  49082. /**
  49083. * Define if the texture animates or not.
  49084. */
  49085. animate: boolean;
  49086. }
  49087. }
  49088. declare module "babylonjs/Shaders/noise.fragment" {
  49089. /** @hidden */
  49090. export var noisePixelShader: {
  49091. name: string;
  49092. shader: string;
  49093. };
  49094. }
  49095. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49096. import { Nullable } from "babylonjs/types";
  49097. import { Scene } from "babylonjs/scene";
  49098. import { Texture } from "babylonjs/Materials/Textures/texture";
  49099. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49100. import "babylonjs/Shaders/noise.fragment";
  49101. /**
  49102. * Class used to generate noise procedural textures
  49103. */
  49104. export class NoiseProceduralTexture extends ProceduralTexture {
  49105. private _time;
  49106. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49107. brightness: number;
  49108. /** Defines the number of octaves to process */
  49109. octaves: number;
  49110. /** Defines the level of persistence (0.8 by default) */
  49111. persistence: number;
  49112. /** Gets or sets animation speed factor (default is 1) */
  49113. animationSpeedFactor: number;
  49114. /**
  49115. * Creates a new NoiseProceduralTexture
  49116. * @param name defines the name fo the texture
  49117. * @param size defines the size of the texture (default is 256)
  49118. * @param scene defines the hosting scene
  49119. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49120. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49121. */
  49122. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49123. private _updateShaderUniforms;
  49124. protected _getDefines(): string;
  49125. /** Generate the current state of the procedural texture */
  49126. render(useCameraPostProcess?: boolean): void;
  49127. /**
  49128. * Serializes this noise procedural texture
  49129. * @returns a serialized noise procedural texture object
  49130. */
  49131. serialize(): any;
  49132. /**
  49133. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49134. * @param parsedTexture defines parsed texture data
  49135. * @param scene defines the current scene
  49136. * @param rootUrl defines the root URL containing noise procedural texture information
  49137. * @returns a parsed NoiseProceduralTexture
  49138. */
  49139. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49140. }
  49141. }
  49142. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49143. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49144. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49145. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49146. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49147. }
  49148. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49149. import { Nullable } from "babylonjs/types";
  49150. import { Scene } from "babylonjs/scene";
  49151. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49152. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49153. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49154. /**
  49155. * Raw cube texture where the raw buffers are passed in
  49156. */
  49157. export class RawCubeTexture extends CubeTexture {
  49158. /**
  49159. * Creates a cube texture where the raw buffers are passed in.
  49160. * @param scene defines the scene the texture is attached to
  49161. * @param data defines the array of data to use to create each face
  49162. * @param size defines the size of the textures
  49163. * @param format defines the format of the data
  49164. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49165. * @param generateMipMaps defines if the engine should generate the mip levels
  49166. * @param invertY defines if data must be stored with Y axis inverted
  49167. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49168. * @param compression defines the compression used (null by default)
  49169. */
  49170. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49171. /**
  49172. * Updates the raw cube texture.
  49173. * @param data defines the data to store
  49174. * @param format defines the data format
  49175. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49176. * @param invertY defines if data must be stored with Y axis inverted
  49177. * @param compression defines the compression used (null by default)
  49178. * @param level defines which level of the texture to update
  49179. */
  49180. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49181. /**
  49182. * Updates a raw cube texture with RGBD encoded data.
  49183. * @param data defines the array of data [mipmap][face] to use to create each face
  49184. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49185. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49186. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49187. * @returns a promsie that resolves when the operation is complete
  49188. */
  49189. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49190. /**
  49191. * Clones the raw cube texture.
  49192. * @return a new cube texture
  49193. */
  49194. clone(): CubeTexture;
  49195. /** @hidden */
  49196. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49197. }
  49198. }
  49199. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49200. import { Scene } from "babylonjs/scene";
  49201. import { Texture } from "babylonjs/Materials/Textures/texture";
  49202. /**
  49203. * Class used to store 3D textures containing user data
  49204. */
  49205. export class RawTexture3D extends Texture {
  49206. /** Gets or sets the texture format to use */
  49207. format: number;
  49208. private _engine;
  49209. /**
  49210. * Create a new RawTexture3D
  49211. * @param data defines the data of the texture
  49212. * @param width defines the width of the texture
  49213. * @param height defines the height of the texture
  49214. * @param depth defines the depth of the texture
  49215. * @param format defines the texture format to use
  49216. * @param scene defines the hosting scene
  49217. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49218. * @param invertY defines if texture must be stored with Y axis inverted
  49219. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49220. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49221. */
  49222. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49223. /** Gets or sets the texture format to use */
  49224. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49225. /**
  49226. * Update the texture with new data
  49227. * @param data defines the data to store in the texture
  49228. */
  49229. update(data: ArrayBufferView): void;
  49230. }
  49231. }
  49232. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49233. import { Scene } from "babylonjs/scene";
  49234. import { Plane } from "babylonjs/Maths/math";
  49235. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49236. /**
  49237. * Creates a refraction texture used by refraction channel of the standard material.
  49238. * It is like a mirror but to see through a material.
  49239. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49240. */
  49241. export class RefractionTexture extends RenderTargetTexture {
  49242. /**
  49243. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49244. * 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.
  49245. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49246. */
  49247. refractionPlane: Plane;
  49248. /**
  49249. * Define how deep under the surface we should see.
  49250. */
  49251. depth: number;
  49252. /**
  49253. * Creates a refraction texture used by refraction channel of the standard material.
  49254. * It is like a mirror but to see through a material.
  49255. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49256. * @param name Define the texture name
  49257. * @param size Define the size of the underlying texture
  49258. * @param scene Define the scene the refraction belongs to
  49259. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49260. */
  49261. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49262. /**
  49263. * Clone the refraction texture.
  49264. * @returns the cloned texture
  49265. */
  49266. clone(): RefractionTexture;
  49267. /**
  49268. * Serialize the texture to a JSON representation you could use in Parse later on
  49269. * @returns the serialized JSON representation
  49270. */
  49271. serialize(): any;
  49272. }
  49273. }
  49274. declare module "babylonjs/Materials/Textures/index" {
  49275. export * from "babylonjs/Materials/Textures/baseTexture";
  49276. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49277. export * from "babylonjs/Materials/Textures/cubeTexture";
  49278. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49279. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49280. export * from "babylonjs/Materials/Textures/internalTexture";
  49281. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49282. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49283. export * from "babylonjs/Materials/Textures/Loaders/index";
  49284. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49285. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49286. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49287. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49288. export * from "babylonjs/Materials/Textures/rawTexture";
  49289. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49290. export * from "babylonjs/Materials/Textures/refractionTexture";
  49291. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49292. export * from "babylonjs/Materials/Textures/texture";
  49293. export * from "babylonjs/Materials/Textures/videoTexture";
  49294. }
  49295. declare module "babylonjs/Materials/index" {
  49296. export * from "babylonjs/Materials/Background/index";
  49297. export * from "babylonjs/Materials/colorCurves";
  49298. export * from "babylonjs/Materials/effect";
  49299. export * from "babylonjs/Materials/fresnelParameters";
  49300. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49301. export * from "babylonjs/Materials/material";
  49302. export * from "babylonjs/Materials/materialDefines";
  49303. export * from "babylonjs/Materials/materialHelper";
  49304. export * from "babylonjs/Materials/multiMaterial";
  49305. export * from "babylonjs/Materials/PBR/index";
  49306. export * from "babylonjs/Materials/pushMaterial";
  49307. export * from "babylonjs/Materials/shaderMaterial";
  49308. export * from "babylonjs/Materials/standardMaterial";
  49309. export * from "babylonjs/Materials/Textures/index";
  49310. export * from "babylonjs/Materials/uniformBuffer";
  49311. export * from "babylonjs/Materials/materialFlags";
  49312. }
  49313. declare module "babylonjs/Maths/index" {
  49314. export * from "babylonjs/Maths/math.scalar";
  49315. export * from "babylonjs/Maths/math";
  49316. export * from "babylonjs/Maths/sphericalPolynomial";
  49317. }
  49318. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49319. import { IDisposable } from "babylonjs/scene";
  49320. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49321. /**
  49322. * Configuration for Draco compression
  49323. */
  49324. export interface IDracoCompressionConfiguration {
  49325. /**
  49326. * Configuration for the decoder.
  49327. */
  49328. decoder?: {
  49329. /**
  49330. * The url to the WebAssembly module.
  49331. */
  49332. wasmUrl?: string;
  49333. /**
  49334. * The url to the WebAssembly binary.
  49335. */
  49336. wasmBinaryUrl?: string;
  49337. /**
  49338. * The url to the fallback JavaScript module.
  49339. */
  49340. fallbackUrl?: string;
  49341. };
  49342. }
  49343. /**
  49344. * Draco compression (https://google.github.io/draco/)
  49345. *
  49346. * This class wraps the Draco module.
  49347. *
  49348. * **Encoder**
  49349. *
  49350. * The encoder is not currently implemented.
  49351. *
  49352. * **Decoder**
  49353. *
  49354. * 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.
  49355. *
  49356. * To update the configuration, use the following code:
  49357. * ```javascript
  49358. * DracoCompression.Configuration = {
  49359. * decoder: {
  49360. * wasmUrl: "<url to the WebAssembly library>",
  49361. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49362. * fallbackUrl: "<url to the fallback JavaScript library>",
  49363. * }
  49364. * };
  49365. * ```
  49366. *
  49367. * 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.
  49368. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49369. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49370. *
  49371. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49372. * ```javascript
  49373. * var dracoCompression = new DracoCompression();
  49374. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49375. * [VertexBuffer.PositionKind]: 0
  49376. * });
  49377. * ```
  49378. *
  49379. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49380. */
  49381. export class DracoCompression implements IDisposable {
  49382. private static _DecoderModulePromise;
  49383. /**
  49384. * The configuration. Defaults to the following urls:
  49385. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49386. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49387. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49388. */
  49389. static Configuration: IDracoCompressionConfiguration;
  49390. /**
  49391. * Returns true if the decoder is available.
  49392. */
  49393. static readonly DecoderAvailable: boolean;
  49394. /**
  49395. * Constructor
  49396. */
  49397. constructor();
  49398. /**
  49399. * Stop all async operations and release resources.
  49400. */
  49401. dispose(): void;
  49402. /**
  49403. * Decode Draco compressed mesh data to vertex data.
  49404. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49405. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49406. * @returns A promise that resolves with the decoded vertex data
  49407. */
  49408. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49409. [kind: string]: number;
  49410. }): Promise<VertexData>;
  49411. private static _GetDecoderModule;
  49412. private static _LoadScriptAsync;
  49413. private static _LoadFileAsync;
  49414. }
  49415. }
  49416. declare module "babylonjs/Meshes/Compression/index" {
  49417. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49418. }
  49419. declare module "babylonjs/Meshes/csg" {
  49420. import { Nullable } from "babylonjs/types";
  49421. import { Scene } from "babylonjs/scene";
  49422. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49423. import { Mesh } from "babylonjs/Meshes/mesh";
  49424. import { Material } from "babylonjs/Materials/material";
  49425. /**
  49426. * Class for building Constructive Solid Geometry
  49427. */
  49428. export class CSG {
  49429. private polygons;
  49430. /**
  49431. * The world matrix
  49432. */
  49433. matrix: Matrix;
  49434. /**
  49435. * Stores the position
  49436. */
  49437. position: Vector3;
  49438. /**
  49439. * Stores the rotation
  49440. */
  49441. rotation: Vector3;
  49442. /**
  49443. * Stores the rotation quaternion
  49444. */
  49445. rotationQuaternion: Nullable<Quaternion>;
  49446. /**
  49447. * Stores the scaling vector
  49448. */
  49449. scaling: Vector3;
  49450. /**
  49451. * Convert the Mesh to CSG
  49452. * @param mesh The Mesh to convert to CSG
  49453. * @returns A new CSG from the Mesh
  49454. */
  49455. static FromMesh(mesh: Mesh): CSG;
  49456. /**
  49457. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49458. * @param polygons Polygons used to construct a CSG solid
  49459. */
  49460. private static FromPolygons;
  49461. /**
  49462. * Clones, or makes a deep copy, of the CSG
  49463. * @returns A new CSG
  49464. */
  49465. clone(): CSG;
  49466. /**
  49467. * Unions this CSG with another CSG
  49468. * @param csg The CSG to union against this CSG
  49469. * @returns The unioned CSG
  49470. */
  49471. union(csg: CSG): CSG;
  49472. /**
  49473. * Unions this CSG with another CSG in place
  49474. * @param csg The CSG to union against this CSG
  49475. */
  49476. unionInPlace(csg: CSG): void;
  49477. /**
  49478. * Subtracts this CSG with another CSG
  49479. * @param csg The CSG to subtract against this CSG
  49480. * @returns A new CSG
  49481. */
  49482. subtract(csg: CSG): CSG;
  49483. /**
  49484. * Subtracts this CSG with another CSG in place
  49485. * @param csg The CSG to subtact against this CSG
  49486. */
  49487. subtractInPlace(csg: CSG): void;
  49488. /**
  49489. * Intersect this CSG with another CSG
  49490. * @param csg The CSG to intersect against this CSG
  49491. * @returns A new CSG
  49492. */
  49493. intersect(csg: CSG): CSG;
  49494. /**
  49495. * Intersects this CSG with another CSG in place
  49496. * @param csg The CSG to intersect against this CSG
  49497. */
  49498. intersectInPlace(csg: CSG): void;
  49499. /**
  49500. * Return a new CSG solid with solid and empty space switched. This solid is
  49501. * not modified.
  49502. * @returns A new CSG solid with solid and empty space switched
  49503. */
  49504. inverse(): CSG;
  49505. /**
  49506. * Inverses the CSG in place
  49507. */
  49508. inverseInPlace(): void;
  49509. /**
  49510. * This is used to keep meshes transformations so they can be restored
  49511. * when we build back a Babylon Mesh
  49512. * NB : All CSG operations are performed in world coordinates
  49513. * @param csg The CSG to copy the transform attributes from
  49514. * @returns This CSG
  49515. */
  49516. copyTransformAttributes(csg: CSG): CSG;
  49517. /**
  49518. * Build Raw mesh from CSG
  49519. * Coordinates here are in world space
  49520. * @param name The name of the mesh geometry
  49521. * @param scene The Scene
  49522. * @param keepSubMeshes Specifies if the submeshes should be kept
  49523. * @returns A new Mesh
  49524. */
  49525. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49526. /**
  49527. * Build Mesh from CSG taking material and transforms into account
  49528. * @param name The name of the Mesh
  49529. * @param material The material of the Mesh
  49530. * @param scene The Scene
  49531. * @param keepSubMeshes Specifies if submeshes should be kept
  49532. * @returns The new Mesh
  49533. */
  49534. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49535. }
  49536. }
  49537. declare module "babylonjs/Meshes/trailMesh" {
  49538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49539. import { Mesh } from "babylonjs/Meshes/mesh";
  49540. import { Scene } from "babylonjs/scene";
  49541. /**
  49542. * Class used to create a trail following a mesh
  49543. */
  49544. export class TrailMesh extends Mesh {
  49545. private _generator;
  49546. private _autoStart;
  49547. private _running;
  49548. private _diameter;
  49549. private _length;
  49550. private _sectionPolygonPointsCount;
  49551. private _sectionVectors;
  49552. private _sectionNormalVectors;
  49553. private _beforeRenderObserver;
  49554. /**
  49555. * @constructor
  49556. * @param name The value used by scene.getMeshByName() to do a lookup.
  49557. * @param generator The mesh to generate a trail.
  49558. * @param scene The scene to add this mesh to.
  49559. * @param diameter Diameter of trailing mesh. Default is 1.
  49560. * @param length Length of trailing mesh. Default is 60.
  49561. * @param autoStart Automatically start trailing mesh. Default true.
  49562. */
  49563. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49564. /**
  49565. * "TrailMesh"
  49566. * @returns "TrailMesh"
  49567. */
  49568. getClassName(): string;
  49569. private _createMesh;
  49570. /**
  49571. * Start trailing mesh.
  49572. */
  49573. start(): void;
  49574. /**
  49575. * Stop trailing mesh.
  49576. */
  49577. stop(): void;
  49578. /**
  49579. * Update trailing mesh geometry.
  49580. */
  49581. update(): void;
  49582. /**
  49583. * Returns a new TrailMesh object.
  49584. * @param name is a string, the name given to the new mesh
  49585. * @param newGenerator use new generator object for cloned trail mesh
  49586. * @returns a new mesh
  49587. */
  49588. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49589. /**
  49590. * Serializes this trail mesh
  49591. * @param serializationObject object to write serialization to
  49592. */
  49593. serialize(serializationObject: any): void;
  49594. /**
  49595. * Parses a serialized trail mesh
  49596. * @param parsedMesh the serialized mesh
  49597. * @param scene the scene to create the trail mesh in
  49598. * @returns the created trail mesh
  49599. */
  49600. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49601. }
  49602. }
  49603. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49604. import { Nullable } from "babylonjs/types";
  49605. import { Scene } from "babylonjs/scene";
  49606. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49607. import { Mesh } from "babylonjs/Meshes/mesh";
  49608. /**
  49609. * Class containing static functions to help procedurally build meshes
  49610. */
  49611. export class RibbonBuilder {
  49612. /**
  49613. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49614. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49615. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49616. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49617. * * 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
  49618. * * 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
  49619. * * 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
  49620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49621. * * If you create a double-sided mesh, you can choose what parts of 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
  49622. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49623. * * 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
  49624. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49625. * * 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
  49626. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49628. * @param name defines the name of the mesh
  49629. * @param options defines the options used to create the mesh
  49630. * @param scene defines the hosting scene
  49631. * @returns the ribbon mesh
  49632. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49633. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49634. */
  49635. static CreateRibbon(name: string, options: {
  49636. pathArray: Vector3[][];
  49637. closeArray?: boolean;
  49638. closePath?: boolean;
  49639. offset?: number;
  49640. updatable?: boolean;
  49641. sideOrientation?: number;
  49642. frontUVs?: Vector4;
  49643. backUVs?: Vector4;
  49644. instance?: Mesh;
  49645. invertUV?: boolean;
  49646. uvs?: Vector2[];
  49647. colors?: Color4[];
  49648. }, scene?: Nullable<Scene>): Mesh;
  49649. }
  49650. }
  49651. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49652. import { Vector4 } from "babylonjs/Maths/math";
  49653. import { Mesh } from "babylonjs/Meshes/mesh";
  49654. /**
  49655. * Class containing static functions to help procedurally build meshes
  49656. */
  49657. export class TorusKnotBuilder {
  49658. /**
  49659. * Creates a torus knot mesh
  49660. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49661. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49662. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49663. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49665. * * If you create a double-sided mesh, you can choose what parts of 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
  49666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49667. * @param name defines the name of the mesh
  49668. * @param options defines the options used to create the mesh
  49669. * @param scene defines the hosting scene
  49670. * @returns the torus knot mesh
  49671. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49672. */
  49673. static CreateTorusKnot(name: string, options: {
  49674. radius?: number;
  49675. tube?: number;
  49676. radialSegments?: number;
  49677. tubularSegments?: number;
  49678. p?: number;
  49679. q?: number;
  49680. updatable?: boolean;
  49681. sideOrientation?: number;
  49682. frontUVs?: Vector4;
  49683. backUVs?: Vector4;
  49684. }, scene: any): Mesh;
  49685. }
  49686. }
  49687. declare module "babylonjs/Meshes/polygonMesh" {
  49688. import { Scene } from "babylonjs/scene";
  49689. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49690. import { Mesh } from "babylonjs/Meshes/mesh";
  49691. /**
  49692. * Polygon
  49693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49694. */
  49695. export class Polygon {
  49696. /**
  49697. * Creates a rectangle
  49698. * @param xmin bottom X coord
  49699. * @param ymin bottom Y coord
  49700. * @param xmax top X coord
  49701. * @param ymax top Y coord
  49702. * @returns points that make the resulting rectation
  49703. */
  49704. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49705. /**
  49706. * Creates a circle
  49707. * @param radius radius of circle
  49708. * @param cx scale in x
  49709. * @param cy scale in y
  49710. * @param numberOfSides number of sides that make up the circle
  49711. * @returns points that make the resulting circle
  49712. */
  49713. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49714. /**
  49715. * Creates a polygon from input string
  49716. * @param input Input polygon data
  49717. * @returns the parsed points
  49718. */
  49719. static Parse(input: string): Vector2[];
  49720. /**
  49721. * Starts building a polygon from x and y coordinates
  49722. * @param x x coordinate
  49723. * @param y y coordinate
  49724. * @returns the started path2
  49725. */
  49726. static StartingAt(x: number, y: number): Path2;
  49727. }
  49728. /**
  49729. * Builds a polygon
  49730. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49731. */
  49732. export class PolygonMeshBuilder {
  49733. private _points;
  49734. private _outlinepoints;
  49735. private _holes;
  49736. private _name;
  49737. private _scene;
  49738. private _epoints;
  49739. private _eholes;
  49740. private _addToepoint;
  49741. /**
  49742. * Babylon reference to the earcut plugin.
  49743. */
  49744. bjsEarcut: any;
  49745. /**
  49746. * Creates a PolygonMeshBuilder
  49747. * @param name name of the builder
  49748. * @param contours Path of the polygon
  49749. * @param scene scene to add to
  49750. * @param earcutInjection can be used to inject your own earcut reference
  49751. */
  49752. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  49753. /**
  49754. * Adds a whole within the polygon
  49755. * @param hole Array of points defining the hole
  49756. * @returns this
  49757. */
  49758. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49759. /**
  49760. * Creates the polygon
  49761. * @param updatable If the mesh should be updatable
  49762. * @param depth The depth of the mesh created
  49763. * @returns the created mesh
  49764. */
  49765. build(updatable?: boolean, depth?: number): Mesh;
  49766. /**
  49767. * Adds a side to the polygon
  49768. * @param positions points that make the polygon
  49769. * @param normals normals of the polygon
  49770. * @param uvs uvs of the polygon
  49771. * @param indices indices of the polygon
  49772. * @param bounds bounds of the polygon
  49773. * @param points points of the polygon
  49774. * @param depth depth of the polygon
  49775. * @param flip flip of the polygon
  49776. */
  49777. private addSide;
  49778. }
  49779. }
  49780. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  49781. import { Scene } from "babylonjs/scene";
  49782. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  49783. import { Mesh } from "babylonjs/Meshes/mesh";
  49784. /**
  49785. * Class containing static functions to help procedurally build meshes
  49786. */
  49787. export class PolygonBuilder {
  49788. /**
  49789. * Creates a polygon mesh
  49790. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49791. * * 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
  49792. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49795. * * Remember you can only change the shape positions, not their number when updating a polygon
  49796. * @param name defines the name of the mesh
  49797. * @param options defines the options used to create the mesh
  49798. * @param scene defines the hosting scene
  49799. * @param earcutInjection can be used to inject your own earcut reference
  49800. * @returns the polygon mesh
  49801. */
  49802. static CreatePolygon(name: string, options: {
  49803. shape: Vector3[];
  49804. holes?: Vector3[][];
  49805. depth?: number;
  49806. faceUV?: Vector4[];
  49807. faceColors?: Color4[];
  49808. updatable?: boolean;
  49809. sideOrientation?: number;
  49810. frontUVs?: Vector4;
  49811. backUVs?: Vector4;
  49812. }, scene: Scene, earcutInjection?: any): Mesh;
  49813. /**
  49814. * Creates an extruded polygon mesh, with depth in the Y direction.
  49815. * * 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)
  49816. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49817. * @param name defines the name of the mesh
  49818. * @param options defines the options used to create the mesh
  49819. * @param scene defines the hosting scene
  49820. * @param earcutInjection can be used to inject your own earcut reference
  49821. * @returns the polygon mesh
  49822. */
  49823. static ExtrudePolygon(name: string, options: {
  49824. shape: Vector3[];
  49825. holes?: Vector3[][];
  49826. depth?: number;
  49827. faceUV?: Vector4[];
  49828. faceColors?: Color4[];
  49829. updatable?: boolean;
  49830. sideOrientation?: number;
  49831. frontUVs?: Vector4;
  49832. backUVs?: Vector4;
  49833. }, scene: Scene, earcutInjection?: any): Mesh;
  49834. }
  49835. }
  49836. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  49837. import { Nullable } from "babylonjs/types";
  49838. import { Scene } from "babylonjs/scene";
  49839. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49840. import { Mesh } from "babylonjs/Meshes/mesh";
  49841. /**
  49842. * Class containing static functions to help procedurally build meshes
  49843. */
  49844. export class ShapeBuilder {
  49845. /**
  49846. * 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.
  49847. * * 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.
  49848. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49849. * * 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.
  49850. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49851. * * 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
  49852. * * 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
  49853. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49855. * * If you create a double-sided mesh, you can choose what parts of 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
  49856. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49858. * @param name defines the name of the mesh
  49859. * @param options defines the options used to create the mesh
  49860. * @param scene defines the hosting scene
  49861. * @returns the extruded shape mesh
  49862. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49864. */
  49865. static ExtrudeShape(name: string, options: {
  49866. shape: Vector3[];
  49867. path: Vector3[];
  49868. scale?: number;
  49869. rotation?: number;
  49870. cap?: number;
  49871. updatable?: boolean;
  49872. sideOrientation?: number;
  49873. frontUVs?: Vector4;
  49874. backUVs?: Vector4;
  49875. instance?: Mesh;
  49876. invertUV?: boolean;
  49877. }, scene?: Nullable<Scene>): Mesh;
  49878. /**
  49879. * Creates an custom extruded shape mesh.
  49880. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49881. * * 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.
  49882. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49883. * * 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
  49884. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49885. * * 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
  49886. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49887. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49888. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49889. * * 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
  49890. * * 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
  49891. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49893. * * If you create a double-sided mesh, you can choose what parts of 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
  49894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49896. * @param name defines the name of the mesh
  49897. * @param options defines the options used to create the mesh
  49898. * @param scene defines the hosting scene
  49899. * @returns the custom extruded shape mesh
  49900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49901. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49903. */
  49904. static ExtrudeShapeCustom(name: string, options: {
  49905. shape: Vector3[];
  49906. path: Vector3[];
  49907. scaleFunction?: any;
  49908. rotationFunction?: any;
  49909. ribbonCloseArray?: boolean;
  49910. ribbonClosePath?: boolean;
  49911. cap?: number;
  49912. updatable?: boolean;
  49913. sideOrientation?: number;
  49914. frontUVs?: Vector4;
  49915. backUVs?: Vector4;
  49916. instance?: Mesh;
  49917. invertUV?: boolean;
  49918. }, scene: Scene): Mesh;
  49919. private static _ExtrudeShapeGeneric;
  49920. }
  49921. }
  49922. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49923. import { Scene } from "babylonjs/scene";
  49924. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49925. import { Mesh } from "babylonjs/Meshes/mesh";
  49926. /**
  49927. * Class containing static functions to help procedurally build meshes
  49928. */
  49929. export class LatheBuilder {
  49930. /**
  49931. * Creates lathe mesh.
  49932. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49933. * * 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
  49934. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49935. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49936. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49937. * * 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
  49938. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49939. * * 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
  49940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49941. * * If you create a double-sided mesh, you can choose what parts of 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
  49942. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49944. * @param name defines the name of the mesh
  49945. * @param options defines the options used to create the mesh
  49946. * @param scene defines the hosting scene
  49947. * @returns the lathe mesh
  49948. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49949. */
  49950. static CreateLathe(name: string, options: {
  49951. shape: Vector3[];
  49952. radius?: number;
  49953. tessellation?: number;
  49954. clip?: number;
  49955. arc?: number;
  49956. closed?: boolean;
  49957. updatable?: boolean;
  49958. sideOrientation?: number;
  49959. frontUVs?: Vector4;
  49960. backUVs?: Vector4;
  49961. cap?: number;
  49962. invertUV?: boolean;
  49963. }, scene: Scene): Mesh;
  49964. }
  49965. }
  49966. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49967. import { Scene } from "babylonjs/scene";
  49968. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49969. import { Mesh } from "babylonjs/Meshes/mesh";
  49970. /**
  49971. * Class containing static functions to help procedurally build meshes
  49972. */
  49973. export class TubeBuilder {
  49974. /**
  49975. * Creates a tube mesh.
  49976. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49977. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49978. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49979. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49980. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49981. * * 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)
  49982. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49983. * * 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
  49984. * * 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
  49985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49986. * * If you create a double-sided mesh, you can choose what parts of 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
  49987. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49989. * @param name defines the name of the mesh
  49990. * @param options defines the options used to create the mesh
  49991. * @param scene defines the hosting scene
  49992. * @returns the tube mesh
  49993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49994. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49995. */
  49996. static CreateTube(name: string, options: {
  49997. path: Vector3[];
  49998. radius?: number;
  49999. tessellation?: number;
  50000. radiusFunction?: {
  50001. (i: number, distance: number): number;
  50002. };
  50003. cap?: number;
  50004. arc?: number;
  50005. updatable?: boolean;
  50006. sideOrientation?: number;
  50007. frontUVs?: Vector4;
  50008. backUVs?: Vector4;
  50009. instance?: Mesh;
  50010. invertUV?: boolean;
  50011. }, scene: Scene): Mesh;
  50012. }
  50013. }
  50014. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50015. import { Scene } from "babylonjs/scene";
  50016. import { Vector4 } from "babylonjs/Maths/math";
  50017. import { Mesh } from "babylonjs/Meshes/mesh";
  50018. /**
  50019. * Class containing static functions to help procedurally build meshes
  50020. */
  50021. export class IcoSphereBuilder {
  50022. /**
  50023. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50024. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50025. * * 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`)
  50026. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50027. * * 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
  50028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50029. * * If you create a double-sided mesh, you can choose what parts of 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
  50030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50031. * @param name defines the name of the mesh
  50032. * @param options defines the options used to create the mesh
  50033. * @param scene defines the hosting scene
  50034. * @returns the icosahedron mesh
  50035. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50036. */
  50037. static CreateIcoSphere(name: string, options: {
  50038. radius?: number;
  50039. radiusX?: number;
  50040. radiusY?: number;
  50041. radiusZ?: number;
  50042. flat?: boolean;
  50043. subdivisions?: number;
  50044. sideOrientation?: number;
  50045. frontUVs?: Vector4;
  50046. backUVs?: Vector4;
  50047. updatable?: boolean;
  50048. }, scene: Scene): Mesh;
  50049. }
  50050. }
  50051. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50052. import { Vector3 } from "babylonjs/Maths/math";
  50053. import { Mesh } from "babylonjs/Meshes/mesh";
  50054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50055. /**
  50056. * Class containing static functions to help procedurally build meshes
  50057. */
  50058. export class DecalBuilder {
  50059. /**
  50060. * Creates a decal mesh.
  50061. * 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
  50062. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50063. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50064. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50065. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50066. * @param name defines the name of the mesh
  50067. * @param sourceMesh defines the mesh where the decal must be applied
  50068. * @param options defines the options used to create the mesh
  50069. * @param scene defines the hosting scene
  50070. * @returns the decal mesh
  50071. * @see https://doc.babylonjs.com/how_to/decals
  50072. */
  50073. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50074. position?: Vector3;
  50075. normal?: Vector3;
  50076. size?: Vector3;
  50077. angle?: number;
  50078. }): Mesh;
  50079. }
  50080. }
  50081. declare module "babylonjs/Meshes/meshBuilder" {
  50082. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50083. import { Nullable } from "babylonjs/types";
  50084. import { Scene } from "babylonjs/scene";
  50085. import { Mesh } from "babylonjs/Meshes/mesh";
  50086. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50087. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50089. /**
  50090. * Class containing static functions to help procedurally build meshes
  50091. */
  50092. export class MeshBuilder {
  50093. /**
  50094. * Creates a box mesh
  50095. * * The parameter `size` sets the size (float) of each box side (default 1)
  50096. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50097. * * 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)
  50098. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50100. * * If you create a double-sided mesh, you can choose what parts of 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
  50101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50102. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50103. * @param name defines the name of the mesh
  50104. * @param options defines the options used to create the mesh
  50105. * @param scene defines the hosting scene
  50106. * @returns the box mesh
  50107. */
  50108. static CreateBox(name: string, options: {
  50109. size?: number;
  50110. width?: number;
  50111. height?: number;
  50112. depth?: number;
  50113. faceUV?: Vector4[];
  50114. faceColors?: Color4[];
  50115. sideOrientation?: number;
  50116. frontUVs?: Vector4;
  50117. backUVs?: Vector4;
  50118. updatable?: boolean;
  50119. }, scene?: Nullable<Scene>): Mesh;
  50120. /**
  50121. * Creates a sphere mesh
  50122. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50123. * * 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`)
  50124. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50125. * * 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
  50126. * * 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)
  50127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50128. * * If you create a double-sided mesh, you can choose what parts of 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
  50129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50130. * @param name defines the name of the mesh
  50131. * @param options defines the options used to create the mesh
  50132. * @param scene defines the hosting scene
  50133. * @returns the sphere mesh
  50134. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50135. */
  50136. static CreateSphere(name: string, options: {
  50137. segments?: number;
  50138. diameter?: number;
  50139. diameterX?: number;
  50140. diameterY?: number;
  50141. diameterZ?: number;
  50142. arc?: number;
  50143. slice?: number;
  50144. sideOrientation?: number;
  50145. frontUVs?: Vector4;
  50146. backUVs?: Vector4;
  50147. updatable?: boolean;
  50148. }, scene: any): Mesh;
  50149. /**
  50150. * Creates a plane polygonal mesh. By default, this is a disc
  50151. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50152. * * 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
  50153. * * 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
  50154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50155. * * If you create a double-sided mesh, you can choose what parts of 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
  50156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50157. * @param name defines the name of the mesh
  50158. * @param options defines the options used to create the mesh
  50159. * @param scene defines the hosting scene
  50160. * @returns the plane polygonal mesh
  50161. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50162. */
  50163. static CreateDisc(name: string, options: {
  50164. radius?: number;
  50165. tessellation?: number;
  50166. arc?: number;
  50167. updatable?: boolean;
  50168. sideOrientation?: number;
  50169. frontUVs?: Vector4;
  50170. backUVs?: Vector4;
  50171. }, scene?: Nullable<Scene>): Mesh;
  50172. /**
  50173. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50174. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50175. * * 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`)
  50176. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50177. * * 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
  50178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50181. * @param name defines the name of the mesh
  50182. * @param options defines the options used to create the mesh
  50183. * @param scene defines the hosting scene
  50184. * @returns the icosahedron mesh
  50185. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50186. */
  50187. static CreateIcoSphere(name: string, options: {
  50188. radius?: number;
  50189. radiusX?: number;
  50190. radiusY?: number;
  50191. radiusZ?: number;
  50192. flat?: boolean;
  50193. subdivisions?: number;
  50194. sideOrientation?: number;
  50195. frontUVs?: Vector4;
  50196. backUVs?: Vector4;
  50197. updatable?: boolean;
  50198. }, scene: Scene): Mesh;
  50199. /**
  50200. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50201. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50202. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50203. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50204. * * 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
  50205. * * 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
  50206. * * 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
  50207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50208. * * If you create a double-sided mesh, you can choose what parts of 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
  50209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50210. * * 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
  50211. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50212. * * 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
  50213. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50215. * @param name defines the name of the mesh
  50216. * @param options defines the options used to create the mesh
  50217. * @param scene defines the hosting scene
  50218. * @returns the ribbon mesh
  50219. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50220. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50221. */
  50222. static CreateRibbon(name: string, options: {
  50223. pathArray: Vector3[][];
  50224. closeArray?: boolean;
  50225. closePath?: boolean;
  50226. offset?: number;
  50227. updatable?: boolean;
  50228. sideOrientation?: number;
  50229. frontUVs?: Vector4;
  50230. backUVs?: Vector4;
  50231. instance?: Mesh;
  50232. invertUV?: boolean;
  50233. uvs?: Vector2[];
  50234. colors?: Color4[];
  50235. }, scene?: Nullable<Scene>): Mesh;
  50236. /**
  50237. * Creates a cylinder or a cone mesh
  50238. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50239. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50240. * * 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.
  50241. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50242. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50243. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50244. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50245. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50246. * * 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).
  50247. * * 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
  50248. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50249. * * 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
  50250. * * 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.
  50251. * * If `enclose` is false, a ring surface is one element.
  50252. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50253. * * 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
  50254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50255. * * If you create a double-sided mesh, you can choose what parts of 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
  50256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50257. * @param name defines the name of the mesh
  50258. * @param options defines the options used to create the mesh
  50259. * @param scene defines the hosting scene
  50260. * @returns the cylinder mesh
  50261. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50262. */
  50263. static CreateCylinder(name: string, options: {
  50264. height?: number;
  50265. diameterTop?: number;
  50266. diameterBottom?: number;
  50267. diameter?: number;
  50268. tessellation?: number;
  50269. subdivisions?: number;
  50270. arc?: number;
  50271. faceColors?: Color4[];
  50272. faceUV?: Vector4[];
  50273. updatable?: boolean;
  50274. hasRings?: boolean;
  50275. enclose?: boolean;
  50276. sideOrientation?: number;
  50277. frontUVs?: Vector4;
  50278. backUVs?: Vector4;
  50279. }, scene: any): Mesh;
  50280. /**
  50281. * Creates a torus mesh
  50282. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50283. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50284. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50286. * * If you create a double-sided mesh, you can choose what parts of 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
  50287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50288. * @param name defines the name of the mesh
  50289. * @param options defines the options used to create the mesh
  50290. * @param scene defines the hosting scene
  50291. * @returns the torus mesh
  50292. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50293. */
  50294. static CreateTorus(name: string, options: {
  50295. diameter?: number;
  50296. thickness?: number;
  50297. tessellation?: number;
  50298. updatable?: boolean;
  50299. sideOrientation?: number;
  50300. frontUVs?: Vector4;
  50301. backUVs?: Vector4;
  50302. }, scene: any): Mesh;
  50303. /**
  50304. * Creates a torus knot mesh
  50305. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50306. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50307. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50308. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50312. * @param name defines the name of the mesh
  50313. * @param options defines the options used to create the mesh
  50314. * @param scene defines the hosting scene
  50315. * @returns the torus knot mesh
  50316. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50317. */
  50318. static CreateTorusKnot(name: string, options: {
  50319. radius?: number;
  50320. tube?: number;
  50321. radialSegments?: number;
  50322. tubularSegments?: number;
  50323. p?: number;
  50324. q?: number;
  50325. updatable?: boolean;
  50326. sideOrientation?: number;
  50327. frontUVs?: Vector4;
  50328. backUVs?: Vector4;
  50329. }, scene: any): Mesh;
  50330. /**
  50331. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50332. * * 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
  50333. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50334. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50335. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50336. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50337. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50338. * * 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
  50339. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50342. * @param name defines the name of the new line system
  50343. * @param options defines the options used to create the line system
  50344. * @param scene defines the hosting scene
  50345. * @returns a new line system mesh
  50346. */
  50347. static CreateLineSystem(name: string, options: {
  50348. lines: Vector3[][];
  50349. updatable?: boolean;
  50350. instance?: Nullable<LinesMesh>;
  50351. colors?: Nullable<Color4[][]>;
  50352. useVertexAlpha?: boolean;
  50353. }, scene: Nullable<Scene>): LinesMesh;
  50354. /**
  50355. * Creates a line mesh
  50356. * 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
  50357. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50358. * * The parameter `points` is an array successive Vector3
  50359. * * 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
  50360. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50361. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50362. * * When updating an instance, remember that only point positions can change, not the number of points
  50363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50365. * @param name defines the name of the new line system
  50366. * @param options defines the options used to create the line system
  50367. * @param scene defines the hosting scene
  50368. * @returns a new line mesh
  50369. */
  50370. static CreateLines(name: string, options: {
  50371. points: Vector3[];
  50372. updatable?: boolean;
  50373. instance?: Nullable<LinesMesh>;
  50374. colors?: Color4[];
  50375. useVertexAlpha?: boolean;
  50376. }, scene?: Nullable<Scene>): LinesMesh;
  50377. /**
  50378. * Creates a dashed line mesh
  50379. * * 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
  50380. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50381. * * The parameter `points` is an array successive Vector3
  50382. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50383. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50384. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50385. * * 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
  50386. * * When updating an instance, remember that only point positions can change, not the number of points
  50387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50388. * @param name defines the name of the mesh
  50389. * @param options defines the options used to create the mesh
  50390. * @param scene defines the hosting scene
  50391. * @returns the dashed line mesh
  50392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50393. */
  50394. static CreateDashedLines(name: string, options: {
  50395. points: Vector3[];
  50396. dashSize?: number;
  50397. gapSize?: number;
  50398. dashNb?: number;
  50399. updatable?: boolean;
  50400. instance?: LinesMesh;
  50401. }, scene?: Nullable<Scene>): LinesMesh;
  50402. /**
  50403. * 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.
  50404. * * 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.
  50405. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50406. * * 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.
  50407. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50408. * * 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
  50409. * * 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
  50410. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50412. * * If you create a double-sided mesh, you can choose what parts of 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
  50413. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50415. * @param name defines the name of the mesh
  50416. * @param options defines the options used to create the mesh
  50417. * @param scene defines the hosting scene
  50418. * @returns the extruded shape mesh
  50419. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50421. */
  50422. static ExtrudeShape(name: string, options: {
  50423. shape: Vector3[];
  50424. path: Vector3[];
  50425. scale?: number;
  50426. rotation?: number;
  50427. cap?: number;
  50428. updatable?: boolean;
  50429. sideOrientation?: number;
  50430. frontUVs?: Vector4;
  50431. backUVs?: Vector4;
  50432. instance?: Mesh;
  50433. invertUV?: boolean;
  50434. }, scene?: Nullable<Scene>): Mesh;
  50435. /**
  50436. * Creates an custom extruded shape mesh.
  50437. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50438. * * 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.
  50439. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50440. * * 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
  50441. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50442. * * 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
  50443. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50444. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50445. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50446. * * 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
  50447. * * 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
  50448. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50450. * * If you create a double-sided mesh, you can choose what parts of 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
  50451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50453. * @param name defines the name of the mesh
  50454. * @param options defines the options used to create the mesh
  50455. * @param scene defines the hosting scene
  50456. * @returns the custom extruded shape mesh
  50457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50458. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50460. */
  50461. static ExtrudeShapeCustom(name: string, options: {
  50462. shape: Vector3[];
  50463. path: Vector3[];
  50464. scaleFunction?: any;
  50465. rotationFunction?: any;
  50466. ribbonCloseArray?: boolean;
  50467. ribbonClosePath?: boolean;
  50468. cap?: number;
  50469. updatable?: boolean;
  50470. sideOrientation?: number;
  50471. frontUVs?: Vector4;
  50472. backUVs?: Vector4;
  50473. instance?: Mesh;
  50474. invertUV?: boolean;
  50475. }, scene: Scene): Mesh;
  50476. /**
  50477. * Creates lathe mesh.
  50478. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50479. * * 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
  50480. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50481. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50482. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50483. * * 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
  50484. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50485. * * 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
  50486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50487. * * If you create a double-sided mesh, you can choose what parts of 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
  50488. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50490. * @param name defines the name of the mesh
  50491. * @param options defines the options used to create the mesh
  50492. * @param scene defines the hosting scene
  50493. * @returns the lathe mesh
  50494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50495. */
  50496. static CreateLathe(name: string, options: {
  50497. shape: Vector3[];
  50498. radius?: number;
  50499. tessellation?: number;
  50500. clip?: number;
  50501. arc?: number;
  50502. closed?: boolean;
  50503. updatable?: boolean;
  50504. sideOrientation?: number;
  50505. frontUVs?: Vector4;
  50506. backUVs?: Vector4;
  50507. cap?: number;
  50508. invertUV?: boolean;
  50509. }, scene: Scene): Mesh;
  50510. /**
  50511. * Creates a plane mesh
  50512. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50513. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50514. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50516. * * If you create a double-sided mesh, you can choose what parts of 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
  50517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50518. * @param name defines the name of the mesh
  50519. * @param options defines the options used to create the mesh
  50520. * @param scene defines the hosting scene
  50521. * @returns the plane mesh
  50522. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50523. */
  50524. static CreatePlane(name: string, options: {
  50525. size?: number;
  50526. width?: number;
  50527. height?: number;
  50528. sideOrientation?: number;
  50529. frontUVs?: Vector4;
  50530. backUVs?: Vector4;
  50531. updatable?: boolean;
  50532. sourcePlane?: Plane;
  50533. }, scene: Scene): Mesh;
  50534. /**
  50535. * Creates a ground mesh
  50536. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50537. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50539. * @param name defines the name of the mesh
  50540. * @param options defines the options used to create the mesh
  50541. * @param scene defines the hosting scene
  50542. * @returns the ground mesh
  50543. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50544. */
  50545. static CreateGround(name: string, options: {
  50546. width?: number;
  50547. height?: number;
  50548. subdivisions?: number;
  50549. subdivisionsX?: number;
  50550. subdivisionsY?: number;
  50551. updatable?: boolean;
  50552. }, scene: any): Mesh;
  50553. /**
  50554. * Creates a tiled ground mesh
  50555. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50556. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50557. * * 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
  50558. * * 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
  50559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50560. * @param name defines the name of the mesh
  50561. * @param options defines the options used to create the mesh
  50562. * @param scene defines the hosting scene
  50563. * @returns the tiled ground mesh
  50564. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50565. */
  50566. static CreateTiledGround(name: string, options: {
  50567. xmin: number;
  50568. zmin: number;
  50569. xmax: number;
  50570. zmax: number;
  50571. subdivisions?: {
  50572. w: number;
  50573. h: number;
  50574. };
  50575. precision?: {
  50576. w: number;
  50577. h: number;
  50578. };
  50579. updatable?: boolean;
  50580. }, scene: Scene): Mesh;
  50581. /**
  50582. * Creates a ground mesh from a height map
  50583. * * The parameter `url` sets the URL of the height map image resource.
  50584. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50585. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50586. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50587. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50588. * * 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.
  50589. * * 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).
  50590. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50592. * @param name defines the name of the mesh
  50593. * @param url defines the url to the height map
  50594. * @param options defines the options used to create the mesh
  50595. * @param scene defines the hosting scene
  50596. * @returns the ground mesh
  50597. * @see https://doc.babylonjs.com/babylon101/height_map
  50598. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50599. */
  50600. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50601. width?: number;
  50602. height?: number;
  50603. subdivisions?: number;
  50604. minHeight?: number;
  50605. maxHeight?: number;
  50606. colorFilter?: Color3;
  50607. alphaFilter?: number;
  50608. updatable?: boolean;
  50609. onReady?: (mesh: GroundMesh) => void;
  50610. }, scene: Scene): GroundMesh;
  50611. /**
  50612. * Creates a polygon mesh
  50613. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50614. * * 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
  50615. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50618. * * Remember you can only change the shape positions, not their number when updating a polygon
  50619. * @param name defines the name of the mesh
  50620. * @param options defines the options used to create the mesh
  50621. * @param scene defines the hosting scene
  50622. * @param earcutInjection can be used to inject your own earcut reference
  50623. * @returns the polygon mesh
  50624. */
  50625. static CreatePolygon(name: string, options: {
  50626. shape: Vector3[];
  50627. holes?: Vector3[][];
  50628. depth?: number;
  50629. faceUV?: Vector4[];
  50630. faceColors?: Color4[];
  50631. updatable?: boolean;
  50632. sideOrientation?: number;
  50633. frontUVs?: Vector4;
  50634. backUVs?: Vector4;
  50635. }, scene: Scene, earcutInjection?: any): Mesh;
  50636. /**
  50637. * Creates an extruded polygon mesh, with depth in the Y direction.
  50638. * * 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)
  50639. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50640. * @param name defines the name of the mesh
  50641. * @param options defines the options used to create the mesh
  50642. * @param scene defines the hosting scene
  50643. * @param earcutInjection can be used to inject your own earcut reference
  50644. * @returns the polygon mesh
  50645. */
  50646. static ExtrudePolygon(name: string, options: {
  50647. shape: Vector3[];
  50648. holes?: Vector3[][];
  50649. depth?: number;
  50650. faceUV?: Vector4[];
  50651. faceColors?: Color4[];
  50652. updatable?: boolean;
  50653. sideOrientation?: number;
  50654. frontUVs?: Vector4;
  50655. backUVs?: Vector4;
  50656. }, scene: Scene, earcutInjection?: any): Mesh;
  50657. /**
  50658. * Creates a tube mesh.
  50659. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50660. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50661. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50662. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50663. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50664. * * 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)
  50665. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50666. * * 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
  50667. * * 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
  50668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50669. * * If you create a double-sided mesh, you can choose what parts of 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
  50670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50672. * @param name defines the name of the mesh
  50673. * @param options defines the options used to create the mesh
  50674. * @param scene defines the hosting scene
  50675. * @returns the tube mesh
  50676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50677. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50678. */
  50679. static CreateTube(name: string, options: {
  50680. path: Vector3[];
  50681. radius?: number;
  50682. tessellation?: number;
  50683. radiusFunction?: {
  50684. (i: number, distance: number): number;
  50685. };
  50686. cap?: number;
  50687. arc?: number;
  50688. updatable?: boolean;
  50689. sideOrientation?: number;
  50690. frontUVs?: Vector4;
  50691. backUVs?: Vector4;
  50692. instance?: Mesh;
  50693. invertUV?: boolean;
  50694. }, scene: Scene): Mesh;
  50695. /**
  50696. * Creates a polyhedron mesh
  50697. * * 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
  50698. * * The parameter `size` (positive float, default 1) sets the polygon size
  50699. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50700. * * 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`
  50701. * * 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
  50702. * * 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)`)
  50703. * * 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
  50704. * * 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
  50705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50706. * * If you create a double-sided mesh, you can choose what parts of 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
  50707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50708. * @param name defines the name of the mesh
  50709. * @param options defines the options used to create the mesh
  50710. * @param scene defines the hosting scene
  50711. * @returns the polyhedron mesh
  50712. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50713. */
  50714. static CreatePolyhedron(name: string, options: {
  50715. type?: number;
  50716. size?: number;
  50717. sizeX?: number;
  50718. sizeY?: number;
  50719. sizeZ?: number;
  50720. custom?: any;
  50721. faceUV?: Vector4[];
  50722. faceColors?: Color4[];
  50723. flat?: boolean;
  50724. updatable?: boolean;
  50725. sideOrientation?: number;
  50726. frontUVs?: Vector4;
  50727. backUVs?: Vector4;
  50728. }, scene: Scene): Mesh;
  50729. /**
  50730. * Creates a decal mesh.
  50731. * 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
  50732. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50733. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50734. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50735. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50736. * @param name defines the name of the mesh
  50737. * @param sourceMesh defines the mesh where the decal must be applied
  50738. * @param options defines the options used to create the mesh
  50739. * @param scene defines the hosting scene
  50740. * @returns the decal mesh
  50741. * @see https://doc.babylonjs.com/how_to/decals
  50742. */
  50743. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50744. position?: Vector3;
  50745. normal?: Vector3;
  50746. size?: Vector3;
  50747. angle?: number;
  50748. }): Mesh;
  50749. }
  50750. }
  50751. declare module "babylonjs/Meshes/meshSimplification" {
  50752. import { Mesh } from "babylonjs/Meshes/mesh";
  50753. /**
  50754. * A simplifier interface for future simplification implementations
  50755. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50756. */
  50757. export interface ISimplifier {
  50758. /**
  50759. * Simplification of a given mesh according to the given settings.
  50760. * Since this requires computation, it is assumed that the function runs async.
  50761. * @param settings The settings of the simplification, including quality and distance
  50762. * @param successCallback A callback that will be called after the mesh was simplified.
  50763. * @param errorCallback in case of an error, this callback will be called. optional.
  50764. */
  50765. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50766. }
  50767. /**
  50768. * Expected simplification settings.
  50769. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50770. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50771. */
  50772. export interface ISimplificationSettings {
  50773. /**
  50774. * Gets or sets the expected quality
  50775. */
  50776. quality: number;
  50777. /**
  50778. * Gets or sets the distance when this optimized version should be used
  50779. */
  50780. distance: number;
  50781. /**
  50782. * Gets an already optimized mesh
  50783. */
  50784. optimizeMesh?: boolean;
  50785. }
  50786. /**
  50787. * Class used to specify simplification options
  50788. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50789. */
  50790. export class SimplificationSettings implements ISimplificationSettings {
  50791. /** expected quality */
  50792. quality: number;
  50793. /** distance when this optimized version should be used */
  50794. distance: number;
  50795. /** already optimized mesh */
  50796. optimizeMesh?: boolean | undefined;
  50797. /**
  50798. * Creates a SimplificationSettings
  50799. * @param quality expected quality
  50800. * @param distance distance when this optimized version should be used
  50801. * @param optimizeMesh already optimized mesh
  50802. */
  50803. constructor(
  50804. /** expected quality */
  50805. quality: number,
  50806. /** distance when this optimized version should be used */
  50807. distance: number,
  50808. /** already optimized mesh */
  50809. optimizeMesh?: boolean | undefined);
  50810. }
  50811. /**
  50812. * Interface used to define a simplification task
  50813. */
  50814. export interface ISimplificationTask {
  50815. /**
  50816. * Array of settings
  50817. */
  50818. settings: Array<ISimplificationSettings>;
  50819. /**
  50820. * Simplification type
  50821. */
  50822. simplificationType: SimplificationType;
  50823. /**
  50824. * Mesh to simplify
  50825. */
  50826. mesh: Mesh;
  50827. /**
  50828. * Callback called on success
  50829. */
  50830. successCallback?: () => void;
  50831. /**
  50832. * Defines if parallel processing can be used
  50833. */
  50834. parallelProcessing: boolean;
  50835. }
  50836. /**
  50837. * Queue used to order the simplification tasks
  50838. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50839. */
  50840. export class SimplificationQueue {
  50841. private _simplificationArray;
  50842. /**
  50843. * Gets a boolean indicating that the process is still running
  50844. */
  50845. running: boolean;
  50846. /**
  50847. * Creates a new queue
  50848. */
  50849. constructor();
  50850. /**
  50851. * Adds a new simplification task
  50852. * @param task defines a task to add
  50853. */
  50854. addTask(task: ISimplificationTask): void;
  50855. /**
  50856. * Execute next task
  50857. */
  50858. executeNext(): void;
  50859. /**
  50860. * Execute a simplification task
  50861. * @param task defines the task to run
  50862. */
  50863. runSimplification(task: ISimplificationTask): void;
  50864. private getSimplifier;
  50865. }
  50866. /**
  50867. * The implemented types of simplification
  50868. * At the moment only Quadratic Error Decimation is implemented
  50869. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50870. */
  50871. export enum SimplificationType {
  50872. /** Quadratic error decimation */
  50873. QUADRATIC = 0
  50874. }
  50875. }
  50876. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  50877. import { Scene } from "babylonjs/scene";
  50878. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  50879. import { ISceneComponent } from "babylonjs/sceneComponent";
  50880. module "babylonjs/scene" {
  50881. interface Scene {
  50882. /** @hidden (Backing field) */
  50883. _simplificationQueue: SimplificationQueue;
  50884. /**
  50885. * Gets or sets the simplification queue attached to the scene
  50886. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50887. */
  50888. simplificationQueue: SimplificationQueue;
  50889. }
  50890. }
  50891. module "babylonjs/Meshes/mesh" {
  50892. interface Mesh {
  50893. /**
  50894. * Simplify the mesh according to the given array of settings.
  50895. * Function will return immediately and will simplify async
  50896. * @param settings a collection of simplification settings
  50897. * @param parallelProcessing should all levels calculate parallel or one after the other
  50898. * @param simplificationType the type of simplification to run
  50899. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50900. * @returns the current mesh
  50901. */
  50902. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50903. }
  50904. }
  50905. /**
  50906. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50907. * created in a scene
  50908. */
  50909. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50910. /**
  50911. * The component name helpfull to identify the component in the list of scene components.
  50912. */
  50913. readonly name: string;
  50914. /**
  50915. * The scene the component belongs to.
  50916. */
  50917. scene: Scene;
  50918. /**
  50919. * Creates a new instance of the component for the given scene
  50920. * @param scene Defines the scene to register the component in
  50921. */
  50922. constructor(scene: Scene);
  50923. /**
  50924. * Registers the component in a given scene
  50925. */
  50926. register(): void;
  50927. /**
  50928. * Rebuilds the elements related to this component in case of
  50929. * context lost for instance.
  50930. */
  50931. rebuild(): void;
  50932. /**
  50933. * Disposes the component and the associated ressources
  50934. */
  50935. dispose(): void;
  50936. private _beforeCameraUpdate;
  50937. }
  50938. }
  50939. declare module "babylonjs/Meshes/Builders/index" {
  50940. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50941. export * from "babylonjs/Meshes/Builders/discBuilder";
  50942. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50943. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50944. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50945. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50946. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50947. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50948. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50949. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50950. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50951. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50952. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50953. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50954. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50955. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50956. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50957. }
  50958. declare module "babylonjs/Meshes/index" {
  50959. export * from "babylonjs/Meshes/abstractMesh";
  50960. export * from "babylonjs/Meshes/buffer";
  50961. export * from "babylonjs/Meshes/Compression/index";
  50962. export * from "babylonjs/Meshes/csg";
  50963. export * from "babylonjs/Meshes/geometry";
  50964. export * from "babylonjs/Meshes/groundMesh";
  50965. export * from "babylonjs/Meshes/trailMesh";
  50966. export * from "babylonjs/Meshes/instancedMesh";
  50967. export * from "babylonjs/Meshes/linesMesh";
  50968. export * from "babylonjs/Meshes/mesh";
  50969. export * from "babylonjs/Meshes/mesh.vertexData";
  50970. export * from "babylonjs/Meshes/meshBuilder";
  50971. export * from "babylonjs/Meshes/meshSimplification";
  50972. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50973. export * from "babylonjs/Meshes/polygonMesh";
  50974. export * from "babylonjs/Meshes/subMesh";
  50975. export * from "babylonjs/Meshes/transformNode";
  50976. export * from "babylonjs/Meshes/Builders/index";
  50977. }
  50978. declare module "babylonjs/Morph/index" {
  50979. export * from "babylonjs/Morph/morphTarget";
  50980. export * from "babylonjs/Morph/morphTargetManager";
  50981. }
  50982. declare module "babylonjs/Offline/database" {
  50983. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  50984. /**
  50985. * Class used to enable access to IndexedDB
  50986. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50987. */
  50988. export class Database implements IOfflineProvider {
  50989. private _callbackManifestChecked;
  50990. private _currentSceneUrl;
  50991. private _db;
  50992. private _enableSceneOffline;
  50993. private _enableTexturesOffline;
  50994. private _manifestVersionFound;
  50995. private _mustUpdateRessources;
  50996. private _hasReachedQuota;
  50997. private _isSupported;
  50998. private _idbFactory;
  50999. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51000. private static IsUASupportingBlobStorage;
  51001. /**
  51002. * Gets a boolean indicating if Database storate is enabled (off by default)
  51003. */
  51004. static IDBStorageEnabled: boolean;
  51005. /**
  51006. * Gets a boolean indicating if scene must be saved in the database
  51007. */
  51008. readonly enableSceneOffline: boolean;
  51009. /**
  51010. * Gets a boolean indicating if textures must be saved in the database
  51011. */
  51012. readonly enableTexturesOffline: boolean;
  51013. /**
  51014. * Creates a new Database
  51015. * @param urlToScene defines the url to load the scene
  51016. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51017. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51018. */
  51019. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51020. private static _ParseURL;
  51021. private static _ReturnFullUrlLocation;
  51022. private _checkManifestFile;
  51023. /**
  51024. * Open the database and make it available
  51025. * @param successCallback defines the callback to call on success
  51026. * @param errorCallback defines the callback to call on error
  51027. */
  51028. open(successCallback: () => void, errorCallback: () => void): void;
  51029. /**
  51030. * Loads an image from the database
  51031. * @param url defines the url to load from
  51032. * @param image defines the target DOM image
  51033. */
  51034. loadImage(url: string, image: HTMLImageElement): void;
  51035. private _loadImageFromDBAsync;
  51036. private _saveImageIntoDBAsync;
  51037. private _checkVersionFromDB;
  51038. private _loadVersionFromDBAsync;
  51039. private _saveVersionIntoDBAsync;
  51040. /**
  51041. * Loads a file from database
  51042. * @param url defines the URL to load from
  51043. * @param sceneLoaded defines a callback to call on success
  51044. * @param progressCallBack defines a callback to call when progress changed
  51045. * @param errorCallback defines a callback to call on error
  51046. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51047. */
  51048. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51049. private _loadFileAsync;
  51050. private _saveFileAsync;
  51051. /**
  51052. * Validates if xhr data is correct
  51053. * @param xhr defines the request to validate
  51054. * @param dataType defines the expected data type
  51055. * @returns true if data is correct
  51056. */
  51057. private static _ValidateXHRData;
  51058. }
  51059. }
  51060. declare module "babylonjs/Offline/index" {
  51061. export * from "babylonjs/Offline/database";
  51062. export * from "babylonjs/Offline/IOfflineProvider";
  51063. }
  51064. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51065. /** @hidden */
  51066. export var gpuUpdateParticlesPixelShader: {
  51067. name: string;
  51068. shader: string;
  51069. };
  51070. }
  51071. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51072. /** @hidden */
  51073. export var gpuUpdateParticlesVertexShader: {
  51074. name: string;
  51075. shader: string;
  51076. };
  51077. }
  51078. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51079. /** @hidden */
  51080. export var clipPlaneFragmentDeclaration2: {
  51081. name: string;
  51082. shader: string;
  51083. };
  51084. }
  51085. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51086. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51087. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51088. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51089. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51090. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51091. /** @hidden */
  51092. export var gpuRenderParticlesPixelShader: {
  51093. name: string;
  51094. shader: string;
  51095. };
  51096. }
  51097. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51098. /** @hidden */
  51099. export var clipPlaneVertexDeclaration2: {
  51100. name: string;
  51101. shader: string;
  51102. };
  51103. }
  51104. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51105. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51106. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51107. /** @hidden */
  51108. export var gpuRenderParticlesVertexShader: {
  51109. name: string;
  51110. shader: string;
  51111. };
  51112. }
  51113. declare module "babylonjs/Particles/gpuParticleSystem" {
  51114. import { Nullable } from "babylonjs/types";
  51115. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51116. import { Observable } from "babylonjs/Misc/observable";
  51117. import { Color4, Color3 } from "babylonjs/Maths/math";
  51118. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51119. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51120. import { Scene, IDisposable } from "babylonjs/scene";
  51121. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51122. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51123. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51124. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51125. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51126. /**
  51127. * This represents a GPU particle system in Babylon
  51128. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51129. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51130. */
  51131. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51132. /**
  51133. * The layer mask we are rendering the particles through.
  51134. */
  51135. layerMask: number;
  51136. private _capacity;
  51137. private _activeCount;
  51138. private _currentActiveCount;
  51139. private _accumulatedCount;
  51140. private _renderEffect;
  51141. private _updateEffect;
  51142. private _buffer0;
  51143. private _buffer1;
  51144. private _spriteBuffer;
  51145. private _updateVAO;
  51146. private _renderVAO;
  51147. private _targetIndex;
  51148. private _sourceBuffer;
  51149. private _targetBuffer;
  51150. private _engine;
  51151. private _currentRenderId;
  51152. private _started;
  51153. private _stopped;
  51154. private _timeDelta;
  51155. private _randomTexture;
  51156. private _randomTexture2;
  51157. private _attributesStrideSize;
  51158. private _updateEffectOptions;
  51159. private _randomTextureSize;
  51160. private _actualFrame;
  51161. private readonly _rawTextureWidth;
  51162. /**
  51163. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51164. */
  51165. static readonly IsSupported: boolean;
  51166. /**
  51167. * An event triggered when the system is disposed.
  51168. */
  51169. onDisposeObservable: Observable<GPUParticleSystem>;
  51170. /**
  51171. * Gets the maximum number of particles active at the same time.
  51172. * @returns The max number of active particles.
  51173. */
  51174. getCapacity(): number;
  51175. /**
  51176. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51177. * to override the particles.
  51178. */
  51179. forceDepthWrite: boolean;
  51180. /**
  51181. * Gets or set the number of active particles
  51182. */
  51183. activeParticleCount: number;
  51184. private _preWarmDone;
  51185. /**
  51186. * Is this system ready to be used/rendered
  51187. * @return true if the system is ready
  51188. */
  51189. isReady(): boolean;
  51190. /**
  51191. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51192. * @returns True if it has been started, otherwise false.
  51193. */
  51194. isStarted(): boolean;
  51195. /**
  51196. * Starts the particle system and begins to emit
  51197. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51198. */
  51199. start(delay?: number): void;
  51200. /**
  51201. * Stops the particle system.
  51202. */
  51203. stop(): void;
  51204. /**
  51205. * Remove all active particles
  51206. */
  51207. reset(): void;
  51208. /**
  51209. * Returns the string "GPUParticleSystem"
  51210. * @returns a string containing the class name
  51211. */
  51212. getClassName(): string;
  51213. private _colorGradientsTexture;
  51214. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51215. /**
  51216. * Adds a new color gradient
  51217. * @param gradient defines the gradient to use (between 0 and 1)
  51218. * @param color1 defines the color to affect to the specified gradient
  51219. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51220. * @returns the current particle system
  51221. */
  51222. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51223. /**
  51224. * Remove a specific color gradient
  51225. * @param gradient defines the gradient to remove
  51226. * @returns the current particle system
  51227. */
  51228. removeColorGradient(gradient: number): GPUParticleSystem;
  51229. private _angularSpeedGradientsTexture;
  51230. private _sizeGradientsTexture;
  51231. private _velocityGradientsTexture;
  51232. private _limitVelocityGradientsTexture;
  51233. private _dragGradientsTexture;
  51234. private _addFactorGradient;
  51235. /**
  51236. * Adds a new size gradient
  51237. * @param gradient defines the gradient to use (between 0 and 1)
  51238. * @param factor defines the size factor to affect to the specified gradient
  51239. * @returns the current particle system
  51240. */
  51241. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51242. /**
  51243. * Remove a specific size gradient
  51244. * @param gradient defines the gradient to remove
  51245. * @returns the current particle system
  51246. */
  51247. removeSizeGradient(gradient: number): GPUParticleSystem;
  51248. /**
  51249. * Adds a new angular speed gradient
  51250. * @param gradient defines the gradient to use (between 0 and 1)
  51251. * @param factor defines the angular speed to affect to the specified gradient
  51252. * @returns the current particle system
  51253. */
  51254. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51255. /**
  51256. * Remove a specific angular speed gradient
  51257. * @param gradient defines the gradient to remove
  51258. * @returns the current particle system
  51259. */
  51260. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51261. /**
  51262. * Adds a new velocity gradient
  51263. * @param gradient defines the gradient to use (between 0 and 1)
  51264. * @param factor defines the velocity to affect to the specified gradient
  51265. * @returns the current particle system
  51266. */
  51267. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51268. /**
  51269. * Remove a specific velocity gradient
  51270. * @param gradient defines the gradient to remove
  51271. * @returns the current particle system
  51272. */
  51273. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51274. /**
  51275. * Adds a new limit velocity gradient
  51276. * @param gradient defines the gradient to use (between 0 and 1)
  51277. * @param factor defines the limit velocity value to affect to the specified gradient
  51278. * @returns the current particle system
  51279. */
  51280. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51281. /**
  51282. * Remove a specific limit velocity gradient
  51283. * @param gradient defines the gradient to remove
  51284. * @returns the current particle system
  51285. */
  51286. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51287. /**
  51288. * Adds a new drag gradient
  51289. * @param gradient defines the gradient to use (between 0 and 1)
  51290. * @param factor defines the drag value to affect to the specified gradient
  51291. * @returns the current particle system
  51292. */
  51293. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51294. /**
  51295. * Remove a specific drag gradient
  51296. * @param gradient defines the gradient to remove
  51297. * @returns the current particle system
  51298. */
  51299. removeDragGradient(gradient: number): GPUParticleSystem;
  51300. /**
  51301. * Not supported by GPUParticleSystem
  51302. * @param gradient defines the gradient to use (between 0 and 1)
  51303. * @param factor defines the emit rate value to affect to the specified gradient
  51304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51305. * @returns the current particle system
  51306. */
  51307. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51308. /**
  51309. * Not supported by GPUParticleSystem
  51310. * @param gradient defines the gradient to remove
  51311. * @returns the current particle system
  51312. */
  51313. removeEmitRateGradient(gradient: number): IParticleSystem;
  51314. /**
  51315. * Not supported by GPUParticleSystem
  51316. * @param gradient defines the gradient to use (between 0 and 1)
  51317. * @param factor defines the start size value to affect to the specified gradient
  51318. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51319. * @returns the current particle system
  51320. */
  51321. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51322. /**
  51323. * Not supported by GPUParticleSystem
  51324. * @param gradient defines the gradient to remove
  51325. * @returns the current particle system
  51326. */
  51327. removeStartSizeGradient(gradient: number): IParticleSystem;
  51328. /**
  51329. * Not supported by GPUParticleSystem
  51330. * @param gradient defines the gradient to use (between 0 and 1)
  51331. * @param min defines the color remap minimal range
  51332. * @param max defines the color remap maximal range
  51333. * @returns the current particle system
  51334. */
  51335. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51336. /**
  51337. * Not supported by GPUParticleSystem
  51338. * @param gradient defines the gradient to remove
  51339. * @returns the current particle system
  51340. */
  51341. removeColorRemapGradient(): IParticleSystem;
  51342. /**
  51343. * Not supported by GPUParticleSystem
  51344. * @param gradient defines the gradient to use (between 0 and 1)
  51345. * @param min defines the alpha remap minimal range
  51346. * @param max defines the alpha remap maximal range
  51347. * @returns the current particle system
  51348. */
  51349. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51350. /**
  51351. * Not supported by GPUParticleSystem
  51352. * @param gradient defines the gradient to remove
  51353. * @returns the current particle system
  51354. */
  51355. removeAlphaRemapGradient(): IParticleSystem;
  51356. /**
  51357. * Not supported by GPUParticleSystem
  51358. * @param gradient defines the gradient to use (between 0 and 1)
  51359. * @param color defines the color to affect to the specified gradient
  51360. * @returns the current particle system
  51361. */
  51362. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51363. /**
  51364. * Not supported by GPUParticleSystem
  51365. * @param gradient defines the gradient to remove
  51366. * @returns the current particle system
  51367. */
  51368. removeRampGradient(): IParticleSystem;
  51369. /**
  51370. * Not supported by GPUParticleSystem
  51371. * @returns the list of ramp gradients
  51372. */
  51373. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51374. /**
  51375. * Not supported by GPUParticleSystem
  51376. * Gets or sets a boolean indicating that ramp gradients must be used
  51377. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51378. */
  51379. useRampGradients: boolean;
  51380. /**
  51381. * Not supported by GPUParticleSystem
  51382. * @param gradient defines the gradient to use (between 0 and 1)
  51383. * @param factor defines the life time factor to affect to the specified gradient
  51384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51385. * @returns the current particle system
  51386. */
  51387. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51388. /**
  51389. * Not supported by GPUParticleSystem
  51390. * @param gradient defines the gradient to remove
  51391. * @returns the current particle system
  51392. */
  51393. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51394. /**
  51395. * Instantiates a GPU particle system.
  51396. * 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.
  51397. * @param name The name of the particle system
  51398. * @param options The options used to create the system
  51399. * @param scene The scene the particle system belongs to
  51400. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51401. */
  51402. constructor(name: string, options: Partial<{
  51403. capacity: number;
  51404. randomTextureSize: number;
  51405. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51406. protected _reset(): void;
  51407. private _createUpdateVAO;
  51408. private _createRenderVAO;
  51409. private _initialize;
  51410. /** @hidden */
  51411. _recreateUpdateEffect(): void;
  51412. /** @hidden */
  51413. _recreateRenderEffect(): void;
  51414. /**
  51415. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51416. * @param preWarm defines if we are in the pre-warmimg phase
  51417. */
  51418. animate(preWarm?: boolean): void;
  51419. private _createFactorGradientTexture;
  51420. private _createSizeGradientTexture;
  51421. private _createAngularSpeedGradientTexture;
  51422. private _createVelocityGradientTexture;
  51423. private _createLimitVelocityGradientTexture;
  51424. private _createDragGradientTexture;
  51425. private _createColorGradientTexture;
  51426. /**
  51427. * Renders the particle system in its current state
  51428. * @param preWarm defines if the system should only update the particles but not render them
  51429. * @returns the current number of particles
  51430. */
  51431. render(preWarm?: boolean): number;
  51432. /**
  51433. * Rebuilds the particle system
  51434. */
  51435. rebuild(): void;
  51436. private _releaseBuffers;
  51437. private _releaseVAOs;
  51438. /**
  51439. * Disposes the particle system and free the associated resources
  51440. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51441. */
  51442. dispose(disposeTexture?: boolean): void;
  51443. /**
  51444. * Clones the particle system.
  51445. * @param name The name of the cloned object
  51446. * @param newEmitter The new emitter to use
  51447. * @returns the cloned particle system
  51448. */
  51449. clone(name: string, newEmitter: any): GPUParticleSystem;
  51450. /**
  51451. * Serializes the particle system to a JSON object.
  51452. * @returns the JSON object
  51453. */
  51454. serialize(): any;
  51455. /**
  51456. * Parses a JSON object to create a GPU particle system.
  51457. * @param parsedParticleSystem The JSON object to parse
  51458. * @param scene The scene to create the particle system in
  51459. * @param rootUrl The root url to use to load external dependencies like texture
  51460. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51461. * @returns the parsed GPU particle system
  51462. */
  51463. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51464. }
  51465. }
  51466. declare module "babylonjs/Particles/particleSystemSet" {
  51467. import { Nullable } from "babylonjs/types";
  51468. import { Color3 } from "babylonjs/Maths/math";
  51469. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51471. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51472. import { Scene, IDisposable } from "babylonjs/scene";
  51473. /**
  51474. * Represents a set of particle systems working together to create a specific effect
  51475. */
  51476. export class ParticleSystemSet implements IDisposable {
  51477. private _emitterCreationOptions;
  51478. private _emitterNode;
  51479. /**
  51480. * Gets the particle system list
  51481. */
  51482. systems: IParticleSystem[];
  51483. /**
  51484. * Gets the emitter node used with this set
  51485. */
  51486. readonly emitterNode: Nullable<TransformNode>;
  51487. /**
  51488. * Creates a new emitter mesh as a sphere
  51489. * @param options defines the options used to create the sphere
  51490. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51491. * @param scene defines the hosting scene
  51492. */
  51493. setEmitterAsSphere(options: {
  51494. diameter: number;
  51495. segments: number;
  51496. color: Color3;
  51497. }, renderingGroupId: number, scene: Scene): void;
  51498. /**
  51499. * Starts all particle systems of the set
  51500. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51501. */
  51502. start(emitter?: AbstractMesh): void;
  51503. /**
  51504. * Release all associated resources
  51505. */
  51506. dispose(): void;
  51507. /**
  51508. * Serialize the set into a JSON compatible object
  51509. * @returns a JSON compatible representation of the set
  51510. */
  51511. serialize(): any;
  51512. /**
  51513. * Parse a new ParticleSystemSet from a serialized source
  51514. * @param data defines a JSON compatible representation of the set
  51515. * @param scene defines the hosting scene
  51516. * @param gpu defines if we want GPU particles or CPU particles
  51517. * @returns a new ParticleSystemSet
  51518. */
  51519. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51520. }
  51521. }
  51522. declare module "babylonjs/Particles/particleHelper" {
  51523. import { Nullable } from "babylonjs/types";
  51524. import { Scene } from "babylonjs/scene";
  51525. import { Vector3 } from "babylonjs/Maths/math";
  51526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51527. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51528. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51529. /**
  51530. * This class is made for on one-liner static method to help creating particle system set.
  51531. */
  51532. export class ParticleHelper {
  51533. /**
  51534. * Gets or sets base Assets URL
  51535. */
  51536. static BaseAssetsUrl: string;
  51537. /**
  51538. * Create a default particle system that you can tweak
  51539. * @param emitter defines the emitter to use
  51540. * @param capacity defines the system capacity (default is 500 particles)
  51541. * @param scene defines the hosting scene
  51542. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51543. * @returns the new Particle system
  51544. */
  51545. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51546. /**
  51547. * This is the main static method (one-liner) of this helper to create different particle systems
  51548. * @param type This string represents the type to the particle system to create
  51549. * @param scene The scene where the particle system should live
  51550. * @param gpu If the system will use gpu
  51551. * @returns the ParticleSystemSet created
  51552. */
  51553. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51554. /**
  51555. * Static function used to export a particle system to a ParticleSystemSet variable.
  51556. * Please note that the emitter shape is not exported
  51557. * @param systems defines the particle systems to export
  51558. * @returns the created particle system set
  51559. */
  51560. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51561. }
  51562. }
  51563. declare module "babylonjs/Particles/particleSystemComponent" {
  51564. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51565. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51566. import "babylonjs/Shaders/particles.vertex";
  51567. module "babylonjs/Engines/engine" {
  51568. interface Engine {
  51569. /**
  51570. * Create an effect to use with particle systems.
  51571. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51572. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51573. * @param uniformsNames defines a list of attribute names
  51574. * @param samplers defines an array of string used to represent textures
  51575. * @param defines defines the string containing the defines to use to compile the shaders
  51576. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51577. * @param onCompiled defines a function to call when the effect creation is successful
  51578. * @param onError defines a function to call when the effect creation has failed
  51579. * @returns the new Effect
  51580. */
  51581. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51582. }
  51583. }
  51584. module "babylonjs/Meshes/mesh" {
  51585. interface Mesh {
  51586. /**
  51587. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51588. * @returns an array of IParticleSystem
  51589. */
  51590. getEmittedParticleSystems(): IParticleSystem[];
  51591. /**
  51592. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51593. * @returns an array of IParticleSystem
  51594. */
  51595. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51596. }
  51597. }
  51598. /**
  51599. * @hidden
  51600. */
  51601. export var _IDoNeedToBeInTheBuild: number;
  51602. }
  51603. declare module "babylonjs/Particles/index" {
  51604. export * from "babylonjs/Particles/baseParticleSystem";
  51605. export * from "babylonjs/Particles/EmitterTypes/index";
  51606. export * from "babylonjs/Particles/gpuParticleSystem";
  51607. export * from "babylonjs/Particles/IParticleSystem";
  51608. export * from "babylonjs/Particles/particle";
  51609. export * from "babylonjs/Particles/particleHelper";
  51610. export * from "babylonjs/Particles/particleSystem";
  51611. export * from "babylonjs/Particles/particleSystemComponent";
  51612. export * from "babylonjs/Particles/particleSystemSet";
  51613. export * from "babylonjs/Particles/solidParticle";
  51614. export * from "babylonjs/Particles/solidParticleSystem";
  51615. export * from "babylonjs/Particles/subEmitter";
  51616. }
  51617. declare module "babylonjs/Physics/physicsEngineComponent" {
  51618. import { Nullable } from "babylonjs/types";
  51619. import { Observable, Observer } from "babylonjs/Misc/observable";
  51620. import { Vector3 } from "babylonjs/Maths/math";
  51621. import { Mesh } from "babylonjs/Meshes/mesh";
  51622. import { ISceneComponent } from "babylonjs/sceneComponent";
  51623. import { Scene } from "babylonjs/scene";
  51624. import { Node } from "babylonjs/node";
  51625. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51626. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51627. module "babylonjs/scene" {
  51628. interface Scene {
  51629. /** @hidden (Backing field) */
  51630. _physicsEngine: Nullable<IPhysicsEngine>;
  51631. /**
  51632. * Gets the current physics engine
  51633. * @returns a IPhysicsEngine or null if none attached
  51634. */
  51635. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51636. /**
  51637. * Enables physics to the current scene
  51638. * @param gravity defines the scene's gravity for the physics engine
  51639. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51640. * @return a boolean indicating if the physics engine was initialized
  51641. */
  51642. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51643. /**
  51644. * Disables and disposes the physics engine associated with the scene
  51645. */
  51646. disablePhysicsEngine(): void;
  51647. /**
  51648. * Gets a boolean indicating if there is an active physics engine
  51649. * @returns a boolean indicating if there is an active physics engine
  51650. */
  51651. isPhysicsEnabled(): boolean;
  51652. /**
  51653. * Deletes a physics compound impostor
  51654. * @param compound defines the compound to delete
  51655. */
  51656. deleteCompoundImpostor(compound: any): void;
  51657. /**
  51658. * An event triggered when physic simulation is about to be run
  51659. */
  51660. onBeforePhysicsObservable: Observable<Scene>;
  51661. /**
  51662. * An event triggered when physic simulation has been done
  51663. */
  51664. onAfterPhysicsObservable: Observable<Scene>;
  51665. }
  51666. }
  51667. module "babylonjs/Meshes/abstractMesh" {
  51668. interface AbstractMesh {
  51669. /** @hidden */
  51670. _physicsImpostor: Nullable<PhysicsImpostor>;
  51671. /**
  51672. * Gets or sets impostor used for physic simulation
  51673. * @see http://doc.babylonjs.com/features/physics_engine
  51674. */
  51675. physicsImpostor: Nullable<PhysicsImpostor>;
  51676. /**
  51677. * Gets the current physics impostor
  51678. * @see http://doc.babylonjs.com/features/physics_engine
  51679. * @returns a physics impostor or null
  51680. */
  51681. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51682. /** Apply a physic impulse to the mesh
  51683. * @param force defines the force to apply
  51684. * @param contactPoint defines where to apply the force
  51685. * @returns the current mesh
  51686. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51687. */
  51688. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51689. /**
  51690. * Creates a physic joint between two meshes
  51691. * @param otherMesh defines the other mesh to use
  51692. * @param pivot1 defines the pivot to use on this mesh
  51693. * @param pivot2 defines the pivot to use on the other mesh
  51694. * @param options defines additional options (can be plugin dependent)
  51695. * @returns the current mesh
  51696. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51697. */
  51698. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51699. /** @hidden */
  51700. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51701. }
  51702. }
  51703. /**
  51704. * Defines the physics engine scene component responsible to manage a physics engine
  51705. */
  51706. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51707. /**
  51708. * The component name helpful to identify the component in the list of scene components.
  51709. */
  51710. readonly name: string;
  51711. /**
  51712. * The scene the component belongs to.
  51713. */
  51714. scene: Scene;
  51715. /**
  51716. * Creates a new instance of the component for the given scene
  51717. * @param scene Defines the scene to register the component in
  51718. */
  51719. constructor(scene: Scene);
  51720. /**
  51721. * Registers the component in a given scene
  51722. */
  51723. register(): void;
  51724. /**
  51725. * Rebuilds the elements related to this component in case of
  51726. * context lost for instance.
  51727. */
  51728. rebuild(): void;
  51729. /**
  51730. * Disposes the component and the associated ressources
  51731. */
  51732. dispose(): void;
  51733. }
  51734. }
  51735. declare module "babylonjs/Physics/physicsHelper" {
  51736. import { Nullable } from "babylonjs/types";
  51737. import { Vector3 } from "babylonjs/Maths/math";
  51738. import { Mesh } from "babylonjs/Meshes/mesh";
  51739. import { Ray } from "babylonjs/Culling/ray";
  51740. import { Scene } from "babylonjs/scene";
  51741. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51742. /**
  51743. * A helper for physics simulations
  51744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51745. */
  51746. export class PhysicsHelper {
  51747. private _scene;
  51748. private _physicsEngine;
  51749. /**
  51750. * Initializes the Physics helper
  51751. * @param scene Babylon.js scene
  51752. */
  51753. constructor(scene: Scene);
  51754. /**
  51755. * Applies a radial explosion impulse
  51756. * @param origin the origin of the explosion
  51757. * @param radius the explosion radius
  51758. * @param strength the explosion strength
  51759. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51760. * @returns A physics radial explosion event, or null
  51761. */
  51762. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51763. /**
  51764. * Applies a radial explosion force
  51765. * @param origin the origin of the explosion
  51766. * @param radius the explosion radius
  51767. * @param strength the explosion strength
  51768. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51769. * @returns A physics radial explosion event, or null
  51770. */
  51771. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51772. /**
  51773. * Creates a gravitational field
  51774. * @param origin the origin of the explosion
  51775. * @param radius the explosion radius
  51776. * @param strength the explosion strength
  51777. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51778. * @returns A physics gravitational field event, or null
  51779. */
  51780. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51781. /**
  51782. * Creates a physics updraft event
  51783. * @param origin the origin of the updraft
  51784. * @param radius the radius of the updraft
  51785. * @param strength the strength of the updraft
  51786. * @param height the height of the updraft
  51787. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51788. * @returns A physics updraft event, or null
  51789. */
  51790. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51791. /**
  51792. * Creates a physics vortex event
  51793. * @param origin the of the vortex
  51794. * @param radius the radius of the vortex
  51795. * @param strength the strength of the vortex
  51796. * @param height the height of the vortex
  51797. * @returns a Physics vortex event, or null
  51798. * A physics vortex event or null
  51799. */
  51800. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  51801. }
  51802. /**
  51803. * Represents a physics radial explosion event
  51804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51805. */
  51806. export class PhysicsRadialExplosionEvent {
  51807. private _scene;
  51808. private _sphere;
  51809. private _sphereOptions;
  51810. private _rays;
  51811. private _dataFetched;
  51812. /**
  51813. * Initializes a radial explosioin event
  51814. * @param scene BabylonJS scene
  51815. */
  51816. constructor(scene: Scene);
  51817. /**
  51818. * Returns the data related to the radial explosion event (sphere & rays).
  51819. * @returns The radial explosion event data
  51820. */
  51821. getData(): PhysicsRadialExplosionEventData;
  51822. /**
  51823. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51824. * @param impostor A physics imposter
  51825. * @param origin the origin of the explosion
  51826. * @param radius the explosion radius
  51827. * @param strength the explosion strength
  51828. * @param falloff possible options: Constant & Linear
  51829. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  51830. */
  51831. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  51832. /**
  51833. * Disposes the sphere.
  51834. * @param force Specifies if the sphere should be disposed by force
  51835. */
  51836. dispose(force?: boolean): void;
  51837. /*** Helpers ***/
  51838. private _prepareSphere;
  51839. private _intersectsWithSphere;
  51840. }
  51841. /**
  51842. * Represents a gravitational field event
  51843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51844. */
  51845. export class PhysicsGravitationalFieldEvent {
  51846. private _physicsHelper;
  51847. private _scene;
  51848. private _origin;
  51849. private _radius;
  51850. private _strength;
  51851. private _falloff;
  51852. private _tickCallback;
  51853. private _sphere;
  51854. private _dataFetched;
  51855. /**
  51856. * Initializes the physics gravitational field event
  51857. * @param physicsHelper A physics helper
  51858. * @param scene BabylonJS scene
  51859. * @param origin The origin position of the gravitational field event
  51860. * @param radius The radius of the gravitational field event
  51861. * @param strength The strength of the gravitational field event
  51862. * @param falloff The falloff for the gravitational field event
  51863. */
  51864. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  51865. /**
  51866. * Returns the data related to the gravitational field event (sphere).
  51867. * @returns A gravitational field event
  51868. */
  51869. getData(): PhysicsGravitationalFieldEventData;
  51870. /**
  51871. * Enables the gravitational field.
  51872. */
  51873. enable(): void;
  51874. /**
  51875. * Disables the gravitational field.
  51876. */
  51877. disable(): void;
  51878. /**
  51879. * Disposes the sphere.
  51880. * @param force The force to dispose from the gravitational field event
  51881. */
  51882. dispose(force?: boolean): void;
  51883. private _tick;
  51884. }
  51885. /**
  51886. * Represents a physics updraft event
  51887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51888. */
  51889. export class PhysicsUpdraftEvent {
  51890. private _scene;
  51891. private _origin;
  51892. private _radius;
  51893. private _strength;
  51894. private _height;
  51895. private _updraftMode;
  51896. private _physicsEngine;
  51897. private _originTop;
  51898. private _originDirection;
  51899. private _tickCallback;
  51900. private _cylinder;
  51901. private _cylinderPosition;
  51902. private _dataFetched;
  51903. /**
  51904. * Initializes the physics updraft event
  51905. * @param _scene BabylonJS scene
  51906. * @param _origin The origin position of the updraft
  51907. * @param _radius The radius of the updraft
  51908. * @param _strength The strength of the updraft
  51909. * @param _height The height of the updraft
  51910. * @param _updraftMode The mode of the updraft
  51911. */
  51912. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  51913. /**
  51914. * Returns the data related to the updraft event (cylinder).
  51915. * @returns A physics updraft event
  51916. */
  51917. getData(): PhysicsUpdraftEventData;
  51918. /**
  51919. * Enables the updraft.
  51920. */
  51921. enable(): void;
  51922. /**
  51923. * Disables the cortex.
  51924. */
  51925. disable(): void;
  51926. /**
  51927. * Disposes the sphere.
  51928. * @param force Specifies if the updraft should be disposed by force
  51929. */
  51930. dispose(force?: boolean): void;
  51931. private getImpostorForceAndContactPoint;
  51932. private _tick;
  51933. /*** Helpers ***/
  51934. private _prepareCylinder;
  51935. private _intersectsWithCylinder;
  51936. }
  51937. /**
  51938. * Represents a physics vortex event
  51939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51940. */
  51941. export class PhysicsVortexEvent {
  51942. private _scene;
  51943. private _origin;
  51944. private _radius;
  51945. private _strength;
  51946. private _height;
  51947. private _physicsEngine;
  51948. private _originTop;
  51949. private _centripetalForceThreshold;
  51950. private _updraftMultiplier;
  51951. private _tickCallback;
  51952. private _cylinder;
  51953. private _cylinderPosition;
  51954. private _dataFetched;
  51955. /**
  51956. * Initializes the physics vortex event
  51957. * @param _scene The BabylonJS scene
  51958. * @param _origin The origin position of the vortex
  51959. * @param _radius The radius of the vortex
  51960. * @param _strength The strength of the vortex
  51961. * @param _height The height of the vortex
  51962. */
  51963. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51964. /**
  51965. * Returns the data related to the vortex event (cylinder).
  51966. * @returns The physics vortex event data
  51967. */
  51968. getData(): PhysicsVortexEventData;
  51969. /**
  51970. * Enables the vortex.
  51971. */
  51972. enable(): void;
  51973. /**
  51974. * Disables the cortex.
  51975. */
  51976. disable(): void;
  51977. /**
  51978. * Disposes the sphere.
  51979. * @param force
  51980. */
  51981. dispose(force?: boolean): void;
  51982. private getImpostorForceAndContactPoint;
  51983. private _tick;
  51984. /*** Helpers ***/
  51985. private _prepareCylinder;
  51986. private _intersectsWithCylinder;
  51987. }
  51988. /**
  51989. * The strenght of the force in correspondence to the distance of the affected object
  51990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51991. */
  51992. export enum PhysicsRadialImpulseFalloff {
  51993. /** Defines that impulse is constant in strength across it's whole radius */
  51994. Constant = 0,
  51995. /** DEfines that impulse gets weaker if it's further from the origin */
  51996. Linear = 1
  51997. }
  51998. /**
  51999. * The strength of the force in correspondence to the distance of the affected object
  52000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52001. */
  52002. export enum PhysicsUpdraftMode {
  52003. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52004. Center = 0,
  52005. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52006. Perpendicular = 1
  52007. }
  52008. /**
  52009. * Interface for a physics force and contact point
  52010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52011. */
  52012. export interface PhysicsForceAndContactPoint {
  52013. /**
  52014. * The force applied at the contact point
  52015. */
  52016. force: Vector3;
  52017. /**
  52018. * The contact point
  52019. */
  52020. contactPoint: Vector3;
  52021. }
  52022. /**
  52023. * Interface for radial explosion event data
  52024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52025. */
  52026. export interface PhysicsRadialExplosionEventData {
  52027. /**
  52028. * A sphere used for the radial explosion event
  52029. */
  52030. sphere: Mesh;
  52031. /**
  52032. * An array of rays for the radial explosion event
  52033. */
  52034. rays: Array<Ray>;
  52035. }
  52036. /**
  52037. * Interface for gravitational field event data
  52038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52039. */
  52040. export interface PhysicsGravitationalFieldEventData {
  52041. /**
  52042. * A sphere mesh used for the gravitational field event
  52043. */
  52044. sphere: Mesh;
  52045. }
  52046. /**
  52047. * Interface for updraft event data
  52048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52049. */
  52050. export interface PhysicsUpdraftEventData {
  52051. /**
  52052. * A cylinder used for the updraft event
  52053. */
  52054. cylinder: Mesh;
  52055. }
  52056. /**
  52057. * Interface for vortex event data
  52058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52059. */
  52060. export interface PhysicsVortexEventData {
  52061. /**
  52062. * A cylinder used for the vortex event
  52063. */
  52064. cylinder: Mesh;
  52065. }
  52066. }
  52067. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52068. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52069. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52070. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52071. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52072. import { Nullable } from "babylonjs/types";
  52073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52074. /**
  52075. * AmmoJS Physics plugin
  52076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52077. * @see https://github.com/kripken/ammo.js/
  52078. */
  52079. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52080. private _useDeltaForWorldStep;
  52081. /**
  52082. * Reference to the Ammo library
  52083. */
  52084. bjsAMMO: any;
  52085. /**
  52086. * Created ammoJS world which physics bodies are added to
  52087. */
  52088. world: any;
  52089. /**
  52090. * Name of the plugin
  52091. */
  52092. name: string;
  52093. private _timeStep;
  52094. private _fixedTimeStep;
  52095. private _maxSteps;
  52096. private _tmpQuaternion;
  52097. private _tmpAmmoTransform;
  52098. private _tmpAmmoQuaternion;
  52099. private _tmpAmmoConcreteContactResultCallback;
  52100. private _collisionConfiguration;
  52101. private _dispatcher;
  52102. private _overlappingPairCache;
  52103. private _solver;
  52104. private _tmpAmmoVectorA;
  52105. private _tmpAmmoVectorB;
  52106. private _tmpAmmoVectorC;
  52107. private _tmpContactCallbackResult;
  52108. private static readonly DISABLE_COLLISION_FLAG;
  52109. private static readonly KINEMATIC_FLAG;
  52110. private static readonly DISABLE_DEACTIVATION_FLAG;
  52111. /**
  52112. * Initializes the ammoJS plugin
  52113. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52114. * @param ammoInjection can be used to inject your own ammo reference
  52115. */
  52116. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52117. /**
  52118. * Sets the gravity of the physics world (m/(s^2))
  52119. * @param gravity Gravity to set
  52120. */
  52121. setGravity(gravity: Vector3): void;
  52122. /**
  52123. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52124. * @param timeStep timestep to use in seconds
  52125. */
  52126. setTimeStep(timeStep: number): void;
  52127. /**
  52128. * 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)
  52129. * @param fixedTimeStep fixedTimeStep to use in seconds
  52130. */
  52131. setFixedTimeStep(fixedTimeStep: number): void;
  52132. /**
  52133. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52134. * @param maxSteps the maximum number of steps by the physics engine per frame
  52135. */
  52136. setMaxSteps(maxSteps: number): void;
  52137. /**
  52138. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52139. * @returns the current timestep in seconds
  52140. */
  52141. getTimeStep(): number;
  52142. private _isImpostorInContact;
  52143. private _isImpostorPairInContact;
  52144. private _stepSimulation;
  52145. /**
  52146. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52147. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52148. * After the step the babylon meshes are set to the position of the physics imposters
  52149. * @param delta amount of time to step forward
  52150. * @param impostors array of imposters to update before/after the step
  52151. */
  52152. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52153. private _tmpVector;
  52154. private _tmpMatrix;
  52155. /**
  52156. * Applies an implulse on the imposter
  52157. * @param impostor imposter to apply impulse
  52158. * @param force amount of force to be applied to the imposter
  52159. * @param contactPoint the location to apply the impulse on the imposter
  52160. */
  52161. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52162. /**
  52163. * Applies a force on the imposter
  52164. * @param impostor imposter to apply force
  52165. * @param force amount of force to be applied to the imposter
  52166. * @param contactPoint the location to apply the force on the imposter
  52167. */
  52168. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52169. /**
  52170. * Creates a physics body using the plugin
  52171. * @param impostor the imposter to create the physics body on
  52172. */
  52173. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52174. /**
  52175. * Removes the physics body from the imposter and disposes of the body's memory
  52176. * @param impostor imposter to remove the physics body from
  52177. */
  52178. removePhysicsBody(impostor: PhysicsImpostor): void;
  52179. /**
  52180. * Generates a joint
  52181. * @param impostorJoint the imposter joint to create the joint with
  52182. */
  52183. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52184. /**
  52185. * Removes a joint
  52186. * @param impostorJoint the imposter joint to remove the joint from
  52187. */
  52188. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52189. private _addMeshVerts;
  52190. private _createShape;
  52191. /**
  52192. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52193. * @param impostor imposter containing the physics body and babylon object
  52194. */
  52195. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52196. /**
  52197. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52198. * @param impostor imposter containing the physics body and babylon object
  52199. * @param newPosition new position
  52200. * @param newRotation new rotation
  52201. */
  52202. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52203. /**
  52204. * If this plugin is supported
  52205. * @returns true if its supported
  52206. */
  52207. isSupported(): boolean;
  52208. /**
  52209. * Sets the linear velocity of the physics body
  52210. * @param impostor imposter to set the velocity on
  52211. * @param velocity velocity to set
  52212. */
  52213. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52214. /**
  52215. * Sets the angular velocity of the physics body
  52216. * @param impostor imposter to set the velocity on
  52217. * @param velocity velocity to set
  52218. */
  52219. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52220. /**
  52221. * gets the linear velocity
  52222. * @param impostor imposter to get linear velocity from
  52223. * @returns linear velocity
  52224. */
  52225. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52226. /**
  52227. * gets the angular velocity
  52228. * @param impostor imposter to get angular velocity from
  52229. * @returns angular velocity
  52230. */
  52231. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52232. /**
  52233. * Sets the mass of physics body
  52234. * @param impostor imposter to set the mass on
  52235. * @param mass mass to set
  52236. */
  52237. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52238. /**
  52239. * Gets the mass of the physics body
  52240. * @param impostor imposter to get the mass from
  52241. * @returns mass
  52242. */
  52243. getBodyMass(impostor: PhysicsImpostor): number;
  52244. /**
  52245. * Gets friction of the impostor
  52246. * @param impostor impostor to get friction from
  52247. * @returns friction value
  52248. */
  52249. getBodyFriction(impostor: PhysicsImpostor): number;
  52250. /**
  52251. * Sets friction of the impostor
  52252. * @param impostor impostor to set friction on
  52253. * @param friction friction value
  52254. */
  52255. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52256. /**
  52257. * Gets restitution of the impostor
  52258. * @param impostor impostor to get restitution from
  52259. * @returns restitution value
  52260. */
  52261. getBodyRestitution(impostor: PhysicsImpostor): number;
  52262. /**
  52263. * Sets resitution of the impostor
  52264. * @param impostor impostor to set resitution on
  52265. * @param restitution resitution value
  52266. */
  52267. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52268. /**
  52269. * Sleeps the physics body and stops it from being active
  52270. * @param impostor impostor to sleep
  52271. */
  52272. sleepBody(impostor: PhysicsImpostor): void;
  52273. /**
  52274. * Activates the physics body
  52275. * @param impostor impostor to activate
  52276. */
  52277. wakeUpBody(impostor: PhysicsImpostor): void;
  52278. /**
  52279. * Updates the distance parameters of the joint
  52280. * @param joint joint to update
  52281. * @param maxDistance maximum distance of the joint
  52282. * @param minDistance minimum distance of the joint
  52283. */
  52284. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52285. /**
  52286. * Sets a motor on the joint
  52287. * @param joint joint to set motor on
  52288. * @param speed speed of the motor
  52289. * @param maxForce maximum force of the motor
  52290. * @param motorIndex index of the motor
  52291. */
  52292. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52293. /**
  52294. * Sets the motors limit
  52295. * @param joint joint to set limit on
  52296. * @param upperLimit upper limit
  52297. * @param lowerLimit lower limit
  52298. */
  52299. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52300. /**
  52301. * Syncs the position and rotation of a mesh with the impostor
  52302. * @param mesh mesh to sync
  52303. * @param impostor impostor to update the mesh with
  52304. */
  52305. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52306. /**
  52307. * Gets the radius of the impostor
  52308. * @param impostor impostor to get radius from
  52309. * @returns the radius
  52310. */
  52311. getRadius(impostor: PhysicsImpostor): number;
  52312. /**
  52313. * Gets the box size of the impostor
  52314. * @param impostor impostor to get box size from
  52315. * @param result the resulting box size
  52316. */
  52317. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52318. /**
  52319. * Disposes of the impostor
  52320. */
  52321. dispose(): void;
  52322. }
  52323. }
  52324. declare module "babylonjs/Physics/Plugins/index" {
  52325. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52326. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52327. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52328. }
  52329. declare module "babylonjs/Physics/index" {
  52330. export * from "babylonjs/Physics/IPhysicsEngine";
  52331. export * from "babylonjs/Physics/physicsEngine";
  52332. export * from "babylonjs/Physics/physicsEngineComponent";
  52333. export * from "babylonjs/Physics/physicsHelper";
  52334. export * from "babylonjs/Physics/physicsImpostor";
  52335. export * from "babylonjs/Physics/physicsJoint";
  52336. export * from "babylonjs/Physics/Plugins/index";
  52337. }
  52338. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52339. /** @hidden */
  52340. export var blackAndWhitePixelShader: {
  52341. name: string;
  52342. shader: string;
  52343. };
  52344. }
  52345. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52346. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52347. import { Camera } from "babylonjs/Cameras/camera";
  52348. import { Engine } from "babylonjs/Engines/engine";
  52349. import "babylonjs/Shaders/blackAndWhite.fragment";
  52350. /**
  52351. * Post process used to render in black and white
  52352. */
  52353. export class BlackAndWhitePostProcess extends PostProcess {
  52354. /**
  52355. * Linear about to convert he result to black and white (default: 1)
  52356. */
  52357. degree: number;
  52358. /**
  52359. * Creates a black and white post process
  52360. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52361. * @param name The name of the effect.
  52362. * @param options The required width/height ratio to downsize to before computing the render pass.
  52363. * @param camera The camera to apply the render pass to.
  52364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52365. * @param engine The engine which the post process will be applied. (default: current engine)
  52366. * @param reusable If the post process can be reused on the same frame. (default: false)
  52367. */
  52368. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52369. }
  52370. }
  52371. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52372. import { Nullable } from "babylonjs/types";
  52373. import { Camera } from "babylonjs/Cameras/camera";
  52374. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52375. import { Engine } from "babylonjs/Engines/engine";
  52376. /**
  52377. * This represents a set of one or more post processes in Babylon.
  52378. * A post process can be used to apply a shader to a texture after it is rendered.
  52379. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52380. */
  52381. export class PostProcessRenderEffect {
  52382. private _postProcesses;
  52383. private _getPostProcesses;
  52384. private _singleInstance;
  52385. private _cameras;
  52386. private _indicesForCamera;
  52387. /**
  52388. * Name of the effect
  52389. * @hidden
  52390. */
  52391. _name: string;
  52392. /**
  52393. * Instantiates a post process render effect.
  52394. * A post process can be used to apply a shader to a texture after it is rendered.
  52395. * @param engine The engine the effect is tied to
  52396. * @param name The name of the effect
  52397. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52398. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52399. */
  52400. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52401. /**
  52402. * Checks if all the post processes in the effect are supported.
  52403. */
  52404. readonly isSupported: boolean;
  52405. /**
  52406. * Updates the current state of the effect
  52407. * @hidden
  52408. */
  52409. _update(): void;
  52410. /**
  52411. * Attaches the effect on cameras
  52412. * @param cameras The camera to attach to.
  52413. * @hidden
  52414. */
  52415. _attachCameras(cameras: Camera): void;
  52416. /**
  52417. * Attaches the effect on cameras
  52418. * @param cameras The camera to attach to.
  52419. * @hidden
  52420. */
  52421. _attachCameras(cameras: Camera[]): void;
  52422. /**
  52423. * Detatches the effect on cameras
  52424. * @param cameras The camera to detatch from.
  52425. * @hidden
  52426. */
  52427. _detachCameras(cameras: Camera): void;
  52428. /**
  52429. * Detatches the effect on cameras
  52430. * @param cameras The camera to detatch from.
  52431. * @hidden
  52432. */
  52433. _detachCameras(cameras: Camera[]): void;
  52434. /**
  52435. * Enables the effect on given cameras
  52436. * @param cameras The camera to enable.
  52437. * @hidden
  52438. */
  52439. _enable(cameras: Camera): void;
  52440. /**
  52441. * Enables the effect on given cameras
  52442. * @param cameras The camera to enable.
  52443. * @hidden
  52444. */
  52445. _enable(cameras: Nullable<Camera[]>): void;
  52446. /**
  52447. * Disables the effect on the given cameras
  52448. * @param cameras The camera to disable.
  52449. * @hidden
  52450. */
  52451. _disable(cameras: Camera): void;
  52452. /**
  52453. * Disables the effect on the given cameras
  52454. * @param cameras The camera to disable.
  52455. * @hidden
  52456. */
  52457. _disable(cameras: Nullable<Camera[]>): void;
  52458. /**
  52459. * Gets a list of the post processes contained in the effect.
  52460. * @param camera The camera to get the post processes on.
  52461. * @returns The list of the post processes in the effect.
  52462. */
  52463. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52464. }
  52465. }
  52466. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52467. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52468. /** @hidden */
  52469. export var extractHighlightsPixelShader: {
  52470. name: string;
  52471. shader: string;
  52472. };
  52473. }
  52474. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52475. import { Nullable } from "babylonjs/types";
  52476. import { Camera } from "babylonjs/Cameras/camera";
  52477. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52478. import { Engine } from "babylonjs/Engines/engine";
  52479. import "babylonjs/Shaders/extractHighlights.fragment";
  52480. /**
  52481. * 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.
  52482. */
  52483. export class ExtractHighlightsPostProcess extends PostProcess {
  52484. /**
  52485. * The luminance threshold, pixels below this value will be set to black.
  52486. */
  52487. threshold: number;
  52488. /** @hidden */
  52489. _exposure: number;
  52490. /**
  52491. * Post process which has the input texture to be used when performing highlight extraction
  52492. * @hidden
  52493. */
  52494. _inputPostProcess: Nullable<PostProcess>;
  52495. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52496. }
  52497. }
  52498. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52499. /** @hidden */
  52500. export var bloomMergePixelShader: {
  52501. name: string;
  52502. shader: string;
  52503. };
  52504. }
  52505. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52506. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52507. import { Nullable } from "babylonjs/types";
  52508. import { Engine } from "babylonjs/Engines/engine";
  52509. import { Camera } from "babylonjs/Cameras/camera";
  52510. import "babylonjs/Shaders/bloomMerge.fragment";
  52511. /**
  52512. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52513. */
  52514. export class BloomMergePostProcess extends PostProcess {
  52515. /** Weight of the bloom to be added to the original input. */
  52516. weight: number;
  52517. /**
  52518. * Creates a new instance of @see BloomMergePostProcess
  52519. * @param name The name of the effect.
  52520. * @param originalFromInput Post process which's input will be used for the merge.
  52521. * @param blurred Blurred highlights post process which's output will be used.
  52522. * @param weight Weight of the bloom to be added to the original input.
  52523. * @param options The required width/height ratio to downsize to before computing the render pass.
  52524. * @param camera The camera to apply the render pass to.
  52525. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52526. * @param engine The engine which the post process will be applied. (default: current engine)
  52527. * @param reusable If the post process can be reused on the same frame. (default: false)
  52528. * @param textureType Type of textures used when performing the post process. (default: 0)
  52529. * @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)
  52530. */
  52531. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52532. /** Weight of the bloom to be added to the original input. */
  52533. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52534. }
  52535. }
  52536. declare module "babylonjs/PostProcesses/bloomEffect" {
  52537. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52538. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52539. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52540. import { Camera } from "babylonjs/Cameras/camera";
  52541. import { Scene } from "babylonjs/scene";
  52542. /**
  52543. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52544. */
  52545. export class BloomEffect extends PostProcessRenderEffect {
  52546. private bloomScale;
  52547. /**
  52548. * @hidden Internal
  52549. */
  52550. _effects: Array<PostProcess>;
  52551. /**
  52552. * @hidden Internal
  52553. */
  52554. _downscale: ExtractHighlightsPostProcess;
  52555. private _blurX;
  52556. private _blurY;
  52557. private _merge;
  52558. /**
  52559. * The luminance threshold to find bright areas of the image to bloom.
  52560. */
  52561. threshold: number;
  52562. /**
  52563. * The strength of the bloom.
  52564. */
  52565. weight: number;
  52566. /**
  52567. * Specifies the size of the bloom blur kernel, relative to the final output size
  52568. */
  52569. kernel: number;
  52570. /**
  52571. * Creates a new instance of @see BloomEffect
  52572. * @param scene The scene the effect belongs to.
  52573. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52574. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52575. * @param bloomWeight The the strength of bloom.
  52576. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52577. * @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)
  52578. */
  52579. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52580. /**
  52581. * Disposes each of the internal effects for a given camera.
  52582. * @param camera The camera to dispose the effect on.
  52583. */
  52584. disposeEffects(camera: Camera): void;
  52585. /**
  52586. * @hidden Internal
  52587. */
  52588. _updateEffects(): void;
  52589. /**
  52590. * Internal
  52591. * @returns if all the contained post processes are ready.
  52592. * @hidden
  52593. */
  52594. _isReady(): boolean;
  52595. }
  52596. }
  52597. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52598. /** @hidden */
  52599. export var chromaticAberrationPixelShader: {
  52600. name: string;
  52601. shader: string;
  52602. };
  52603. }
  52604. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52605. import { Vector2 } from "babylonjs/Maths/math";
  52606. import { Nullable } from "babylonjs/types";
  52607. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52608. import { Camera } from "babylonjs/Cameras/camera";
  52609. import { Engine } from "babylonjs/Engines/engine";
  52610. import "babylonjs/Shaders/chromaticAberration.fragment";
  52611. /**
  52612. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52613. */
  52614. export class ChromaticAberrationPostProcess extends PostProcess {
  52615. /**
  52616. * The amount of seperation of rgb channels (default: 30)
  52617. */
  52618. aberrationAmount: number;
  52619. /**
  52620. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52621. */
  52622. radialIntensity: number;
  52623. /**
  52624. * 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))
  52625. */
  52626. direction: Vector2;
  52627. /**
  52628. * 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))
  52629. */
  52630. centerPosition: Vector2;
  52631. /**
  52632. * Creates a new instance ChromaticAberrationPostProcess
  52633. * @param name The name of the effect.
  52634. * @param screenWidth The width of the screen to apply the effect on.
  52635. * @param screenHeight The height of the screen to apply the effect on.
  52636. * @param options The required width/height ratio to downsize to before computing the render pass.
  52637. * @param camera The camera to apply the render pass to.
  52638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52639. * @param engine The engine which the post process will be applied. (default: current engine)
  52640. * @param reusable If the post process can be reused on the same frame. (default: false)
  52641. * @param textureType Type of textures used when performing the post process. (default: 0)
  52642. * @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)
  52643. */
  52644. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52645. }
  52646. }
  52647. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52648. /** @hidden */
  52649. export var circleOfConfusionPixelShader: {
  52650. name: string;
  52651. shader: string;
  52652. };
  52653. }
  52654. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52655. import { Nullable } from "babylonjs/types";
  52656. import { Engine } from "babylonjs/Engines/engine";
  52657. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52658. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52659. import { Camera } from "babylonjs/Cameras/camera";
  52660. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52661. /**
  52662. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52663. */
  52664. export class CircleOfConfusionPostProcess extends PostProcess {
  52665. /**
  52666. * 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.
  52667. */
  52668. lensSize: number;
  52669. /**
  52670. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52671. */
  52672. fStop: number;
  52673. /**
  52674. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52675. */
  52676. focusDistance: number;
  52677. /**
  52678. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52679. */
  52680. focalLength: number;
  52681. private _depthTexture;
  52682. /**
  52683. * Creates a new instance CircleOfConfusionPostProcess
  52684. * @param name The name of the effect.
  52685. * @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.
  52686. * @param options The required width/height ratio to downsize to before computing the render pass.
  52687. * @param camera The camera to apply the render pass to.
  52688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52689. * @param engine The engine which the post process will be applied. (default: current engine)
  52690. * @param reusable If the post process can be reused on the same frame. (default: false)
  52691. * @param textureType Type of textures used when performing the post process. (default: 0)
  52692. * @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)
  52693. */
  52694. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52695. /**
  52696. * 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.
  52697. */
  52698. depthTexture: RenderTargetTexture;
  52699. }
  52700. }
  52701. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52702. /** @hidden */
  52703. export var colorCorrectionPixelShader: {
  52704. name: string;
  52705. shader: string;
  52706. };
  52707. }
  52708. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52709. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52710. import { Engine } from "babylonjs/Engines/engine";
  52711. import { Camera } from "babylonjs/Cameras/camera";
  52712. import "babylonjs/Shaders/colorCorrection.fragment";
  52713. /**
  52714. *
  52715. * This post-process allows the modification of rendered colors by using
  52716. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52717. *
  52718. * The object needs to be provided an url to a texture containing the color
  52719. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52720. * Use an image editing software to tweak the LUT to match your needs.
  52721. *
  52722. * For an example of a color LUT, see here:
  52723. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52724. * For explanations on color grading, see here:
  52725. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52726. *
  52727. */
  52728. export class ColorCorrectionPostProcess extends PostProcess {
  52729. private _colorTableTexture;
  52730. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52731. }
  52732. }
  52733. declare module "babylonjs/Shaders/convolution.fragment" {
  52734. /** @hidden */
  52735. export var convolutionPixelShader: {
  52736. name: string;
  52737. shader: string;
  52738. };
  52739. }
  52740. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  52741. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52742. import { Nullable } from "babylonjs/types";
  52743. import { Camera } from "babylonjs/Cameras/camera";
  52744. import { Engine } from "babylonjs/Engines/engine";
  52745. import "babylonjs/Shaders/convolution.fragment";
  52746. /**
  52747. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52748. * input texture to perform effects such as edge detection or sharpening
  52749. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52750. */
  52751. export class ConvolutionPostProcess extends PostProcess {
  52752. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52753. kernel: number[];
  52754. /**
  52755. * Creates a new instance ConvolutionPostProcess
  52756. * @param name The name of the effect.
  52757. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52758. * @param options The required width/height ratio to downsize to before computing the render pass.
  52759. * @param camera The camera to apply the render pass to.
  52760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52761. * @param engine The engine which the post process will be applied. (default: current engine)
  52762. * @param reusable If the post process can be reused on the same frame. (default: false)
  52763. * @param textureType Type of textures used when performing the post process. (default: 0)
  52764. */
  52765. constructor(name: string,
  52766. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52767. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52768. /**
  52769. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52770. */
  52771. static EdgeDetect0Kernel: number[];
  52772. /**
  52773. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52774. */
  52775. static EdgeDetect1Kernel: number[];
  52776. /**
  52777. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52778. */
  52779. static EdgeDetect2Kernel: number[];
  52780. /**
  52781. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52782. */
  52783. static SharpenKernel: number[];
  52784. /**
  52785. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52786. */
  52787. static EmbossKernel: number[];
  52788. /**
  52789. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52790. */
  52791. static GaussianKernel: number[];
  52792. }
  52793. }
  52794. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  52795. import { Nullable } from "babylonjs/types";
  52796. import { Vector2 } from "babylonjs/Maths/math";
  52797. import { Camera } from "babylonjs/Cameras/camera";
  52798. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52799. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52800. import { Engine } from "babylonjs/Engines/engine";
  52801. import { Scene } from "babylonjs/scene";
  52802. /**
  52803. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52804. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52805. * based on samples that have a large difference in distance than the center pixel.
  52806. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52807. */
  52808. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52809. direction: Vector2;
  52810. /**
  52811. * Creates a new instance CircleOfConfusionPostProcess
  52812. * @param name The name of the effect.
  52813. * @param scene The scene the effect belongs to.
  52814. * @param direction The direction the blur should be applied.
  52815. * @param kernel The size of the kernel used to blur.
  52816. * @param options The required width/height ratio to downsize to before computing the render pass.
  52817. * @param camera The camera to apply the render pass to.
  52818. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52819. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52821. * @param engine The engine which the post process will be applied. (default: current engine)
  52822. * @param reusable If the post process can be reused on the same frame. (default: false)
  52823. * @param textureType Type of textures used when performing the post process. (default: 0)
  52824. * @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)
  52825. */
  52826. 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);
  52827. }
  52828. }
  52829. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  52830. /** @hidden */
  52831. export var depthOfFieldMergePixelShader: {
  52832. name: string;
  52833. shader: string;
  52834. };
  52835. }
  52836. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  52837. import { Nullable } from "babylonjs/types";
  52838. import { Camera } from "babylonjs/Cameras/camera";
  52839. import { Effect } from "babylonjs/Materials/effect";
  52840. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52841. import { Engine } from "babylonjs/Engines/engine";
  52842. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  52843. /**
  52844. * Options to be set when merging outputs from the default pipeline.
  52845. */
  52846. export class DepthOfFieldMergePostProcessOptions {
  52847. /**
  52848. * The original image to merge on top of
  52849. */
  52850. originalFromInput: PostProcess;
  52851. /**
  52852. * Parameters to perform the merge of the depth of field effect
  52853. */
  52854. depthOfField?: {
  52855. circleOfConfusion: PostProcess;
  52856. blurSteps: Array<PostProcess>;
  52857. };
  52858. /**
  52859. * Parameters to perform the merge of bloom effect
  52860. */
  52861. bloom?: {
  52862. blurred: PostProcess;
  52863. weight: number;
  52864. };
  52865. }
  52866. /**
  52867. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52868. */
  52869. export class DepthOfFieldMergePostProcess extends PostProcess {
  52870. private blurSteps;
  52871. /**
  52872. * Creates a new instance of DepthOfFieldMergePostProcess
  52873. * @param name The name of the effect.
  52874. * @param originalFromInput Post process which's input will be used for the merge.
  52875. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52876. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52877. * @param options The required width/height ratio to downsize to before computing the render pass.
  52878. * @param camera The camera to apply the render pass to.
  52879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52880. * @param engine The engine which the post process will be applied. (default: current engine)
  52881. * @param reusable If the post process can be reused on the same frame. (default: false)
  52882. * @param textureType Type of textures used when performing the post process. (default: 0)
  52883. * @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)
  52884. */
  52885. 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);
  52886. /**
  52887. * Updates the effect with the current post process compile time values and recompiles the shader.
  52888. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52889. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52890. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52891. * @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
  52892. * @param onCompiled Called when the shader has been compiled.
  52893. * @param onError Called if there is an error when compiling a shader.
  52894. */
  52895. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52896. }
  52897. }
  52898. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  52899. import { Nullable } from "babylonjs/types";
  52900. import { Camera } from "babylonjs/Cameras/camera";
  52901. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52902. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52903. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52904. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52905. import { Scene } from "babylonjs/scene";
  52906. /**
  52907. * Specifies the level of max blur that should be applied when using the depth of field effect
  52908. */
  52909. export enum DepthOfFieldEffectBlurLevel {
  52910. /**
  52911. * Subtle blur
  52912. */
  52913. Low = 0,
  52914. /**
  52915. * Medium blur
  52916. */
  52917. Medium = 1,
  52918. /**
  52919. * Large blur
  52920. */
  52921. High = 2
  52922. }
  52923. /**
  52924. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52925. */
  52926. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52927. private _circleOfConfusion;
  52928. /**
  52929. * @hidden Internal, blurs from high to low
  52930. */
  52931. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52932. private _depthOfFieldBlurY;
  52933. private _dofMerge;
  52934. /**
  52935. * @hidden Internal post processes in depth of field effect
  52936. */
  52937. _effects: Array<PostProcess>;
  52938. /**
  52939. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52940. */
  52941. focalLength: number;
  52942. /**
  52943. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52944. */
  52945. fStop: number;
  52946. /**
  52947. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52948. */
  52949. focusDistance: number;
  52950. /**
  52951. * 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.
  52952. */
  52953. lensSize: number;
  52954. /**
  52955. * Creates a new instance DepthOfFieldEffect
  52956. * @param scene The scene the effect belongs to.
  52957. * @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.
  52958. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52959. * @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)
  52960. */
  52961. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52962. /**
  52963. * 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.
  52964. */
  52965. depthTexture: RenderTargetTexture;
  52966. /**
  52967. * Disposes each of the internal effects for a given camera.
  52968. * @param camera The camera to dispose the effect on.
  52969. */
  52970. disposeEffects(camera: Camera): void;
  52971. /**
  52972. * @hidden Internal
  52973. */
  52974. _updateEffects(): void;
  52975. /**
  52976. * Internal
  52977. * @returns if all the contained post processes are ready.
  52978. * @hidden
  52979. */
  52980. _isReady(): boolean;
  52981. }
  52982. }
  52983. declare module "babylonjs/Shaders/displayPass.fragment" {
  52984. /** @hidden */
  52985. export var displayPassPixelShader: {
  52986. name: string;
  52987. shader: string;
  52988. };
  52989. }
  52990. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  52991. import { Nullable } from "babylonjs/types";
  52992. import { Camera } from "babylonjs/Cameras/camera";
  52993. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52994. import { Engine } from "babylonjs/Engines/engine";
  52995. import "babylonjs/Shaders/displayPass.fragment";
  52996. /**
  52997. * DisplayPassPostProcess which produces an output the same as it's input
  52998. */
  52999. export class DisplayPassPostProcess extends PostProcess {
  53000. /**
  53001. * Creates the DisplayPassPostProcess
  53002. * @param name The name of the effect.
  53003. * @param options The required width/height ratio to downsize to before computing the render pass.
  53004. * @param camera The camera to apply the render pass to.
  53005. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53006. * @param engine The engine which the post process will be applied. (default: current engine)
  53007. * @param reusable If the post process can be reused on the same frame. (default: false)
  53008. */
  53009. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53010. }
  53011. }
  53012. declare module "babylonjs/Shaders/filter.fragment" {
  53013. /** @hidden */
  53014. export var filterPixelShader: {
  53015. name: string;
  53016. shader: string;
  53017. };
  53018. }
  53019. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53020. import { Nullable } from "babylonjs/types";
  53021. import { Matrix } from "babylonjs/Maths/math";
  53022. import { Camera } from "babylonjs/Cameras/camera";
  53023. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53024. import { Engine } from "babylonjs/Engines/engine";
  53025. import "babylonjs/Shaders/filter.fragment";
  53026. /**
  53027. * Applies a kernel filter to the image
  53028. */
  53029. export class FilterPostProcess extends PostProcess {
  53030. /** The matrix to be applied to the image */
  53031. kernelMatrix: Matrix;
  53032. /**
  53033. *
  53034. * @param name The name of the effect.
  53035. * @param kernelMatrix The matrix to be applied to the image
  53036. * @param options The required width/height ratio to downsize to before computing the render pass.
  53037. * @param camera The camera to apply the render pass to.
  53038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53039. * @param engine The engine which the post process will be applied. (default: current engine)
  53040. * @param reusable If the post process can be reused on the same frame. (default: false)
  53041. */
  53042. constructor(name: string,
  53043. /** The matrix to be applied to the image */
  53044. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53045. }
  53046. }
  53047. declare module "babylonjs/Shaders/fxaa.fragment" {
  53048. /** @hidden */
  53049. export var fxaaPixelShader: {
  53050. name: string;
  53051. shader: string;
  53052. };
  53053. }
  53054. declare module "babylonjs/Shaders/fxaa.vertex" {
  53055. /** @hidden */
  53056. export var fxaaVertexShader: {
  53057. name: string;
  53058. shader: string;
  53059. };
  53060. }
  53061. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53062. import { Nullable } from "babylonjs/types";
  53063. import { Camera } from "babylonjs/Cameras/camera";
  53064. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53065. import { Engine } from "babylonjs/Engines/engine";
  53066. import "babylonjs/Shaders/fxaa.fragment";
  53067. import "babylonjs/Shaders/fxaa.vertex";
  53068. /**
  53069. * Fxaa post process
  53070. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53071. */
  53072. export class FxaaPostProcess extends PostProcess {
  53073. /** @hidden */
  53074. texelWidth: number;
  53075. /** @hidden */
  53076. texelHeight: number;
  53077. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53078. private _getDefines;
  53079. }
  53080. }
  53081. declare module "babylonjs/Shaders/grain.fragment" {
  53082. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53083. /** @hidden */
  53084. export var grainPixelShader: {
  53085. name: string;
  53086. shader: string;
  53087. };
  53088. }
  53089. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53090. import { Nullable } from "babylonjs/types";
  53091. import { Camera } from "babylonjs/Cameras/camera";
  53092. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53093. import { Engine } from "babylonjs/Engines/engine";
  53094. import "babylonjs/Shaders/grain.fragment";
  53095. /**
  53096. * The GrainPostProcess adds noise to the image at mid luminance levels
  53097. */
  53098. export class GrainPostProcess extends PostProcess {
  53099. /**
  53100. * The intensity of the grain added (default: 30)
  53101. */
  53102. intensity: number;
  53103. /**
  53104. * If the grain should be randomized on every frame
  53105. */
  53106. animated: boolean;
  53107. /**
  53108. * Creates a new instance of @see GrainPostProcess
  53109. * @param name The name of the effect.
  53110. * @param options The required width/height ratio to downsize to before computing the render pass.
  53111. * @param camera The camera to apply the render pass to.
  53112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53113. * @param engine The engine which the post process will be applied. (default: current engine)
  53114. * @param reusable If the post process can be reused on the same frame. (default: false)
  53115. * @param textureType Type of textures used when performing the post process. (default: 0)
  53116. * @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)
  53117. */
  53118. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53119. }
  53120. }
  53121. declare module "babylonjs/Shaders/highlights.fragment" {
  53122. /** @hidden */
  53123. export var highlightsPixelShader: {
  53124. name: string;
  53125. shader: string;
  53126. };
  53127. }
  53128. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53129. import { Nullable } from "babylonjs/types";
  53130. import { Camera } from "babylonjs/Cameras/camera";
  53131. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53132. import { Engine } from "babylonjs/Engines/engine";
  53133. import "babylonjs/Shaders/highlights.fragment";
  53134. /**
  53135. * Extracts highlights from the image
  53136. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53137. */
  53138. export class HighlightsPostProcess extends PostProcess {
  53139. /**
  53140. * Extracts highlights from the image
  53141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53142. * @param name The name of the effect.
  53143. * @param options The required width/height ratio to downsize to before computing the render pass.
  53144. * @param camera The camera to apply the render pass to.
  53145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53146. * @param engine The engine which the post process will be applied. (default: current engine)
  53147. * @param reusable If the post process can be reused on the same frame. (default: false)
  53148. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53149. */
  53150. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53151. }
  53152. }
  53153. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53154. /** @hidden */
  53155. export var mrtFragmentDeclaration: {
  53156. name: string;
  53157. shader: string;
  53158. };
  53159. }
  53160. declare module "babylonjs/Shaders/geometry.fragment" {
  53161. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53162. /** @hidden */
  53163. export var geometryPixelShader: {
  53164. name: string;
  53165. shader: string;
  53166. };
  53167. }
  53168. declare module "babylonjs/Shaders/geometry.vertex" {
  53169. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53170. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53171. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53172. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53173. /** @hidden */
  53174. export var geometryVertexShader: {
  53175. name: string;
  53176. shader: string;
  53177. };
  53178. }
  53179. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53180. import { Matrix } from "babylonjs/Maths/math";
  53181. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53182. import { Mesh } from "babylonjs/Meshes/mesh";
  53183. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53184. import { Effect } from "babylonjs/Materials/effect";
  53185. import { Scene } from "babylonjs/scene";
  53186. import "babylonjs/Shaders/geometry.fragment";
  53187. import "babylonjs/Shaders/geometry.vertex";
  53188. /**
  53189. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53190. */
  53191. export class GeometryBufferRenderer {
  53192. /**
  53193. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53194. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53195. */
  53196. static readonly POSITION_TEXTURE_TYPE: number;
  53197. /**
  53198. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53199. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53200. */
  53201. static readonly VELOCITY_TEXTURE_TYPE: number;
  53202. /**
  53203. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53204. * in order to compute objects velocities when enableVelocity is set to "true"
  53205. * @hidden
  53206. */
  53207. _previousTransformationMatrices: {
  53208. [index: number]: Matrix;
  53209. };
  53210. private _scene;
  53211. private _multiRenderTarget;
  53212. private _ratio;
  53213. private _enablePosition;
  53214. private _enableVelocity;
  53215. private _positionIndex;
  53216. private _velocityIndex;
  53217. protected _effect: Effect;
  53218. protected _cachedDefines: string;
  53219. /**
  53220. * Set the render list (meshes to be rendered) used in the G buffer.
  53221. */
  53222. renderList: Mesh[];
  53223. /**
  53224. * Gets wether or not G buffer are supported by the running hardware.
  53225. * This requires draw buffer supports
  53226. */
  53227. readonly isSupported: boolean;
  53228. /**
  53229. * Returns the index of the given texture type in the G-Buffer textures array
  53230. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53231. * @returns the index of the given texture type in the G-Buffer textures array
  53232. */
  53233. getTextureIndex(textureType: number): number;
  53234. /**
  53235. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53236. */
  53237. /**
  53238. * Sets whether or not objects positions are enabled for the G buffer.
  53239. */
  53240. enablePosition: boolean;
  53241. /**
  53242. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53243. */
  53244. /**
  53245. * Sets wether or not objects velocities are enabled for the G buffer.
  53246. */
  53247. enableVelocity: boolean;
  53248. /**
  53249. * Gets the scene associated with the buffer.
  53250. */
  53251. readonly scene: Scene;
  53252. /**
  53253. * Gets the ratio used by the buffer during its creation.
  53254. * How big is the buffer related to the main canvas.
  53255. */
  53256. readonly ratio: number;
  53257. /** @hidden */
  53258. static _SceneComponentInitialization: (scene: Scene) => void;
  53259. /**
  53260. * Creates a new G Buffer for the scene
  53261. * @param scene The scene the buffer belongs to
  53262. * @param ratio How big is the buffer related to the main canvas.
  53263. */
  53264. constructor(scene: Scene, ratio?: number);
  53265. /**
  53266. * Checks wether everything is ready to render a submesh to the G buffer.
  53267. * @param subMesh the submesh to check readiness for
  53268. * @param useInstances is the mesh drawn using instance or not
  53269. * @returns true if ready otherwise false
  53270. */
  53271. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53272. /**
  53273. * Gets the current underlying G Buffer.
  53274. * @returns the buffer
  53275. */
  53276. getGBuffer(): MultiRenderTarget;
  53277. /**
  53278. * Gets the number of samples used to render the buffer (anti aliasing).
  53279. */
  53280. /**
  53281. * Sets the number of samples used to render the buffer (anti aliasing).
  53282. */
  53283. samples: number;
  53284. /**
  53285. * Disposes the renderer and frees up associated resources.
  53286. */
  53287. dispose(): void;
  53288. protected _createRenderTargets(): void;
  53289. }
  53290. }
  53291. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53292. /** @hidden */
  53293. export var motionBlurPixelShader: {
  53294. name: string;
  53295. shader: string;
  53296. };
  53297. }
  53298. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53299. import { Nullable } from "babylonjs/types";
  53300. import { Camera } from "babylonjs/Cameras/camera";
  53301. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53302. import { Scene } from "babylonjs/scene";
  53303. import "babylonjs/Shaders/motionBlur.fragment";
  53304. import { Engine } from "babylonjs/Engines/engine";
  53305. /**
  53306. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53307. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53308. * As an example, all you have to do is to create the post-process:
  53309. * var mb = new BABYLON.MotionBlurPostProcess(
  53310. * 'mb', // The name of the effect.
  53311. * scene, // The scene containing the objects to blur according to their velocity.
  53312. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53313. * camera // The camera to apply the render pass to.
  53314. * );
  53315. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53316. */
  53317. export class MotionBlurPostProcess extends PostProcess {
  53318. /**
  53319. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53320. */
  53321. motionStrength: number;
  53322. /**
  53323. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53324. */
  53325. /**
  53326. * Sets the number of iterations to be used for motion blur quality
  53327. */
  53328. motionBlurSamples: number;
  53329. private _motionBlurSamples;
  53330. private _geometryBufferRenderer;
  53331. /**
  53332. * Creates a new instance MotionBlurPostProcess
  53333. * @param name The name of the effect.
  53334. * @param scene The scene containing the objects to blur according to their velocity.
  53335. * @param options The required width/height ratio to downsize to before computing the render pass.
  53336. * @param camera The camera to apply the render pass to.
  53337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53338. * @param engine The engine which the post process will be applied. (default: current engine)
  53339. * @param reusable If the post process can be reused on the same frame. (default: false)
  53340. * @param textureType Type of textures used when performing the post process. (default: 0)
  53341. * @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)
  53342. */
  53343. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53344. /**
  53345. * Disposes the post process.
  53346. * @param camera The camera to dispose the post process on.
  53347. */
  53348. dispose(camera?: Camera): void;
  53349. }
  53350. }
  53351. declare module "babylonjs/Shaders/refraction.fragment" {
  53352. /** @hidden */
  53353. export var refractionPixelShader: {
  53354. name: string;
  53355. shader: string;
  53356. };
  53357. }
  53358. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53359. import { Color3 } from "babylonjs/Maths/math";
  53360. import { Camera } from "babylonjs/Cameras/camera";
  53361. import { Texture } from "babylonjs/Materials/Textures/texture";
  53362. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53363. import { Engine } from "babylonjs/Engines/engine";
  53364. import "babylonjs/Shaders/refraction.fragment";
  53365. /**
  53366. * Post process which applies a refractin texture
  53367. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53368. */
  53369. export class RefractionPostProcess extends PostProcess {
  53370. /** the base color of the refraction (used to taint the rendering) */
  53371. color: Color3;
  53372. /** simulated refraction depth */
  53373. depth: number;
  53374. /** the coefficient of the base color (0 to remove base color tainting) */
  53375. colorLevel: number;
  53376. private _refTexture;
  53377. private _ownRefractionTexture;
  53378. /**
  53379. * Gets or sets the refraction texture
  53380. * Please note that you are responsible for disposing the texture if you set it manually
  53381. */
  53382. refractionTexture: Texture;
  53383. /**
  53384. * Initializes the RefractionPostProcess
  53385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53386. * @param name The name of the effect.
  53387. * @param refractionTextureUrl Url of the refraction texture to use
  53388. * @param color the base color of the refraction (used to taint the rendering)
  53389. * @param depth simulated refraction depth
  53390. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53391. * @param camera The camera to apply the render pass to.
  53392. * @param options The required width/height ratio to downsize to before computing the render pass.
  53393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53394. * @param engine The engine which the post process will be applied. (default: current engine)
  53395. * @param reusable If the post process can be reused on the same frame. (default: false)
  53396. */
  53397. constructor(name: string, refractionTextureUrl: string,
  53398. /** the base color of the refraction (used to taint the rendering) */
  53399. color: Color3,
  53400. /** simulated refraction depth */
  53401. depth: number,
  53402. /** the coefficient of the base color (0 to remove base color tainting) */
  53403. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53404. /**
  53405. * Disposes of the post process
  53406. * @param camera Camera to dispose post process on
  53407. */
  53408. dispose(camera: Camera): void;
  53409. }
  53410. }
  53411. declare module "babylonjs/Shaders/sharpen.fragment" {
  53412. /** @hidden */
  53413. export var sharpenPixelShader: {
  53414. name: string;
  53415. shader: string;
  53416. };
  53417. }
  53418. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53419. import { Nullable } from "babylonjs/types";
  53420. import { Camera } from "babylonjs/Cameras/camera";
  53421. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53422. import "babylonjs/Shaders/sharpen.fragment";
  53423. import { Engine } from "babylonjs/Engines/engine";
  53424. /**
  53425. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53426. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53427. */
  53428. export class SharpenPostProcess extends PostProcess {
  53429. /**
  53430. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53431. */
  53432. colorAmount: number;
  53433. /**
  53434. * How much sharpness should be applied (default: 0.3)
  53435. */
  53436. edgeAmount: number;
  53437. /**
  53438. * Creates a new instance ConvolutionPostProcess
  53439. * @param name The name of the effect.
  53440. * @param options The required width/height ratio to downsize to before computing the render pass.
  53441. * @param camera The camera to apply the render pass to.
  53442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53443. * @param engine The engine which the post process will be applied. (default: current engine)
  53444. * @param reusable If the post process can be reused on the same frame. (default: false)
  53445. * @param textureType Type of textures used when performing the post process. (default: 0)
  53446. * @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)
  53447. */
  53448. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53449. }
  53450. }
  53451. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53452. import { Nullable } from "babylonjs/types";
  53453. import { Camera } from "babylonjs/Cameras/camera";
  53454. import { Engine } from "babylonjs/Engines/engine";
  53455. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53456. /**
  53457. * PostProcessRenderPipeline
  53458. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53459. */
  53460. export class PostProcessRenderPipeline {
  53461. private engine;
  53462. private _renderEffects;
  53463. private _renderEffectsForIsolatedPass;
  53464. /**
  53465. * @hidden
  53466. */
  53467. protected _cameras: Camera[];
  53468. /** @hidden */
  53469. _name: string;
  53470. /**
  53471. * Gets pipeline name
  53472. */
  53473. readonly name: string;
  53474. /**
  53475. * Initializes a PostProcessRenderPipeline
  53476. * @param engine engine to add the pipeline to
  53477. * @param name name of the pipeline
  53478. */
  53479. constructor(engine: Engine, name: string);
  53480. /**
  53481. * Gets the class name
  53482. * @returns "PostProcessRenderPipeline"
  53483. */
  53484. getClassName(): string;
  53485. /**
  53486. * If all the render effects in the pipeline are supported
  53487. */
  53488. readonly isSupported: boolean;
  53489. /**
  53490. * Adds an effect to the pipeline
  53491. * @param renderEffect the effect to add
  53492. */
  53493. addEffect(renderEffect: PostProcessRenderEffect): void;
  53494. /** @hidden */
  53495. _rebuild(): void;
  53496. /** @hidden */
  53497. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53498. /** @hidden */
  53499. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53500. /** @hidden */
  53501. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53502. /** @hidden */
  53503. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53504. /** @hidden */
  53505. _attachCameras(cameras: Camera, unique: boolean): void;
  53506. /** @hidden */
  53507. _attachCameras(cameras: Camera[], unique: boolean): void;
  53508. /** @hidden */
  53509. _detachCameras(cameras: Camera): void;
  53510. /** @hidden */
  53511. _detachCameras(cameras: Nullable<Camera[]>): void;
  53512. /** @hidden */
  53513. _update(): void;
  53514. /** @hidden */
  53515. _reset(): void;
  53516. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53517. /**
  53518. * Disposes of the pipeline
  53519. */
  53520. dispose(): void;
  53521. }
  53522. }
  53523. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53524. import { IAnimatable } from "babylonjs/Misc/tools";
  53525. import { Camera } from "babylonjs/Cameras/camera";
  53526. import { IDisposable } from "babylonjs/scene";
  53527. import { Scene } from "babylonjs/scene";
  53528. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53529. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53530. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53531. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53532. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53533. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53534. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53535. import { Animation } from "babylonjs/Animations/animation";
  53536. /**
  53537. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53538. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53539. */
  53540. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53541. private _scene;
  53542. private _camerasToBeAttached;
  53543. /**
  53544. * ID of the sharpen post process,
  53545. */
  53546. private readonly SharpenPostProcessId;
  53547. /**
  53548. * @ignore
  53549. * ID of the image processing post process;
  53550. */
  53551. readonly ImageProcessingPostProcessId: string;
  53552. /**
  53553. * @ignore
  53554. * ID of the Fast Approximate Anti-Aliasing post process;
  53555. */
  53556. readonly FxaaPostProcessId: string;
  53557. /**
  53558. * ID of the chromatic aberration post process,
  53559. */
  53560. private readonly ChromaticAberrationPostProcessId;
  53561. /**
  53562. * ID of the grain post process
  53563. */
  53564. private readonly GrainPostProcessId;
  53565. /**
  53566. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53567. */
  53568. sharpen: SharpenPostProcess;
  53569. private _sharpenEffect;
  53570. private bloom;
  53571. /**
  53572. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53573. */
  53574. depthOfField: DepthOfFieldEffect;
  53575. /**
  53576. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53577. */
  53578. fxaa: FxaaPostProcess;
  53579. /**
  53580. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53581. */
  53582. imageProcessing: ImageProcessingPostProcess;
  53583. /**
  53584. * Chromatic aberration post process which will shift rgb colors in the image
  53585. */
  53586. chromaticAberration: ChromaticAberrationPostProcess;
  53587. private _chromaticAberrationEffect;
  53588. /**
  53589. * Grain post process which add noise to the image
  53590. */
  53591. grain: GrainPostProcess;
  53592. private _grainEffect;
  53593. /**
  53594. * Glow post process which adds a glow to emissive areas of the image
  53595. */
  53596. private _glowLayer;
  53597. /**
  53598. * Animations which can be used to tweak settings over a period of time
  53599. */
  53600. animations: Animation[];
  53601. private _imageProcessingConfigurationObserver;
  53602. private _sharpenEnabled;
  53603. private _bloomEnabled;
  53604. private _depthOfFieldEnabled;
  53605. private _depthOfFieldBlurLevel;
  53606. private _fxaaEnabled;
  53607. private _imageProcessingEnabled;
  53608. private _defaultPipelineTextureType;
  53609. private _bloomScale;
  53610. private _chromaticAberrationEnabled;
  53611. private _grainEnabled;
  53612. private _buildAllowed;
  53613. /**
  53614. * Gets active scene
  53615. */
  53616. readonly scene: Scene;
  53617. /**
  53618. * Enable or disable the sharpen process from the pipeline
  53619. */
  53620. sharpenEnabled: boolean;
  53621. private _resizeObserver;
  53622. private _hardwareScaleLevel;
  53623. private _bloomKernel;
  53624. /**
  53625. * Specifies the size of the bloom blur kernel, relative to the final output size
  53626. */
  53627. bloomKernel: number;
  53628. /**
  53629. * Specifies the weight of the bloom in the final rendering
  53630. */
  53631. private _bloomWeight;
  53632. /**
  53633. * Specifies the luma threshold for the area that will be blurred by the bloom
  53634. */
  53635. private _bloomThreshold;
  53636. private _hdr;
  53637. /**
  53638. * The strength of the bloom.
  53639. */
  53640. bloomWeight: number;
  53641. /**
  53642. * The strength of the bloom.
  53643. */
  53644. bloomThreshold: number;
  53645. /**
  53646. * The scale of the bloom, lower value will provide better performance.
  53647. */
  53648. bloomScale: number;
  53649. /**
  53650. * Enable or disable the bloom from the pipeline
  53651. */
  53652. bloomEnabled: boolean;
  53653. private _rebuildBloom;
  53654. /**
  53655. * If the depth of field is enabled.
  53656. */
  53657. depthOfFieldEnabled: boolean;
  53658. /**
  53659. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53660. */
  53661. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53662. /**
  53663. * If the anti aliasing is enabled.
  53664. */
  53665. fxaaEnabled: boolean;
  53666. private _samples;
  53667. /**
  53668. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53669. */
  53670. samples: number;
  53671. /**
  53672. * If image processing is enabled.
  53673. */
  53674. imageProcessingEnabled: boolean;
  53675. /**
  53676. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53677. */
  53678. glowLayerEnabled: boolean;
  53679. /**
  53680. * Enable or disable the chromaticAberration process from the pipeline
  53681. */
  53682. chromaticAberrationEnabled: boolean;
  53683. /**
  53684. * Enable or disable the grain process from the pipeline
  53685. */
  53686. grainEnabled: boolean;
  53687. /**
  53688. * @constructor
  53689. * @param name - The rendering pipeline name (default: "")
  53690. * @param hdr - If high dynamic range textures should be used (default: true)
  53691. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53692. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53693. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53694. */
  53695. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53696. /**
  53697. * Get the class name
  53698. * @returns "DefaultRenderingPipeline"
  53699. */
  53700. getClassName(): string;
  53701. /**
  53702. * Force the compilation of the entire pipeline.
  53703. */
  53704. prepare(): void;
  53705. private _hasCleared;
  53706. private _prevPostProcess;
  53707. private _prevPrevPostProcess;
  53708. private _setAutoClearAndTextureSharing;
  53709. private _depthOfFieldSceneObserver;
  53710. private _buildPipeline;
  53711. private _disposePostProcesses;
  53712. /**
  53713. * Adds a camera to the pipeline
  53714. * @param camera the camera to be added
  53715. */
  53716. addCamera(camera: Camera): void;
  53717. /**
  53718. * Removes a camera from the pipeline
  53719. * @param camera the camera to remove
  53720. */
  53721. removeCamera(camera: Camera): void;
  53722. /**
  53723. * Dispose of the pipeline and stop all post processes
  53724. */
  53725. dispose(): void;
  53726. /**
  53727. * Serialize the rendering pipeline (Used when exporting)
  53728. * @returns the serialized object
  53729. */
  53730. serialize(): any;
  53731. /**
  53732. * Parse the serialized pipeline
  53733. * @param source Source pipeline.
  53734. * @param scene The scene to load the pipeline to.
  53735. * @param rootUrl The URL of the serialized pipeline.
  53736. * @returns An instantiated pipeline from the serialized object.
  53737. */
  53738. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53739. }
  53740. }
  53741. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  53742. /** @hidden */
  53743. export var lensHighlightsPixelShader: {
  53744. name: string;
  53745. shader: string;
  53746. };
  53747. }
  53748. declare module "babylonjs/Shaders/depthOfField.fragment" {
  53749. /** @hidden */
  53750. export var depthOfFieldPixelShader: {
  53751. name: string;
  53752. shader: string;
  53753. };
  53754. }
  53755. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  53756. import { Camera } from "babylonjs/Cameras/camera";
  53757. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53758. import { Scene } from "babylonjs/scene";
  53759. import "babylonjs/Shaders/chromaticAberration.fragment";
  53760. import "babylonjs/Shaders/lensHighlights.fragment";
  53761. import "babylonjs/Shaders/depthOfField.fragment";
  53762. /**
  53763. * BABYLON.JS Chromatic Aberration GLSL Shader
  53764. * Author: Olivier Guyot
  53765. * Separates very slightly R, G and B colors on the edges of the screen
  53766. * Inspired by Francois Tarlier & Martins Upitis
  53767. */
  53768. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53769. /**
  53770. * @ignore
  53771. * The chromatic aberration PostProcess id in the pipeline
  53772. */
  53773. LensChromaticAberrationEffect: string;
  53774. /**
  53775. * @ignore
  53776. * The highlights enhancing PostProcess id in the pipeline
  53777. */
  53778. HighlightsEnhancingEffect: string;
  53779. /**
  53780. * @ignore
  53781. * The depth-of-field PostProcess id in the pipeline
  53782. */
  53783. LensDepthOfFieldEffect: string;
  53784. private _scene;
  53785. private _depthTexture;
  53786. private _grainTexture;
  53787. private _chromaticAberrationPostProcess;
  53788. private _highlightsPostProcess;
  53789. private _depthOfFieldPostProcess;
  53790. private _edgeBlur;
  53791. private _grainAmount;
  53792. private _chromaticAberration;
  53793. private _distortion;
  53794. private _highlightsGain;
  53795. private _highlightsThreshold;
  53796. private _dofDistance;
  53797. private _dofAperture;
  53798. private _dofDarken;
  53799. private _dofPentagon;
  53800. private _blurNoise;
  53801. /**
  53802. * @constructor
  53803. *
  53804. * Effect parameters are as follow:
  53805. * {
  53806. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53807. * edge_blur: number; // from 0 to x (1 for realism)
  53808. * distortion: number; // from 0 to x (1 for realism)
  53809. * grain_amount: number; // from 0 to 1
  53810. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53811. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53812. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53813. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53814. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53815. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53816. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53817. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53818. * }
  53819. * Note: if an effect parameter is unset, effect is disabled
  53820. *
  53821. * @param name The rendering pipeline name
  53822. * @param parameters - An object containing all parameters (see above)
  53823. * @param scene The scene linked to this pipeline
  53824. * @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)
  53825. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53826. */
  53827. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53828. /**
  53829. * Sets the amount of blur at the edges
  53830. * @param amount blur amount
  53831. */
  53832. setEdgeBlur(amount: number): void;
  53833. /**
  53834. * Sets edge blur to 0
  53835. */
  53836. disableEdgeBlur(): void;
  53837. /**
  53838. * Sets the amout of grain
  53839. * @param amount Amount of grain
  53840. */
  53841. setGrainAmount(amount: number): void;
  53842. /**
  53843. * Set grain amount to 0
  53844. */
  53845. disableGrain(): void;
  53846. /**
  53847. * Sets the chromatic aberration amount
  53848. * @param amount amount of chromatic aberration
  53849. */
  53850. setChromaticAberration(amount: number): void;
  53851. /**
  53852. * Sets chromatic aberration amount to 0
  53853. */
  53854. disableChromaticAberration(): void;
  53855. /**
  53856. * Sets the EdgeDistortion amount
  53857. * @param amount amount of EdgeDistortion
  53858. */
  53859. setEdgeDistortion(amount: number): void;
  53860. /**
  53861. * Sets edge distortion to 0
  53862. */
  53863. disableEdgeDistortion(): void;
  53864. /**
  53865. * Sets the FocusDistance amount
  53866. * @param amount amount of FocusDistance
  53867. */
  53868. setFocusDistance(amount: number): void;
  53869. /**
  53870. * Disables depth of field
  53871. */
  53872. disableDepthOfField(): void;
  53873. /**
  53874. * Sets the Aperture amount
  53875. * @param amount amount of Aperture
  53876. */
  53877. setAperture(amount: number): void;
  53878. /**
  53879. * Sets the DarkenOutOfFocus amount
  53880. * @param amount amount of DarkenOutOfFocus
  53881. */
  53882. setDarkenOutOfFocus(amount: number): void;
  53883. /**
  53884. * Creates a pentagon bokeh effect
  53885. */
  53886. enablePentagonBokeh(): void;
  53887. /**
  53888. * Disables the pentagon bokeh effect
  53889. */
  53890. disablePentagonBokeh(): void;
  53891. /**
  53892. * Enables noise blur
  53893. */
  53894. enableNoiseBlur(): void;
  53895. /**
  53896. * Disables noise blur
  53897. */
  53898. disableNoiseBlur(): void;
  53899. /**
  53900. * Sets the HighlightsGain amount
  53901. * @param amount amount of HighlightsGain
  53902. */
  53903. setHighlightsGain(amount: number): void;
  53904. /**
  53905. * Sets the HighlightsThreshold amount
  53906. * @param amount amount of HighlightsThreshold
  53907. */
  53908. setHighlightsThreshold(amount: number): void;
  53909. /**
  53910. * Disables highlights
  53911. */
  53912. disableHighlights(): void;
  53913. /**
  53914. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53915. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53916. */
  53917. dispose(disableDepthRender?: boolean): void;
  53918. private _createChromaticAberrationPostProcess;
  53919. private _createHighlightsPostProcess;
  53920. private _createDepthOfFieldPostProcess;
  53921. private _createGrainTexture;
  53922. }
  53923. }
  53924. declare module "babylonjs/Shaders/ssao2.fragment" {
  53925. /** @hidden */
  53926. export var ssao2PixelShader: {
  53927. name: string;
  53928. shader: string;
  53929. };
  53930. }
  53931. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  53932. /** @hidden */
  53933. export var ssaoCombinePixelShader: {
  53934. name: string;
  53935. shader: string;
  53936. };
  53937. }
  53938. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53939. import { Camera } from "babylonjs/Cameras/camera";
  53940. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53941. import { Scene } from "babylonjs/scene";
  53942. import "babylonjs/Shaders/ssao2.fragment";
  53943. import "babylonjs/Shaders/ssaoCombine.fragment";
  53944. /**
  53945. * Render pipeline to produce ssao effect
  53946. */
  53947. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53948. /**
  53949. * @ignore
  53950. * The PassPostProcess id in the pipeline that contains the original scene color
  53951. */
  53952. SSAOOriginalSceneColorEffect: string;
  53953. /**
  53954. * @ignore
  53955. * The SSAO PostProcess id in the pipeline
  53956. */
  53957. SSAORenderEffect: string;
  53958. /**
  53959. * @ignore
  53960. * The horizontal blur PostProcess id in the pipeline
  53961. */
  53962. SSAOBlurHRenderEffect: string;
  53963. /**
  53964. * @ignore
  53965. * The vertical blur PostProcess id in the pipeline
  53966. */
  53967. SSAOBlurVRenderEffect: string;
  53968. /**
  53969. * @ignore
  53970. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53971. */
  53972. SSAOCombineRenderEffect: string;
  53973. /**
  53974. * The output strength of the SSAO post-process. Default value is 1.0.
  53975. */
  53976. totalStrength: number;
  53977. /**
  53978. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53979. */
  53980. maxZ: number;
  53981. /**
  53982. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53983. */
  53984. minZAspect: number;
  53985. private _samples;
  53986. /**
  53987. * Number of samples used for the SSAO calculations. Default value is 8
  53988. */
  53989. samples: number;
  53990. private _textureSamples;
  53991. /**
  53992. * Number of samples to use for antialiasing
  53993. */
  53994. textureSamples: number;
  53995. /**
  53996. * Ratio object used for SSAO ratio and blur ratio
  53997. */
  53998. private _ratio;
  53999. /**
  54000. * Dynamically generated sphere sampler.
  54001. */
  54002. private _sampleSphere;
  54003. /**
  54004. * Blur filter offsets
  54005. */
  54006. private _samplerOffsets;
  54007. private _expensiveBlur;
  54008. /**
  54009. * If bilateral blur should be used
  54010. */
  54011. expensiveBlur: boolean;
  54012. /**
  54013. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54014. */
  54015. radius: number;
  54016. /**
  54017. * The base color of the SSAO post-process
  54018. * The final result is "base + ssao" between [0, 1]
  54019. */
  54020. base: number;
  54021. /**
  54022. * Support test.
  54023. */
  54024. static readonly IsSupported: boolean;
  54025. private _scene;
  54026. private _depthTexture;
  54027. private _normalTexture;
  54028. private _randomTexture;
  54029. private _originalColorPostProcess;
  54030. private _ssaoPostProcess;
  54031. private _blurHPostProcess;
  54032. private _blurVPostProcess;
  54033. private _ssaoCombinePostProcess;
  54034. private _firstUpdate;
  54035. /**
  54036. * Gets active scene
  54037. */
  54038. readonly scene: Scene;
  54039. /**
  54040. * @constructor
  54041. * @param name The rendering pipeline name
  54042. * @param scene The scene linked to this pipeline
  54043. * @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 }
  54044. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54045. */
  54046. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54047. /**
  54048. * Get the class name
  54049. * @returns "SSAO2RenderingPipeline"
  54050. */
  54051. getClassName(): string;
  54052. /**
  54053. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54054. */
  54055. dispose(disableGeometryBufferRenderer?: boolean): void;
  54056. private _createBlurPostProcess;
  54057. /** @hidden */
  54058. _rebuild(): void;
  54059. private _bits;
  54060. private _radicalInverse_VdC;
  54061. private _hammersley;
  54062. private _hemisphereSample_uniform;
  54063. private _generateHemisphere;
  54064. private _createSSAOPostProcess;
  54065. private _createSSAOCombinePostProcess;
  54066. private _createRandomTexture;
  54067. /**
  54068. * Serialize the rendering pipeline (Used when exporting)
  54069. * @returns the serialized object
  54070. */
  54071. serialize(): any;
  54072. /**
  54073. * Parse the serialized pipeline
  54074. * @param source Source pipeline.
  54075. * @param scene The scene to load the pipeline to.
  54076. * @param rootUrl The URL of the serialized pipeline.
  54077. * @returns An instantiated pipeline from the serialized object.
  54078. */
  54079. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54080. }
  54081. }
  54082. declare module "babylonjs/Shaders/ssao.fragment" {
  54083. /** @hidden */
  54084. export var ssaoPixelShader: {
  54085. name: string;
  54086. shader: string;
  54087. };
  54088. }
  54089. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54090. import { Camera } from "babylonjs/Cameras/camera";
  54091. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54092. import { Scene } from "babylonjs/scene";
  54093. import "babylonjs/Shaders/ssao.fragment";
  54094. import "babylonjs/Shaders/ssaoCombine.fragment";
  54095. /**
  54096. * Render pipeline to produce ssao effect
  54097. */
  54098. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54099. /**
  54100. * @ignore
  54101. * The PassPostProcess id in the pipeline that contains the original scene color
  54102. */
  54103. SSAOOriginalSceneColorEffect: string;
  54104. /**
  54105. * @ignore
  54106. * The SSAO PostProcess id in the pipeline
  54107. */
  54108. SSAORenderEffect: string;
  54109. /**
  54110. * @ignore
  54111. * The horizontal blur PostProcess id in the pipeline
  54112. */
  54113. SSAOBlurHRenderEffect: string;
  54114. /**
  54115. * @ignore
  54116. * The vertical blur PostProcess id in the pipeline
  54117. */
  54118. SSAOBlurVRenderEffect: string;
  54119. /**
  54120. * @ignore
  54121. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54122. */
  54123. SSAOCombineRenderEffect: string;
  54124. /**
  54125. * The output strength of the SSAO post-process. Default value is 1.0.
  54126. */
  54127. totalStrength: number;
  54128. /**
  54129. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54130. */
  54131. radius: number;
  54132. /**
  54133. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54134. * Must not be equal to fallOff and superior to fallOff.
  54135. * Default value is 0.0075
  54136. */
  54137. area: number;
  54138. /**
  54139. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54140. * Must not be equal to area and inferior to area.
  54141. * Default value is 0.000001
  54142. */
  54143. fallOff: number;
  54144. /**
  54145. * The base color of the SSAO post-process
  54146. * The final result is "base + ssao" between [0, 1]
  54147. */
  54148. base: number;
  54149. private _scene;
  54150. private _depthTexture;
  54151. private _randomTexture;
  54152. private _originalColorPostProcess;
  54153. private _ssaoPostProcess;
  54154. private _blurHPostProcess;
  54155. private _blurVPostProcess;
  54156. private _ssaoCombinePostProcess;
  54157. private _firstUpdate;
  54158. /**
  54159. * Gets active scene
  54160. */
  54161. readonly scene: Scene;
  54162. /**
  54163. * @constructor
  54164. * @param name - The rendering pipeline name
  54165. * @param scene - The scene linked to this pipeline
  54166. * @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 }
  54167. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54168. */
  54169. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54170. /**
  54171. * Get the class name
  54172. * @returns "SSAORenderingPipeline"
  54173. */
  54174. getClassName(): string;
  54175. /**
  54176. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54177. */
  54178. dispose(disableDepthRender?: boolean): void;
  54179. private _createBlurPostProcess;
  54180. /** @hidden */
  54181. _rebuild(): void;
  54182. private _createSSAOPostProcess;
  54183. private _createSSAOCombinePostProcess;
  54184. private _createRandomTexture;
  54185. }
  54186. }
  54187. declare module "babylonjs/Shaders/standard.fragment" {
  54188. /** @hidden */
  54189. export var standardPixelShader: {
  54190. name: string;
  54191. shader: string;
  54192. };
  54193. }
  54194. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54195. import { Nullable } from "babylonjs/types";
  54196. import { IAnimatable } from "babylonjs/Misc/tools";
  54197. import { Camera } from "babylonjs/Cameras/camera";
  54198. import { Texture } from "babylonjs/Materials/Textures/texture";
  54199. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54200. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54201. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54202. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54203. import { IDisposable } from "babylonjs/scene";
  54204. import { SpotLight } from "babylonjs/Lights/spotLight";
  54205. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54206. import { Scene } from "babylonjs/scene";
  54207. import { Animation } from "babylonjs/Animations/animation";
  54208. import "babylonjs/Shaders/standard.fragment";
  54209. /**
  54210. * Standard rendering pipeline
  54211. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54212. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54213. */
  54214. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54215. /**
  54216. * Public members
  54217. */
  54218. /**
  54219. * Post-process which contains the original scene color before the pipeline applies all the effects
  54220. */
  54221. originalPostProcess: Nullable<PostProcess>;
  54222. /**
  54223. * Post-process used to down scale an image x4
  54224. */
  54225. downSampleX4PostProcess: Nullable<PostProcess>;
  54226. /**
  54227. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54228. */
  54229. brightPassPostProcess: Nullable<PostProcess>;
  54230. /**
  54231. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54232. */
  54233. blurHPostProcesses: PostProcess[];
  54234. /**
  54235. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54236. */
  54237. blurVPostProcesses: PostProcess[];
  54238. /**
  54239. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54240. */
  54241. textureAdderPostProcess: Nullable<PostProcess>;
  54242. /**
  54243. * Post-process used to create volumetric lighting effect
  54244. */
  54245. volumetricLightPostProcess: Nullable<PostProcess>;
  54246. /**
  54247. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54248. */
  54249. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54250. /**
  54251. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54252. */
  54253. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54254. /**
  54255. * Post-process used to merge the volumetric light effect and the real scene color
  54256. */
  54257. volumetricLightMergePostProces: Nullable<PostProcess>;
  54258. /**
  54259. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54260. */
  54261. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54262. /**
  54263. * Base post-process used to calculate the average luminance of the final image for HDR
  54264. */
  54265. luminancePostProcess: Nullable<PostProcess>;
  54266. /**
  54267. * Post-processes used to create down sample post-processes in order to get
  54268. * the average luminance of the final image for HDR
  54269. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54270. */
  54271. luminanceDownSamplePostProcesses: PostProcess[];
  54272. /**
  54273. * Post-process used to create a HDR effect (light adaptation)
  54274. */
  54275. hdrPostProcess: Nullable<PostProcess>;
  54276. /**
  54277. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54278. */
  54279. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54280. /**
  54281. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54282. */
  54283. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54284. /**
  54285. * Post-process used to merge the final HDR post-process and the real scene color
  54286. */
  54287. hdrFinalPostProcess: Nullable<PostProcess>;
  54288. /**
  54289. * Post-process used to create a lens flare effect
  54290. */
  54291. lensFlarePostProcess: Nullable<PostProcess>;
  54292. /**
  54293. * Post-process that merges the result of the lens flare post-process and the real scene color
  54294. */
  54295. lensFlareComposePostProcess: Nullable<PostProcess>;
  54296. /**
  54297. * Post-process used to create a motion blur effect
  54298. */
  54299. motionBlurPostProcess: Nullable<PostProcess>;
  54300. /**
  54301. * Post-process used to create a depth of field effect
  54302. */
  54303. depthOfFieldPostProcess: Nullable<PostProcess>;
  54304. /**
  54305. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54306. */
  54307. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54308. /**
  54309. * Represents the brightness threshold in order to configure the illuminated surfaces
  54310. */
  54311. brightThreshold: number;
  54312. /**
  54313. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54314. */
  54315. blurWidth: number;
  54316. /**
  54317. * Sets if the blur for highlighted surfaces must be only horizontal
  54318. */
  54319. horizontalBlur: boolean;
  54320. /**
  54321. * Sets the overall exposure used by the pipeline
  54322. */
  54323. exposure: number;
  54324. /**
  54325. * Texture used typically to simulate "dirty" on camera lens
  54326. */
  54327. lensTexture: Nullable<Texture>;
  54328. /**
  54329. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54330. */
  54331. volumetricLightCoefficient: number;
  54332. /**
  54333. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54334. */
  54335. volumetricLightPower: number;
  54336. /**
  54337. * Used the set the blur intensity to smooth the volumetric lights
  54338. */
  54339. volumetricLightBlurScale: number;
  54340. /**
  54341. * Light (spot or directional) used to generate the volumetric lights rays
  54342. * The source light must have a shadow generate so the pipeline can get its
  54343. * depth map
  54344. */
  54345. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54346. /**
  54347. * For eye adaptation, represents the minimum luminance the eye can see
  54348. */
  54349. hdrMinimumLuminance: number;
  54350. /**
  54351. * For eye adaptation, represents the decrease luminance speed
  54352. */
  54353. hdrDecreaseRate: number;
  54354. /**
  54355. * For eye adaptation, represents the increase luminance speed
  54356. */
  54357. hdrIncreaseRate: number;
  54358. /**
  54359. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54360. */
  54361. lensColorTexture: Nullable<Texture>;
  54362. /**
  54363. * The overall strengh for the lens flare effect
  54364. */
  54365. lensFlareStrength: number;
  54366. /**
  54367. * Dispersion coefficient for lens flare ghosts
  54368. */
  54369. lensFlareGhostDispersal: number;
  54370. /**
  54371. * Main lens flare halo width
  54372. */
  54373. lensFlareHaloWidth: number;
  54374. /**
  54375. * Based on the lens distortion effect, defines how much the lens flare result
  54376. * is distorted
  54377. */
  54378. lensFlareDistortionStrength: number;
  54379. /**
  54380. * Lens star texture must be used to simulate rays on the flares and is available
  54381. * in the documentation
  54382. */
  54383. lensStarTexture: Nullable<Texture>;
  54384. /**
  54385. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54386. * flare effect by taking account of the dirt texture
  54387. */
  54388. lensFlareDirtTexture: Nullable<Texture>;
  54389. /**
  54390. * Represents the focal length for the depth of field effect
  54391. */
  54392. depthOfFieldDistance: number;
  54393. /**
  54394. * Represents the blur intensity for the blurred part of the depth of field effect
  54395. */
  54396. depthOfFieldBlurWidth: number;
  54397. /**
  54398. * For motion blur, defines how much the image is blurred by the movement
  54399. */
  54400. motionStrength: number;
  54401. /**
  54402. * List of animations for the pipeline (IAnimatable implementation)
  54403. */
  54404. animations: Animation[];
  54405. /**
  54406. * Private members
  54407. */
  54408. private _scene;
  54409. private _currentDepthOfFieldSource;
  54410. private _basePostProcess;
  54411. private _hdrCurrentLuminance;
  54412. private _floatTextureType;
  54413. private _ratio;
  54414. private _bloomEnabled;
  54415. private _depthOfFieldEnabled;
  54416. private _vlsEnabled;
  54417. private _lensFlareEnabled;
  54418. private _hdrEnabled;
  54419. private _motionBlurEnabled;
  54420. private _fxaaEnabled;
  54421. private _motionBlurSamples;
  54422. private _volumetricLightStepsCount;
  54423. private _samples;
  54424. /**
  54425. * @ignore
  54426. * Specifies if the bloom pipeline is enabled
  54427. */
  54428. BloomEnabled: boolean;
  54429. /**
  54430. * @ignore
  54431. * Specifies if the depth of field pipeline is enabed
  54432. */
  54433. DepthOfFieldEnabled: boolean;
  54434. /**
  54435. * @ignore
  54436. * Specifies if the lens flare pipeline is enabed
  54437. */
  54438. LensFlareEnabled: boolean;
  54439. /**
  54440. * @ignore
  54441. * Specifies if the HDR pipeline is enabled
  54442. */
  54443. HDREnabled: boolean;
  54444. /**
  54445. * @ignore
  54446. * Specifies if the volumetric lights scattering effect is enabled
  54447. */
  54448. VLSEnabled: boolean;
  54449. /**
  54450. * @ignore
  54451. * Specifies if the motion blur effect is enabled
  54452. */
  54453. MotionBlurEnabled: boolean;
  54454. /**
  54455. * Specifies if anti-aliasing is enabled
  54456. */
  54457. fxaaEnabled: boolean;
  54458. /**
  54459. * Specifies the number of steps used to calculate the volumetric lights
  54460. * Typically in interval [50, 200]
  54461. */
  54462. volumetricLightStepsCount: number;
  54463. /**
  54464. * Specifies the number of samples used for the motion blur effect
  54465. * Typically in interval [16, 64]
  54466. */
  54467. motionBlurSamples: number;
  54468. /**
  54469. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54470. */
  54471. samples: number;
  54472. /**
  54473. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54474. * @constructor
  54475. * @param name The rendering pipeline name
  54476. * @param scene The scene linked to this pipeline
  54477. * @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)
  54478. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54479. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54480. */
  54481. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54482. private _buildPipeline;
  54483. private _createDownSampleX4PostProcess;
  54484. private _createBrightPassPostProcess;
  54485. private _createBlurPostProcesses;
  54486. private _createTextureAdderPostProcess;
  54487. private _createVolumetricLightPostProcess;
  54488. private _createLuminancePostProcesses;
  54489. private _createHdrPostProcess;
  54490. private _createLensFlarePostProcess;
  54491. private _createDepthOfFieldPostProcess;
  54492. private _createMotionBlurPostProcess;
  54493. private _getDepthTexture;
  54494. private _disposePostProcesses;
  54495. /**
  54496. * Dispose of the pipeline and stop all post processes
  54497. */
  54498. dispose(): void;
  54499. /**
  54500. * Serialize the rendering pipeline (Used when exporting)
  54501. * @returns the serialized object
  54502. */
  54503. serialize(): any;
  54504. /**
  54505. * Parse the serialized pipeline
  54506. * @param source Source pipeline.
  54507. * @param scene The scene to load the pipeline to.
  54508. * @param rootUrl The URL of the serialized pipeline.
  54509. * @returns An instantiated pipeline from the serialized object.
  54510. */
  54511. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54512. /**
  54513. * Luminance steps
  54514. */
  54515. static LuminanceSteps: number;
  54516. }
  54517. }
  54518. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54519. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54520. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54521. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54522. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54523. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54524. }
  54525. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54526. import { Camera } from "babylonjs/Cameras/camera";
  54527. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54528. /**
  54529. * PostProcessRenderPipelineManager class
  54530. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54531. */
  54532. export class PostProcessRenderPipelineManager {
  54533. private _renderPipelines;
  54534. /**
  54535. * Initializes a PostProcessRenderPipelineManager
  54536. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54537. */
  54538. constructor();
  54539. /**
  54540. * Gets the list of supported render pipelines
  54541. */
  54542. readonly supportedPipelines: PostProcessRenderPipeline[];
  54543. /**
  54544. * Adds a pipeline to the manager
  54545. * @param renderPipeline The pipeline to add
  54546. */
  54547. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54548. /**
  54549. * Attaches a camera to the pipeline
  54550. * @param renderPipelineName The name of the pipeline to attach to
  54551. * @param cameras the camera to attach
  54552. * @param unique if the camera can be attached multiple times to the pipeline
  54553. */
  54554. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54555. /**
  54556. * Detaches a camera from the pipeline
  54557. * @param renderPipelineName The name of the pipeline to detach from
  54558. * @param cameras the camera to detach
  54559. */
  54560. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54561. /**
  54562. * Enables an effect by name on a pipeline
  54563. * @param renderPipelineName the name of the pipeline to enable the effect in
  54564. * @param renderEffectName the name of the effect to enable
  54565. * @param cameras the cameras that the effect should be enabled on
  54566. */
  54567. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54568. /**
  54569. * Disables an effect by name on a pipeline
  54570. * @param renderPipelineName the name of the pipeline to disable the effect in
  54571. * @param renderEffectName the name of the effect to disable
  54572. * @param cameras the cameras that the effect should be disabled on
  54573. */
  54574. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54575. /**
  54576. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54577. */
  54578. update(): void;
  54579. /** @hidden */
  54580. _rebuild(): void;
  54581. /**
  54582. * Disposes of the manager and pipelines
  54583. */
  54584. dispose(): void;
  54585. }
  54586. }
  54587. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54588. import { ISceneComponent } from "babylonjs/sceneComponent";
  54589. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54590. import { Scene } from "babylonjs/scene";
  54591. module "babylonjs/scene" {
  54592. interface Scene {
  54593. /** @hidden (Backing field) */
  54594. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54595. /**
  54596. * Gets the postprocess render pipeline manager
  54597. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54598. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54599. */
  54600. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54601. }
  54602. }
  54603. /**
  54604. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54605. */
  54606. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54607. /**
  54608. * The component name helpfull to identify the component in the list of scene components.
  54609. */
  54610. readonly name: string;
  54611. /**
  54612. * The scene the component belongs to.
  54613. */
  54614. scene: Scene;
  54615. /**
  54616. * Creates a new instance of the component for the given scene
  54617. * @param scene Defines the scene to register the component in
  54618. */
  54619. constructor(scene: Scene);
  54620. /**
  54621. * Registers the component in a given scene
  54622. */
  54623. register(): void;
  54624. /**
  54625. * Rebuilds the elements related to this component in case of
  54626. * context lost for instance.
  54627. */
  54628. rebuild(): void;
  54629. /**
  54630. * Disposes the component and the associated ressources
  54631. */
  54632. dispose(): void;
  54633. private _gatherRenderTargets;
  54634. }
  54635. }
  54636. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54637. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54638. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54639. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54640. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54641. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54642. }
  54643. declare module "babylonjs/Shaders/tonemap.fragment" {
  54644. /** @hidden */
  54645. export var tonemapPixelShader: {
  54646. name: string;
  54647. shader: string;
  54648. };
  54649. }
  54650. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54651. import { Camera } from "babylonjs/Cameras/camera";
  54652. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54653. import "babylonjs/Shaders/tonemap.fragment";
  54654. import { Engine } from "babylonjs/Engines/engine";
  54655. /** Defines operator used for tonemapping */
  54656. export enum TonemappingOperator {
  54657. /** Hable */
  54658. Hable = 0,
  54659. /** Reinhard */
  54660. Reinhard = 1,
  54661. /** HejiDawson */
  54662. HejiDawson = 2,
  54663. /** Photographic */
  54664. Photographic = 3
  54665. }
  54666. /**
  54667. * Defines a post process to apply tone mapping
  54668. */
  54669. export class TonemapPostProcess extends PostProcess {
  54670. private _operator;
  54671. /** Defines the required exposure adjustement */
  54672. exposureAdjustment: number;
  54673. /**
  54674. * Creates a new TonemapPostProcess
  54675. * @param name defines the name of the postprocess
  54676. * @param _operator defines the operator to use
  54677. * @param exposureAdjustment defines the required exposure adjustement
  54678. * @param camera defines the camera to use (can be null)
  54679. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54680. * @param engine defines the hosting engine (can be ignore if camera is set)
  54681. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54682. */
  54683. constructor(name: string, _operator: TonemappingOperator,
  54684. /** Defines the required exposure adjustement */
  54685. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54686. }
  54687. }
  54688. declare module "babylonjs/Shaders/depth.vertex" {
  54689. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54690. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54691. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54692. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54693. /** @hidden */
  54694. export var depthVertexShader: {
  54695. name: string;
  54696. shader: string;
  54697. };
  54698. }
  54699. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  54700. /** @hidden */
  54701. export var volumetricLightScatteringPixelShader: {
  54702. name: string;
  54703. shader: string;
  54704. };
  54705. }
  54706. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  54707. /** @hidden */
  54708. export var volumetricLightScatteringPassPixelShader: {
  54709. name: string;
  54710. shader: string;
  54711. };
  54712. }
  54713. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  54714. import { Vector3 } from "babylonjs/Maths/math";
  54715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54716. import { Mesh } from "babylonjs/Meshes/mesh";
  54717. import { Camera } from "babylonjs/Cameras/camera";
  54718. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54719. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54720. import { Scene } from "babylonjs/scene";
  54721. import "babylonjs/Meshes/Builders/planeBuilder";
  54722. import "babylonjs/Shaders/depth.vertex";
  54723. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  54724. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  54725. import { Engine } from "babylonjs/Engines/engine";
  54726. /**
  54727. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54728. */
  54729. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54730. private _volumetricLightScatteringPass;
  54731. private _volumetricLightScatteringRTT;
  54732. private _viewPort;
  54733. private _screenCoordinates;
  54734. private _cachedDefines;
  54735. /**
  54736. * If not undefined, the mesh position is computed from the attached node position
  54737. */
  54738. attachedNode: {
  54739. position: Vector3;
  54740. };
  54741. /**
  54742. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54743. */
  54744. customMeshPosition: Vector3;
  54745. /**
  54746. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54747. */
  54748. useCustomMeshPosition: boolean;
  54749. /**
  54750. * If the post-process should inverse the light scattering direction
  54751. */
  54752. invert: boolean;
  54753. /**
  54754. * The internal mesh used by the post-process
  54755. */
  54756. mesh: Mesh;
  54757. /**
  54758. * @hidden
  54759. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54760. */
  54761. useDiffuseColor: boolean;
  54762. /**
  54763. * Array containing the excluded meshes not rendered in the internal pass
  54764. */
  54765. excludedMeshes: AbstractMesh[];
  54766. /**
  54767. * Controls the overall intensity of the post-process
  54768. */
  54769. exposure: number;
  54770. /**
  54771. * Dissipates each sample's contribution in range [0, 1]
  54772. */
  54773. decay: number;
  54774. /**
  54775. * Controls the overall intensity of each sample
  54776. */
  54777. weight: number;
  54778. /**
  54779. * Controls the density of each sample
  54780. */
  54781. density: number;
  54782. /**
  54783. * @constructor
  54784. * @param name The post-process name
  54785. * @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)
  54786. * @param camera The camera that the post-process will be attached to
  54787. * @param mesh The mesh used to create the light scattering
  54788. * @param samples The post-process quality, default 100
  54789. * @param samplingModeThe post-process filtering mode
  54790. * @param engine The babylon engine
  54791. * @param reusable If the post-process is reusable
  54792. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54793. */
  54794. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54795. /**
  54796. * Returns the string "VolumetricLightScatteringPostProcess"
  54797. * @returns "VolumetricLightScatteringPostProcess"
  54798. */
  54799. getClassName(): string;
  54800. private _isReady;
  54801. /**
  54802. * Sets the new light position for light scattering effect
  54803. * @param position The new custom light position
  54804. */
  54805. setCustomMeshPosition(position: Vector3): void;
  54806. /**
  54807. * Returns the light position for light scattering effect
  54808. * @return Vector3 The custom light position
  54809. */
  54810. getCustomMeshPosition(): Vector3;
  54811. /**
  54812. * Disposes the internal assets and detaches the post-process from the camera
  54813. */
  54814. dispose(camera: Camera): void;
  54815. /**
  54816. * Returns the render target texture used by the post-process
  54817. * @return the render target texture used by the post-process
  54818. */
  54819. getPass(): RenderTargetTexture;
  54820. private _meshExcluded;
  54821. private _createPass;
  54822. private _updateMeshScreenCoordinates;
  54823. /**
  54824. * Creates a default mesh for the Volumeric Light Scattering post-process
  54825. * @param name The mesh name
  54826. * @param scene The scene where to create the mesh
  54827. * @return the default mesh
  54828. */
  54829. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54830. }
  54831. }
  54832. declare module "babylonjs/PostProcesses/index" {
  54833. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  54834. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  54835. export * from "babylonjs/PostProcesses/bloomEffect";
  54836. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  54837. export * from "babylonjs/PostProcesses/blurPostProcess";
  54838. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54839. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  54840. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  54841. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  54842. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54843. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  54844. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  54845. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  54846. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54847. export * from "babylonjs/PostProcesses/filterPostProcess";
  54848. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  54849. export * from "babylonjs/PostProcesses/grainPostProcess";
  54850. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  54851. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54852. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  54853. export * from "babylonjs/PostProcesses/passPostProcess";
  54854. export * from "babylonjs/PostProcesses/postProcess";
  54855. export * from "babylonjs/PostProcesses/postProcessManager";
  54856. export * from "babylonjs/PostProcesses/refractionPostProcess";
  54857. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  54858. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  54859. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  54860. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  54861. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  54862. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  54863. }
  54864. declare module "babylonjs/Probes/index" {
  54865. export * from "babylonjs/Probes/reflectionProbe";
  54866. }
  54867. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  54868. import { Scene } from "babylonjs/scene";
  54869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54870. import { Color3 } from "babylonjs/Maths/math";
  54871. import { SmartArray } from "babylonjs/Misc/smartArray";
  54872. import { ISceneComponent } from "babylonjs/sceneComponent";
  54873. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  54874. import "babylonjs/Meshes/Builders/boxBuilder";
  54875. import "babylonjs/Shaders/color.fragment";
  54876. import "babylonjs/Shaders/color.vertex";
  54877. module "babylonjs/scene" {
  54878. interface Scene {
  54879. /** @hidden (Backing field) */
  54880. _boundingBoxRenderer: BoundingBoxRenderer;
  54881. /** @hidden (Backing field) */
  54882. _forceShowBoundingBoxes: boolean;
  54883. /**
  54884. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54885. */
  54886. forceShowBoundingBoxes: boolean;
  54887. /**
  54888. * Gets the bounding box renderer associated with the scene
  54889. * @returns a BoundingBoxRenderer
  54890. */
  54891. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54892. }
  54893. }
  54894. module "babylonjs/Meshes/abstractMesh" {
  54895. interface AbstractMesh {
  54896. /** @hidden (Backing field) */
  54897. _showBoundingBox: boolean;
  54898. /**
  54899. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54900. */
  54901. showBoundingBox: boolean;
  54902. }
  54903. }
  54904. /**
  54905. * Component responsible of rendering the bounding box of the meshes in a scene.
  54906. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54907. */
  54908. export class BoundingBoxRenderer implements ISceneComponent {
  54909. /**
  54910. * The component name helpfull to identify the component in the list of scene components.
  54911. */
  54912. readonly name: string;
  54913. /**
  54914. * The scene the component belongs to.
  54915. */
  54916. scene: Scene;
  54917. /**
  54918. * Color of the bounding box lines placed in front of an object
  54919. */
  54920. frontColor: Color3;
  54921. /**
  54922. * Color of the bounding box lines placed behind an object
  54923. */
  54924. backColor: Color3;
  54925. /**
  54926. * Defines if the renderer should show the back lines or not
  54927. */
  54928. showBackLines: boolean;
  54929. /**
  54930. * @hidden
  54931. */
  54932. renderList: SmartArray<BoundingBox>;
  54933. private _colorShader;
  54934. private _vertexBuffers;
  54935. private _indexBuffer;
  54936. /**
  54937. * Instantiates a new bounding box renderer in a scene.
  54938. * @param scene the scene the renderer renders in
  54939. */
  54940. constructor(scene: Scene);
  54941. /**
  54942. * Registers the component in a given scene
  54943. */
  54944. register(): void;
  54945. private _evaluateSubMesh;
  54946. private _activeMesh;
  54947. private _prepareRessources;
  54948. private _createIndexBuffer;
  54949. /**
  54950. * Rebuilds the elements related to this component in case of
  54951. * context lost for instance.
  54952. */
  54953. rebuild(): void;
  54954. /**
  54955. * @hidden
  54956. */
  54957. reset(): void;
  54958. /**
  54959. * Render the bounding boxes of a specific rendering group
  54960. * @param renderingGroupId defines the rendering group to render
  54961. */
  54962. render(renderingGroupId: number): void;
  54963. /**
  54964. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54965. * @param mesh Define the mesh to render the occlusion bounding box for
  54966. */
  54967. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54968. /**
  54969. * Dispose and release the resources attached to this renderer.
  54970. */
  54971. dispose(): void;
  54972. }
  54973. }
  54974. declare module "babylonjs/Shaders/depth.fragment" {
  54975. /** @hidden */
  54976. export var depthPixelShader: {
  54977. name: string;
  54978. shader: string;
  54979. };
  54980. }
  54981. declare module "babylonjs/Rendering/depthRenderer" {
  54982. import { Nullable } from "babylonjs/types";
  54983. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54984. import { Scene } from "babylonjs/scene";
  54985. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54986. import { Camera } from "babylonjs/Cameras/camera";
  54987. import "babylonjs/Shaders/depth.fragment";
  54988. import "babylonjs/Shaders/depth.vertex";
  54989. /**
  54990. * This represents a depth renderer in Babylon.
  54991. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54992. */
  54993. export class DepthRenderer {
  54994. private _scene;
  54995. private _depthMap;
  54996. private _effect;
  54997. private _cachedDefines;
  54998. private _camera;
  54999. /**
  55000. * Specifiess that the depth renderer will only be used within
  55001. * the camera it is created for.
  55002. * This can help forcing its rendering during the camera processing.
  55003. */
  55004. useOnlyInActiveCamera: boolean;
  55005. /** @hidden */
  55006. static _SceneComponentInitialization: (scene: Scene) => void;
  55007. /**
  55008. * Instantiates a depth renderer
  55009. * @param scene The scene the renderer belongs to
  55010. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55011. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55012. */
  55013. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55014. /**
  55015. * Creates the depth rendering effect and checks if the effect is ready.
  55016. * @param subMesh The submesh to be used to render the depth map of
  55017. * @param useInstances If multiple world instances should be used
  55018. * @returns if the depth renderer is ready to render the depth map
  55019. */
  55020. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55021. /**
  55022. * Gets the texture which the depth map will be written to.
  55023. * @returns The depth map texture
  55024. */
  55025. getDepthMap(): RenderTargetTexture;
  55026. /**
  55027. * Disposes of the depth renderer.
  55028. */
  55029. dispose(): void;
  55030. }
  55031. }
  55032. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55033. import { Nullable } from "babylonjs/types";
  55034. import { Scene } from "babylonjs/scene";
  55035. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55036. import { Camera } from "babylonjs/Cameras/camera";
  55037. import { ISceneComponent } from "babylonjs/sceneComponent";
  55038. module "babylonjs/scene" {
  55039. interface Scene {
  55040. /** @hidden (Backing field) */
  55041. _depthRenderer: {
  55042. [id: string]: DepthRenderer;
  55043. };
  55044. /**
  55045. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55046. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55047. * @returns the created depth renderer
  55048. */
  55049. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55050. /**
  55051. * Disables a depth renderer for a given camera
  55052. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55053. */
  55054. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55055. }
  55056. }
  55057. /**
  55058. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55059. * in several rendering techniques.
  55060. */
  55061. export class DepthRendererSceneComponent implements ISceneComponent {
  55062. /**
  55063. * The component name helpfull to identify the component in the list of scene components.
  55064. */
  55065. readonly name: string;
  55066. /**
  55067. * The scene the component belongs to.
  55068. */
  55069. scene: Scene;
  55070. /**
  55071. * Creates a new instance of the component for the given scene
  55072. * @param scene Defines the scene to register the component in
  55073. */
  55074. constructor(scene: Scene);
  55075. /**
  55076. * Registers the component in a given scene
  55077. */
  55078. register(): void;
  55079. /**
  55080. * Rebuilds the elements related to this component in case of
  55081. * context lost for instance.
  55082. */
  55083. rebuild(): void;
  55084. /**
  55085. * Disposes the component and the associated ressources
  55086. */
  55087. dispose(): void;
  55088. private _gatherRenderTargets;
  55089. private _gatherActiveCameraRenderTargets;
  55090. }
  55091. }
  55092. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55093. import { Nullable } from "babylonjs/types";
  55094. import { Scene } from "babylonjs/scene";
  55095. import { ISceneComponent } from "babylonjs/sceneComponent";
  55096. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55097. module "babylonjs/scene" {
  55098. interface Scene {
  55099. /** @hidden (Backing field) */
  55100. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55101. /**
  55102. * Gets or Sets the current geometry buffer associated to the scene.
  55103. */
  55104. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55105. /**
  55106. * Enables a GeometryBufferRender and associates it with the scene
  55107. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55108. * @returns the GeometryBufferRenderer
  55109. */
  55110. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55111. /**
  55112. * Disables the GeometryBufferRender associated with the scene
  55113. */
  55114. disableGeometryBufferRenderer(): void;
  55115. }
  55116. }
  55117. /**
  55118. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55119. * in several rendering techniques.
  55120. */
  55121. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55122. /**
  55123. * The component name helpful to identify the component in the list of scene components.
  55124. */
  55125. readonly name: string;
  55126. /**
  55127. * The scene the component belongs to.
  55128. */
  55129. scene: Scene;
  55130. /**
  55131. * Creates a new instance of the component for the given scene
  55132. * @param scene Defines the scene to register the component in
  55133. */
  55134. constructor(scene: Scene);
  55135. /**
  55136. * Registers the component in a given scene
  55137. */
  55138. register(): void;
  55139. /**
  55140. * Rebuilds the elements related to this component in case of
  55141. * context lost for instance.
  55142. */
  55143. rebuild(): void;
  55144. /**
  55145. * Disposes the component and the associated ressources
  55146. */
  55147. dispose(): void;
  55148. private _gatherRenderTargets;
  55149. }
  55150. }
  55151. declare module "babylonjs/Shaders/outline.fragment" {
  55152. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55153. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55154. /** @hidden */
  55155. export var outlinePixelShader: {
  55156. name: string;
  55157. shader: string;
  55158. };
  55159. }
  55160. declare module "babylonjs/Shaders/outline.vertex" {
  55161. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55162. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55163. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55164. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55165. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55166. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55167. /** @hidden */
  55168. export var outlineVertexShader: {
  55169. name: string;
  55170. shader: string;
  55171. };
  55172. }
  55173. declare module "babylonjs/Rendering/outlineRenderer" {
  55174. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55175. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55176. import { Scene } from "babylonjs/scene";
  55177. import { ISceneComponent } from "babylonjs/sceneComponent";
  55178. import "babylonjs/Shaders/outline.fragment";
  55179. import "babylonjs/Shaders/outline.vertex";
  55180. module "babylonjs/scene" {
  55181. interface Scene {
  55182. /** @hidden */
  55183. _outlineRenderer: OutlineRenderer;
  55184. /**
  55185. * Gets the outline renderer associated with the scene
  55186. * @returns a OutlineRenderer
  55187. */
  55188. getOutlineRenderer(): OutlineRenderer;
  55189. }
  55190. }
  55191. module "babylonjs/Meshes/abstractMesh" {
  55192. interface AbstractMesh {
  55193. /** @hidden (Backing field) */
  55194. _renderOutline: boolean;
  55195. /**
  55196. * Gets or sets a boolean indicating if the outline must be rendered as well
  55197. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55198. */
  55199. renderOutline: boolean;
  55200. /** @hidden (Backing field) */
  55201. _renderOverlay: boolean;
  55202. /**
  55203. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55204. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55205. */
  55206. renderOverlay: boolean;
  55207. }
  55208. }
  55209. /**
  55210. * This class is responsible to draw bothe outline/overlay of meshes.
  55211. * It should not be used directly but through the available method on mesh.
  55212. */
  55213. export class OutlineRenderer implements ISceneComponent {
  55214. /**
  55215. * The name of the component. Each component must have a unique name.
  55216. */
  55217. name: string;
  55218. /**
  55219. * The scene the component belongs to.
  55220. */
  55221. scene: Scene;
  55222. /**
  55223. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55224. */
  55225. zOffset: number;
  55226. private _engine;
  55227. private _effect;
  55228. private _cachedDefines;
  55229. private _savedDepthWrite;
  55230. /**
  55231. * Instantiates a new outline renderer. (There could be only one per scene).
  55232. * @param scene Defines the scene it belongs to
  55233. */
  55234. constructor(scene: Scene);
  55235. /**
  55236. * Register the component to one instance of a scene.
  55237. */
  55238. register(): void;
  55239. /**
  55240. * Rebuilds the elements related to this component in case of
  55241. * context lost for instance.
  55242. */
  55243. rebuild(): void;
  55244. /**
  55245. * Disposes the component and the associated ressources.
  55246. */
  55247. dispose(): void;
  55248. /**
  55249. * Renders the outline in the canvas.
  55250. * @param subMesh Defines the sumesh to render
  55251. * @param batch Defines the batch of meshes in case of instances
  55252. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55253. */
  55254. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55255. /**
  55256. * Returns whether or not the outline renderer is ready for a given submesh.
  55257. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55258. * @param subMesh Defines the submesh to check readyness for
  55259. * @param useInstances Defines wheter wee are trying to render instances or not
  55260. * @returns true if ready otherwise false
  55261. */
  55262. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55263. private _beforeRenderingMesh;
  55264. private _afterRenderingMesh;
  55265. }
  55266. }
  55267. declare module "babylonjs/Rendering/index" {
  55268. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55269. export * from "babylonjs/Rendering/depthRenderer";
  55270. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55271. export * from "babylonjs/Rendering/edgesRenderer";
  55272. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55273. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55274. export * from "babylonjs/Rendering/outlineRenderer";
  55275. export * from "babylonjs/Rendering/renderingGroup";
  55276. export * from "babylonjs/Rendering/renderingManager";
  55277. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55278. }
  55279. declare module "babylonjs/Sprites/index" {
  55280. export * from "babylonjs/Sprites/sprite";
  55281. export * from "babylonjs/Sprites/spriteManager";
  55282. export * from "babylonjs/Sprites/spriteSceneComponent";
  55283. }
  55284. declare module "babylonjs/Misc/assetsManager" {
  55285. import { Scene } from "babylonjs/scene";
  55286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55287. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55288. import { Skeleton } from "babylonjs/Bones/skeleton";
  55289. import { Observable } from "babylonjs/Misc/observable";
  55290. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55291. import { Texture } from "babylonjs/Materials/Textures/texture";
  55292. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55293. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55294. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55295. /**
  55296. * Defines the list of states available for a task inside a AssetsManager
  55297. */
  55298. export enum AssetTaskState {
  55299. /**
  55300. * Initialization
  55301. */
  55302. INIT = 0,
  55303. /**
  55304. * Running
  55305. */
  55306. RUNNING = 1,
  55307. /**
  55308. * Done
  55309. */
  55310. DONE = 2,
  55311. /**
  55312. * Error
  55313. */
  55314. ERROR = 3
  55315. }
  55316. /**
  55317. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55318. */
  55319. export abstract class AbstractAssetTask {
  55320. /**
  55321. * Task name
  55322. */ name: string;
  55323. /**
  55324. * Callback called when the task is successful
  55325. */
  55326. onSuccess: (task: any) => void;
  55327. /**
  55328. * Callback called when the task is not successful
  55329. */
  55330. onError: (task: any, message?: string, exception?: any) => void;
  55331. /**
  55332. * Creates a new AssetsManager
  55333. * @param name defines the name of the task
  55334. */
  55335. constructor(
  55336. /**
  55337. * Task name
  55338. */ name: string);
  55339. private _isCompleted;
  55340. private _taskState;
  55341. private _errorObject;
  55342. /**
  55343. * Get if the task is completed
  55344. */
  55345. readonly isCompleted: boolean;
  55346. /**
  55347. * Gets the current state of the task
  55348. */
  55349. readonly taskState: AssetTaskState;
  55350. /**
  55351. * Gets the current error object (if task is in error)
  55352. */
  55353. readonly errorObject: {
  55354. message?: string;
  55355. exception?: any;
  55356. };
  55357. /**
  55358. * Internal only
  55359. * @hidden
  55360. */
  55361. _setErrorObject(message?: string, exception?: any): void;
  55362. /**
  55363. * Execute the current task
  55364. * @param scene defines the scene where you want your assets to be loaded
  55365. * @param onSuccess is a callback called when the task is successfully executed
  55366. * @param onError is a callback called if an error occurs
  55367. */
  55368. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55369. /**
  55370. * Execute the current task
  55371. * @param scene defines the scene where you want your assets to be loaded
  55372. * @param onSuccess is a callback called when the task is successfully executed
  55373. * @param onError is a callback called if an error occurs
  55374. */
  55375. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55376. /**
  55377. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55378. * This can be used with failed tasks that have the reason for failure fixed.
  55379. */
  55380. reset(): void;
  55381. private onErrorCallback;
  55382. private onDoneCallback;
  55383. }
  55384. /**
  55385. * Define the interface used by progress events raised during assets loading
  55386. */
  55387. export interface IAssetsProgressEvent {
  55388. /**
  55389. * Defines the number of remaining tasks to process
  55390. */
  55391. remainingCount: number;
  55392. /**
  55393. * Defines the total number of tasks
  55394. */
  55395. totalCount: number;
  55396. /**
  55397. * Defines the task that was just processed
  55398. */
  55399. task: AbstractAssetTask;
  55400. }
  55401. /**
  55402. * Class used to share progress information about assets loading
  55403. */
  55404. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55405. /**
  55406. * Defines the number of remaining tasks to process
  55407. */
  55408. remainingCount: number;
  55409. /**
  55410. * Defines the total number of tasks
  55411. */
  55412. totalCount: number;
  55413. /**
  55414. * Defines the task that was just processed
  55415. */
  55416. task: AbstractAssetTask;
  55417. /**
  55418. * Creates a AssetsProgressEvent
  55419. * @param remainingCount defines the number of remaining tasks to process
  55420. * @param totalCount defines the total number of tasks
  55421. * @param task defines the task that was just processed
  55422. */
  55423. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55424. }
  55425. /**
  55426. * Define a task used by AssetsManager to load meshes
  55427. */
  55428. export class MeshAssetTask extends AbstractAssetTask {
  55429. /**
  55430. * Defines the name of the task
  55431. */
  55432. name: string;
  55433. /**
  55434. * Defines the list of mesh's names you want to load
  55435. */
  55436. meshesNames: any;
  55437. /**
  55438. * Defines the root url to use as a base to load your meshes and associated resources
  55439. */
  55440. rootUrl: string;
  55441. /**
  55442. * Defines the filename of the scene to load from
  55443. */
  55444. sceneFilename: string;
  55445. /**
  55446. * Gets the list of loaded meshes
  55447. */
  55448. loadedMeshes: Array<AbstractMesh>;
  55449. /**
  55450. * Gets the list of loaded particle systems
  55451. */
  55452. loadedParticleSystems: Array<IParticleSystem>;
  55453. /**
  55454. * Gets the list of loaded skeletons
  55455. */
  55456. loadedSkeletons: Array<Skeleton>;
  55457. /**
  55458. * Gets the list of loaded animation groups
  55459. */
  55460. loadedAnimationGroups: Array<AnimationGroup>;
  55461. /**
  55462. * Callback called when the task is successful
  55463. */
  55464. onSuccess: (task: MeshAssetTask) => void;
  55465. /**
  55466. * Callback called when the task is successful
  55467. */
  55468. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55469. /**
  55470. * Creates a new MeshAssetTask
  55471. * @param name defines the name of the task
  55472. * @param meshesNames defines the list of mesh's names you want to load
  55473. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55474. * @param sceneFilename defines the filename of the scene to load from
  55475. */
  55476. constructor(
  55477. /**
  55478. * Defines the name of the task
  55479. */
  55480. name: string,
  55481. /**
  55482. * Defines the list of mesh's names you want to load
  55483. */
  55484. meshesNames: any,
  55485. /**
  55486. * Defines the root url to use as a base to load your meshes and associated resources
  55487. */
  55488. rootUrl: string,
  55489. /**
  55490. * Defines the filename of the scene to load from
  55491. */
  55492. sceneFilename: string);
  55493. /**
  55494. * Execute the current task
  55495. * @param scene defines the scene where you want your assets to be loaded
  55496. * @param onSuccess is a callback called when the task is successfully executed
  55497. * @param onError is a callback called if an error occurs
  55498. */
  55499. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55500. }
  55501. /**
  55502. * Define a task used by AssetsManager to load text content
  55503. */
  55504. export class TextFileAssetTask extends AbstractAssetTask {
  55505. /**
  55506. * Defines the name of the task
  55507. */
  55508. name: string;
  55509. /**
  55510. * Defines the location of the file to load
  55511. */
  55512. url: string;
  55513. /**
  55514. * Gets the loaded text string
  55515. */
  55516. text: string;
  55517. /**
  55518. * Callback called when the task is successful
  55519. */
  55520. onSuccess: (task: TextFileAssetTask) => void;
  55521. /**
  55522. * Callback called when the task is successful
  55523. */
  55524. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55525. /**
  55526. * Creates a new TextFileAssetTask object
  55527. * @param name defines the name of the task
  55528. * @param url defines the location of the file to load
  55529. */
  55530. constructor(
  55531. /**
  55532. * Defines the name of the task
  55533. */
  55534. name: string,
  55535. /**
  55536. * Defines the location of the file to load
  55537. */
  55538. url: string);
  55539. /**
  55540. * Execute the current task
  55541. * @param scene defines the scene where you want your assets to be loaded
  55542. * @param onSuccess is a callback called when the task is successfully executed
  55543. * @param onError is a callback called if an error occurs
  55544. */
  55545. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55546. }
  55547. /**
  55548. * Define a task used by AssetsManager to load binary data
  55549. */
  55550. export class BinaryFileAssetTask extends AbstractAssetTask {
  55551. /**
  55552. * Defines the name of the task
  55553. */
  55554. name: string;
  55555. /**
  55556. * Defines the location of the file to load
  55557. */
  55558. url: string;
  55559. /**
  55560. * Gets the lodaded data (as an array buffer)
  55561. */
  55562. data: ArrayBuffer;
  55563. /**
  55564. * Callback called when the task is successful
  55565. */
  55566. onSuccess: (task: BinaryFileAssetTask) => void;
  55567. /**
  55568. * Callback called when the task is successful
  55569. */
  55570. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55571. /**
  55572. * Creates a new BinaryFileAssetTask object
  55573. * @param name defines the name of the new task
  55574. * @param url defines the location of the file to load
  55575. */
  55576. constructor(
  55577. /**
  55578. * Defines the name of the task
  55579. */
  55580. name: string,
  55581. /**
  55582. * Defines the location of the file to load
  55583. */
  55584. url: string);
  55585. /**
  55586. * Execute the current task
  55587. * @param scene defines the scene where you want your assets to be loaded
  55588. * @param onSuccess is a callback called when the task is successfully executed
  55589. * @param onError is a callback called if an error occurs
  55590. */
  55591. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55592. }
  55593. /**
  55594. * Define a task used by AssetsManager to load images
  55595. */
  55596. export class ImageAssetTask extends AbstractAssetTask {
  55597. /**
  55598. * Defines the name of the task
  55599. */
  55600. name: string;
  55601. /**
  55602. * Defines the location of the image to load
  55603. */
  55604. url: string;
  55605. /**
  55606. * Gets the loaded images
  55607. */
  55608. image: HTMLImageElement;
  55609. /**
  55610. * Callback called when the task is successful
  55611. */
  55612. onSuccess: (task: ImageAssetTask) => void;
  55613. /**
  55614. * Callback called when the task is successful
  55615. */
  55616. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55617. /**
  55618. * Creates a new ImageAssetTask
  55619. * @param name defines the name of the task
  55620. * @param url defines the location of the image to load
  55621. */
  55622. constructor(
  55623. /**
  55624. * Defines the name of the task
  55625. */
  55626. name: string,
  55627. /**
  55628. * Defines the location of the image to load
  55629. */
  55630. url: string);
  55631. /**
  55632. * Execute the current task
  55633. * @param scene defines the scene where you want your assets to be loaded
  55634. * @param onSuccess is a callback called when the task is successfully executed
  55635. * @param onError is a callback called if an error occurs
  55636. */
  55637. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55638. }
  55639. /**
  55640. * Defines the interface used by texture loading tasks
  55641. */
  55642. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55643. /**
  55644. * Gets the loaded texture
  55645. */
  55646. texture: TEX;
  55647. }
  55648. /**
  55649. * Define a task used by AssetsManager to load 2D textures
  55650. */
  55651. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55652. /**
  55653. * Defines the name of the task
  55654. */
  55655. name: string;
  55656. /**
  55657. * Defines the location of the file to load
  55658. */
  55659. url: string;
  55660. /**
  55661. * Defines if mipmap should not be generated (default is false)
  55662. */
  55663. noMipmap?: boolean | undefined;
  55664. /**
  55665. * Defines if texture must be inverted on Y axis (default is false)
  55666. */
  55667. invertY?: boolean | undefined;
  55668. /**
  55669. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55670. */
  55671. samplingMode: number;
  55672. /**
  55673. * Gets the loaded texture
  55674. */
  55675. texture: Texture;
  55676. /**
  55677. * Callback called when the task is successful
  55678. */
  55679. onSuccess: (task: TextureAssetTask) => void;
  55680. /**
  55681. * Callback called when the task is successful
  55682. */
  55683. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55684. /**
  55685. * Creates a new TextureAssetTask object
  55686. * @param name defines the name of the task
  55687. * @param url defines the location of the file to load
  55688. * @param noMipmap defines if mipmap should not be generated (default is false)
  55689. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55690. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55691. */
  55692. constructor(
  55693. /**
  55694. * Defines the name of the task
  55695. */
  55696. name: string,
  55697. /**
  55698. * Defines the location of the file to load
  55699. */
  55700. url: string,
  55701. /**
  55702. * Defines if mipmap should not be generated (default is false)
  55703. */
  55704. noMipmap?: boolean | undefined,
  55705. /**
  55706. * Defines if texture must be inverted on Y axis (default is false)
  55707. */
  55708. invertY?: boolean | undefined,
  55709. /**
  55710. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55711. */
  55712. samplingMode?: number);
  55713. /**
  55714. * Execute the current task
  55715. * @param scene defines the scene where you want your assets to be loaded
  55716. * @param onSuccess is a callback called when the task is successfully executed
  55717. * @param onError is a callback called if an error occurs
  55718. */
  55719. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55720. }
  55721. /**
  55722. * Define a task used by AssetsManager to load cube textures
  55723. */
  55724. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55725. /**
  55726. * Defines the name of the task
  55727. */
  55728. name: string;
  55729. /**
  55730. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55731. */
  55732. url: string;
  55733. /**
  55734. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55735. */
  55736. extensions?: string[] | undefined;
  55737. /**
  55738. * Defines if mipmaps should not be generated (default is false)
  55739. */
  55740. noMipmap?: boolean | undefined;
  55741. /**
  55742. * Defines the explicit list of files (undefined by default)
  55743. */
  55744. files?: string[] | undefined;
  55745. /**
  55746. * Gets the loaded texture
  55747. */
  55748. texture: CubeTexture;
  55749. /**
  55750. * Callback called when the task is successful
  55751. */
  55752. onSuccess: (task: CubeTextureAssetTask) => void;
  55753. /**
  55754. * Callback called when the task is successful
  55755. */
  55756. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55757. /**
  55758. * Creates a new CubeTextureAssetTask
  55759. * @param name defines the name of the task
  55760. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55761. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55762. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55763. * @param files defines the explicit list of files (undefined by default)
  55764. */
  55765. constructor(
  55766. /**
  55767. * Defines the name of the task
  55768. */
  55769. name: string,
  55770. /**
  55771. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55772. */
  55773. url: string,
  55774. /**
  55775. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55776. */
  55777. extensions?: string[] | undefined,
  55778. /**
  55779. * Defines if mipmaps should not be generated (default is false)
  55780. */
  55781. noMipmap?: boolean | undefined,
  55782. /**
  55783. * Defines the explicit list of files (undefined by default)
  55784. */
  55785. files?: string[] | undefined);
  55786. /**
  55787. * Execute the current task
  55788. * @param scene defines the scene where you want your assets to be loaded
  55789. * @param onSuccess is a callback called when the task is successfully executed
  55790. * @param onError is a callback called if an error occurs
  55791. */
  55792. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55793. }
  55794. /**
  55795. * Define a task used by AssetsManager to load HDR cube textures
  55796. */
  55797. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55798. /**
  55799. * Defines the name of the task
  55800. */
  55801. name: string;
  55802. /**
  55803. * Defines the location of the file to load
  55804. */
  55805. url: string;
  55806. /**
  55807. * Defines the desired size (the more it increases the longer the generation will be)
  55808. */
  55809. size: number;
  55810. /**
  55811. * Defines if mipmaps should not be generated (default is false)
  55812. */
  55813. noMipmap: boolean;
  55814. /**
  55815. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55816. */
  55817. generateHarmonics: boolean;
  55818. /**
  55819. * 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)
  55820. */
  55821. gammaSpace: boolean;
  55822. /**
  55823. * Internal Use Only
  55824. */
  55825. reserved: boolean;
  55826. /**
  55827. * Gets the loaded texture
  55828. */
  55829. texture: HDRCubeTexture;
  55830. /**
  55831. * Callback called when the task is successful
  55832. */
  55833. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55834. /**
  55835. * Callback called when the task is successful
  55836. */
  55837. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55838. /**
  55839. * Creates a new HDRCubeTextureAssetTask object
  55840. * @param name defines the name of the task
  55841. * @param url defines the location of the file to load
  55842. * @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.
  55843. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55844. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55845. * @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)
  55846. * @param reserved Internal use only
  55847. */
  55848. constructor(
  55849. /**
  55850. * Defines the name of the task
  55851. */
  55852. name: string,
  55853. /**
  55854. * Defines the location of the file to load
  55855. */
  55856. url: string,
  55857. /**
  55858. * Defines the desired size (the more it increases the longer the generation will be)
  55859. */
  55860. size: number,
  55861. /**
  55862. * Defines if mipmaps should not be generated (default is false)
  55863. */
  55864. noMipmap?: boolean,
  55865. /**
  55866. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55867. */
  55868. generateHarmonics?: boolean,
  55869. /**
  55870. * 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)
  55871. */
  55872. gammaSpace?: boolean,
  55873. /**
  55874. * Internal Use Only
  55875. */
  55876. reserved?: boolean);
  55877. /**
  55878. * Execute the current task
  55879. * @param scene defines the scene where you want your assets to be loaded
  55880. * @param onSuccess is a callback called when the task is successfully executed
  55881. * @param onError is a callback called if an error occurs
  55882. */
  55883. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55884. }
  55885. /**
  55886. * This class can be used to easily import assets into a scene
  55887. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55888. */
  55889. export class AssetsManager {
  55890. private _scene;
  55891. private _isLoading;
  55892. protected _tasks: AbstractAssetTask[];
  55893. protected _waitingTasksCount: number;
  55894. protected _totalTasksCount: number;
  55895. /**
  55896. * Callback called when all tasks are processed
  55897. */
  55898. onFinish: (tasks: AbstractAssetTask[]) => void;
  55899. /**
  55900. * Callback called when a task is successful
  55901. */
  55902. onTaskSuccess: (task: AbstractAssetTask) => void;
  55903. /**
  55904. * Callback called when a task had an error
  55905. */
  55906. onTaskError: (task: AbstractAssetTask) => void;
  55907. /**
  55908. * Callback called when a task is done (whatever the result is)
  55909. */
  55910. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55911. /**
  55912. * Observable called when all tasks are processed
  55913. */
  55914. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55915. /**
  55916. * Observable called when a task had an error
  55917. */
  55918. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55919. /**
  55920. * Observable called when a task is successful
  55921. */
  55922. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55923. /**
  55924. * Observable called when a task is done (whatever the result is)
  55925. */
  55926. onProgressObservable: Observable<IAssetsProgressEvent>;
  55927. /**
  55928. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55929. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55930. */
  55931. useDefaultLoadingScreen: boolean;
  55932. /**
  55933. * Creates a new AssetsManager
  55934. * @param scene defines the scene to work on
  55935. */
  55936. constructor(scene: Scene);
  55937. /**
  55938. * Add a MeshAssetTask to the list of active tasks
  55939. * @param taskName defines the name of the new task
  55940. * @param meshesNames defines the name of meshes to load
  55941. * @param rootUrl defines the root url to use to locate files
  55942. * @param sceneFilename defines the filename of the scene file
  55943. * @returns a new MeshAssetTask object
  55944. */
  55945. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55946. /**
  55947. * Add a TextFileAssetTask to the list of active tasks
  55948. * @param taskName defines the name of the new task
  55949. * @param url defines the url of the file to load
  55950. * @returns a new TextFileAssetTask object
  55951. */
  55952. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55953. /**
  55954. * Add a BinaryFileAssetTask to the list of active tasks
  55955. * @param taskName defines the name of the new task
  55956. * @param url defines the url of the file to load
  55957. * @returns a new BinaryFileAssetTask object
  55958. */
  55959. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55960. /**
  55961. * Add a ImageAssetTask to the list of active tasks
  55962. * @param taskName defines the name of the new task
  55963. * @param url defines the url of the file to load
  55964. * @returns a new ImageAssetTask object
  55965. */
  55966. addImageTask(taskName: string, url: string): ImageAssetTask;
  55967. /**
  55968. * Add a TextureAssetTask to the list of active tasks
  55969. * @param taskName defines the name of the new task
  55970. * @param url defines the url of the file to load
  55971. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55972. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55973. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55974. * @returns a new TextureAssetTask object
  55975. */
  55976. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55977. /**
  55978. * Add a CubeTextureAssetTask to the list of active tasks
  55979. * @param taskName defines the name of the new task
  55980. * @param url defines the url of the file to load
  55981. * @param extensions defines the extension to use to load the cube map (can be null)
  55982. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55983. * @param files defines the list of files to load (can be null)
  55984. * @returns a new CubeTextureAssetTask object
  55985. */
  55986. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55987. /**
  55988. *
  55989. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55990. * @param taskName defines the name of the new task
  55991. * @param url defines the url of the file to load
  55992. * @param size defines the size you want for the cubemap (can be null)
  55993. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55994. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55995. * @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)
  55996. * @param reserved Internal use only
  55997. * @returns a new HDRCubeTextureAssetTask object
  55998. */
  55999. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56000. /**
  56001. * Remove a task from the assets manager.
  56002. * @param task the task to remove
  56003. */
  56004. removeTask(task: AbstractAssetTask): void;
  56005. private _decreaseWaitingTasksCount;
  56006. private _runTask;
  56007. /**
  56008. * Reset the AssetsManager and remove all tasks
  56009. * @return the current instance of the AssetsManager
  56010. */
  56011. reset(): AssetsManager;
  56012. /**
  56013. * Start the loading process
  56014. * @return the current instance of the AssetsManager
  56015. */
  56016. load(): AssetsManager;
  56017. }
  56018. }
  56019. declare module "babylonjs/Misc/deferred" {
  56020. /**
  56021. * Wrapper class for promise with external resolve and reject.
  56022. */
  56023. export class Deferred<T> {
  56024. /**
  56025. * The promise associated with this deferred object.
  56026. */
  56027. readonly promise: Promise<T>;
  56028. private _resolve;
  56029. private _reject;
  56030. /**
  56031. * The resolve method of the promise associated with this deferred object.
  56032. */
  56033. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56034. /**
  56035. * The reject method of the promise associated with this deferred object.
  56036. */
  56037. readonly reject: (reason?: any) => void;
  56038. /**
  56039. * Constructor for this deferred object.
  56040. */
  56041. constructor();
  56042. }
  56043. }
  56044. declare module "babylonjs/Misc/filesInput" {
  56045. import { Engine } from "babylonjs/Engines/engine";
  56046. import { Scene } from "babylonjs/scene";
  56047. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56048. /**
  56049. * Class used to help managing file picking and drag'n'drop
  56050. */
  56051. export class FilesInput {
  56052. /**
  56053. * List of files ready to be loaded
  56054. */
  56055. static readonly FilesToLoad: {
  56056. [key: string]: File;
  56057. };
  56058. /**
  56059. * Callback called when a file is processed
  56060. */
  56061. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56062. private _engine;
  56063. private _currentScene;
  56064. private _sceneLoadedCallback;
  56065. private _progressCallback;
  56066. private _additionalRenderLoopLogicCallback;
  56067. private _textureLoadingCallback;
  56068. private _startingProcessingFilesCallback;
  56069. private _onReloadCallback;
  56070. private _errorCallback;
  56071. private _elementToMonitor;
  56072. private _sceneFileToLoad;
  56073. private _filesToLoad;
  56074. /**
  56075. * Creates a new FilesInput
  56076. * @param engine defines the rendering engine
  56077. * @param scene defines the hosting scene
  56078. * @param sceneLoadedCallback callback called when scene is loaded
  56079. * @param progressCallback callback called to track progress
  56080. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56081. * @param textureLoadingCallback callback called when a texture is loading
  56082. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56083. * @param onReloadCallback callback called when a reload is requested
  56084. * @param errorCallback callback call if an error occurs
  56085. */
  56086. 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);
  56087. private _dragEnterHandler;
  56088. private _dragOverHandler;
  56089. private _dropHandler;
  56090. /**
  56091. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56092. * @param elementToMonitor defines the DOM element to track
  56093. */
  56094. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56095. /**
  56096. * Release all associated resources
  56097. */
  56098. dispose(): void;
  56099. private renderFunction;
  56100. private drag;
  56101. private drop;
  56102. private _traverseFolder;
  56103. private _processFiles;
  56104. /**
  56105. * Load files from a drop event
  56106. * @param event defines the drop event to use as source
  56107. */
  56108. loadFiles(event: any): void;
  56109. private _processReload;
  56110. /**
  56111. * Reload the current scene from the loaded files
  56112. */
  56113. reload(): void;
  56114. }
  56115. }
  56116. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56117. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56118. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56119. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56120. }
  56121. declare module "babylonjs/Misc/sceneOptimizer" {
  56122. import { Scene, IDisposable } from "babylonjs/scene";
  56123. import { Observable } from "babylonjs/Misc/observable";
  56124. /**
  56125. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56126. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56127. */
  56128. export class SceneOptimization {
  56129. /**
  56130. * Defines the priority of this optimization (0 by default which means first in the list)
  56131. */
  56132. priority: number;
  56133. /**
  56134. * Gets a string describing the action executed by the current optimization
  56135. * @returns description string
  56136. */
  56137. getDescription(): string;
  56138. /**
  56139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56140. * @param scene defines the current scene where to apply this optimization
  56141. * @param optimizer defines the current optimizer
  56142. * @returns true if everything that can be done was applied
  56143. */
  56144. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56145. /**
  56146. * Creates the SceneOptimization object
  56147. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56148. * @param desc defines the description associated with the optimization
  56149. */
  56150. constructor(
  56151. /**
  56152. * Defines the priority of this optimization (0 by default which means first in the list)
  56153. */
  56154. priority?: number);
  56155. }
  56156. /**
  56157. * Defines an optimization used to reduce the size of render target textures
  56158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56159. */
  56160. export class TextureOptimization extends SceneOptimization {
  56161. /**
  56162. * Defines the priority of this optimization (0 by default which means first in the list)
  56163. */
  56164. priority: number;
  56165. /**
  56166. * 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
  56167. */
  56168. maximumSize: number;
  56169. /**
  56170. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56171. */
  56172. step: number;
  56173. /**
  56174. * Gets a string describing the action executed by the current optimization
  56175. * @returns description string
  56176. */
  56177. getDescription(): string;
  56178. /**
  56179. * Creates the TextureOptimization object
  56180. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56181. * @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
  56182. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56183. */
  56184. constructor(
  56185. /**
  56186. * Defines the priority of this optimization (0 by default which means first in the list)
  56187. */
  56188. priority?: number,
  56189. /**
  56190. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  56191. */
  56192. maximumSize?: number,
  56193. /**
  56194. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56195. */
  56196. step?: number);
  56197. /**
  56198. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56199. * @param scene defines the current scene where to apply this optimization
  56200. * @param optimizer defines the current optimizer
  56201. * @returns true if everything that can be done was applied
  56202. */
  56203. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56204. }
  56205. /**
  56206. * Defines an optimization used to increase or decrease the rendering resolution
  56207. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56208. */
  56209. export class HardwareScalingOptimization extends SceneOptimization {
  56210. /**
  56211. * Defines the priority of this optimization (0 by default which means first in the list)
  56212. */
  56213. priority: number;
  56214. /**
  56215. * Defines the maximum scale to use (2 by default)
  56216. */
  56217. maximumScale: number;
  56218. /**
  56219. * Defines the step to use between two passes (0.5 by default)
  56220. */
  56221. step: number;
  56222. private _currentScale;
  56223. private _directionOffset;
  56224. /**
  56225. * Gets a string describing the action executed by the current optimization
  56226. * @return description string
  56227. */
  56228. getDescription(): string;
  56229. /**
  56230. * Creates the HardwareScalingOptimization object
  56231. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56232. * @param maximumScale defines the maximum scale to use (2 by default)
  56233. * @param step defines the step to use between two passes (0.5 by default)
  56234. */
  56235. constructor(
  56236. /**
  56237. * Defines the priority of this optimization (0 by default which means first in the list)
  56238. */
  56239. priority?: number,
  56240. /**
  56241. * Defines the maximum scale to use (2 by default)
  56242. */
  56243. maximumScale?: number,
  56244. /**
  56245. * Defines the step to use between two passes (0.5 by default)
  56246. */
  56247. step?: number);
  56248. /**
  56249. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56250. * @param scene defines the current scene where to apply this optimization
  56251. * @param optimizer defines the current optimizer
  56252. * @returns true if everything that can be done was applied
  56253. */
  56254. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56255. }
  56256. /**
  56257. * Defines an optimization used to remove shadows
  56258. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56259. */
  56260. export class ShadowsOptimization extends SceneOptimization {
  56261. /**
  56262. * Gets a string describing the action executed by the current optimization
  56263. * @return description string
  56264. */
  56265. getDescription(): string;
  56266. /**
  56267. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56268. * @param scene defines the current scene where to apply this optimization
  56269. * @param optimizer defines the current optimizer
  56270. * @returns true if everything that can be done was applied
  56271. */
  56272. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56273. }
  56274. /**
  56275. * Defines an optimization used to turn post-processes off
  56276. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56277. */
  56278. export class PostProcessesOptimization extends SceneOptimization {
  56279. /**
  56280. * Gets a string describing the action executed by the current optimization
  56281. * @return description string
  56282. */
  56283. getDescription(): string;
  56284. /**
  56285. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56286. * @param scene defines the current scene where to apply this optimization
  56287. * @param optimizer defines the current optimizer
  56288. * @returns true if everything that can be done was applied
  56289. */
  56290. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56291. }
  56292. /**
  56293. * Defines an optimization used to turn lens flares off
  56294. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56295. */
  56296. export class LensFlaresOptimization extends SceneOptimization {
  56297. /**
  56298. * Gets a string describing the action executed by the current optimization
  56299. * @return description string
  56300. */
  56301. getDescription(): string;
  56302. /**
  56303. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56304. * @param scene defines the current scene where to apply this optimization
  56305. * @param optimizer defines the current optimizer
  56306. * @returns true if everything that can be done was applied
  56307. */
  56308. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56309. }
  56310. /**
  56311. * Defines an optimization based on user defined callback.
  56312. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56313. */
  56314. export class CustomOptimization extends SceneOptimization {
  56315. /**
  56316. * Callback called to apply the custom optimization.
  56317. */
  56318. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56319. /**
  56320. * Callback called to get custom description
  56321. */
  56322. onGetDescription: () => string;
  56323. /**
  56324. * Gets a string describing the action executed by the current optimization
  56325. * @returns description string
  56326. */
  56327. getDescription(): string;
  56328. /**
  56329. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56330. * @param scene defines the current scene where to apply this optimization
  56331. * @param optimizer defines the current optimizer
  56332. * @returns true if everything that can be done was applied
  56333. */
  56334. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56335. }
  56336. /**
  56337. * Defines an optimization used to turn particles off
  56338. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56339. */
  56340. export class ParticlesOptimization extends SceneOptimization {
  56341. /**
  56342. * Gets a string describing the action executed by the current optimization
  56343. * @return description string
  56344. */
  56345. getDescription(): string;
  56346. /**
  56347. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56348. * @param scene defines the current scene where to apply this optimization
  56349. * @param optimizer defines the current optimizer
  56350. * @returns true if everything that can be done was applied
  56351. */
  56352. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56353. }
  56354. /**
  56355. * Defines an optimization used to turn render targets off
  56356. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56357. */
  56358. export class RenderTargetsOptimization extends SceneOptimization {
  56359. /**
  56360. * Gets a string describing the action executed by the current optimization
  56361. * @return description string
  56362. */
  56363. getDescription(): string;
  56364. /**
  56365. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56366. * @param scene defines the current scene where to apply this optimization
  56367. * @param optimizer defines the current optimizer
  56368. * @returns true if everything that can be done was applied
  56369. */
  56370. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56371. }
  56372. /**
  56373. * Defines an optimization used to merge meshes with compatible materials
  56374. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56375. */
  56376. export class MergeMeshesOptimization extends SceneOptimization {
  56377. private static _UpdateSelectionTree;
  56378. /**
  56379. * Gets or sets a boolean which defines if optimization octree has to be updated
  56380. */
  56381. /**
  56382. * Gets or sets a boolean which defines if optimization octree has to be updated
  56383. */
  56384. static UpdateSelectionTree: boolean;
  56385. /**
  56386. * Gets a string describing the action executed by the current optimization
  56387. * @return description string
  56388. */
  56389. getDescription(): string;
  56390. private _canBeMerged;
  56391. /**
  56392. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56393. * @param scene defines the current scene where to apply this optimization
  56394. * @param optimizer defines the current optimizer
  56395. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56396. * @returns true if everything that can be done was applied
  56397. */
  56398. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56399. }
  56400. /**
  56401. * Defines a list of options used by SceneOptimizer
  56402. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56403. */
  56404. export class SceneOptimizerOptions {
  56405. /**
  56406. * Defines the target frame rate to reach (60 by default)
  56407. */
  56408. targetFrameRate: number;
  56409. /**
  56410. * Defines the interval between two checkes (2000ms by default)
  56411. */
  56412. trackerDuration: number;
  56413. /**
  56414. * Gets the list of optimizations to apply
  56415. */
  56416. optimizations: SceneOptimization[];
  56417. /**
  56418. * Creates a new list of options used by SceneOptimizer
  56419. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56420. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56421. */
  56422. constructor(
  56423. /**
  56424. * Defines the target frame rate to reach (60 by default)
  56425. */
  56426. targetFrameRate?: number,
  56427. /**
  56428. * Defines the interval between two checkes (2000ms by default)
  56429. */
  56430. trackerDuration?: number);
  56431. /**
  56432. * Add a new optimization
  56433. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56434. * @returns the current SceneOptimizerOptions
  56435. */
  56436. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56437. /**
  56438. * Add a new custom optimization
  56439. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56440. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56441. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56442. * @returns the current SceneOptimizerOptions
  56443. */
  56444. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56445. /**
  56446. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56447. * @param targetFrameRate defines the target frame rate (60 by default)
  56448. * @returns a SceneOptimizerOptions object
  56449. */
  56450. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56451. /**
  56452. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56453. * @param targetFrameRate defines the target frame rate (60 by default)
  56454. * @returns a SceneOptimizerOptions object
  56455. */
  56456. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56457. /**
  56458. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56459. * @param targetFrameRate defines the target frame rate (60 by default)
  56460. * @returns a SceneOptimizerOptions object
  56461. */
  56462. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56463. }
  56464. /**
  56465. * Class used to run optimizations in order to reach a target frame rate
  56466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56467. */
  56468. export class SceneOptimizer implements IDisposable {
  56469. private _isRunning;
  56470. private _options;
  56471. private _scene;
  56472. private _currentPriorityLevel;
  56473. private _targetFrameRate;
  56474. private _trackerDuration;
  56475. private _currentFrameRate;
  56476. private _sceneDisposeObserver;
  56477. private _improvementMode;
  56478. /**
  56479. * Defines an observable called when the optimizer reaches the target frame rate
  56480. */
  56481. onSuccessObservable: Observable<SceneOptimizer>;
  56482. /**
  56483. * Defines an observable called when the optimizer enables an optimization
  56484. */
  56485. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56486. /**
  56487. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56488. */
  56489. onFailureObservable: Observable<SceneOptimizer>;
  56490. /**
  56491. * Gets a boolean indicating if the optimizer is in improvement mode
  56492. */
  56493. readonly isInImprovementMode: boolean;
  56494. /**
  56495. * Gets the current priority level (0 at start)
  56496. */
  56497. readonly currentPriorityLevel: number;
  56498. /**
  56499. * Gets the current frame rate checked by the SceneOptimizer
  56500. */
  56501. readonly currentFrameRate: number;
  56502. /**
  56503. * Gets or sets the current target frame rate (60 by default)
  56504. */
  56505. /**
  56506. * Gets or sets the current target frame rate (60 by default)
  56507. */
  56508. targetFrameRate: number;
  56509. /**
  56510. * Gets or sets the current interval between two checks (every 2000ms by default)
  56511. */
  56512. /**
  56513. * Gets or sets the current interval between two checks (every 2000ms by default)
  56514. */
  56515. trackerDuration: number;
  56516. /**
  56517. * Gets the list of active optimizations
  56518. */
  56519. readonly optimizations: SceneOptimization[];
  56520. /**
  56521. * Creates a new SceneOptimizer
  56522. * @param scene defines the scene to work on
  56523. * @param options defines the options to use with the SceneOptimizer
  56524. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56525. * @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)
  56526. */
  56527. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56528. /**
  56529. * Stops the current optimizer
  56530. */
  56531. stop(): void;
  56532. /**
  56533. * Reset the optimizer to initial step (current priority level = 0)
  56534. */
  56535. reset(): void;
  56536. /**
  56537. * Start the optimizer. By default it will try to reach a specific framerate
  56538. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56539. */
  56540. start(): void;
  56541. private _checkCurrentState;
  56542. /**
  56543. * Release all resources
  56544. */
  56545. dispose(): void;
  56546. /**
  56547. * Helper function to create a SceneOptimizer with one single line of code
  56548. * @param scene defines the scene to work on
  56549. * @param options defines the options to use with the SceneOptimizer
  56550. * @param onSuccess defines a callback to call on success
  56551. * @param onFailure defines a callback to call on failure
  56552. * @returns the new SceneOptimizer object
  56553. */
  56554. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56555. }
  56556. }
  56557. declare module "babylonjs/Misc/sceneSerializer" {
  56558. import { Scene } from "babylonjs/scene";
  56559. /**
  56560. * Class used to serialize a scene into a string
  56561. */
  56562. export class SceneSerializer {
  56563. /**
  56564. * Clear cache used by a previous serialization
  56565. */
  56566. static ClearCache(): void;
  56567. /**
  56568. * Serialize a scene into a JSON compatible object
  56569. * @param scene defines the scene to serialize
  56570. * @returns a JSON compatible object
  56571. */
  56572. static Serialize(scene: Scene): any;
  56573. /**
  56574. * Serialize a mesh into a JSON compatible object
  56575. * @param toSerialize defines the mesh to serialize
  56576. * @param withParents defines if parents must be serialized as well
  56577. * @param withChildren defines if children must be serialized as well
  56578. * @returns a JSON compatible object
  56579. */
  56580. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56581. }
  56582. }
  56583. declare module "babylonjs/Misc/videoRecorder" {
  56584. import { Nullable } from "babylonjs/types";
  56585. import { Engine } from "babylonjs/Engines/engine";
  56586. /**
  56587. * This represents the different options avilable for the video capture.
  56588. */
  56589. export interface VideoRecorderOptions {
  56590. /** Defines the mime type of the video */
  56591. mimeType: string;
  56592. /** Defines the video the video should be recorded at */
  56593. fps: number;
  56594. /** Defines the chunk size for the recording data */
  56595. recordChunckSize: number;
  56596. /** The audio tracks to attach to the record */
  56597. audioTracks?: MediaStreamTrack[];
  56598. }
  56599. /**
  56600. * This can helps recording videos from BabylonJS.
  56601. * This is based on the available WebRTC functionalities of the browser.
  56602. *
  56603. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56604. */
  56605. export class VideoRecorder {
  56606. private static readonly _defaultOptions;
  56607. /**
  56608. * Returns wehther or not the VideoRecorder is available in your browser.
  56609. * @param engine Defines the Babylon Engine to check the support for
  56610. * @returns true if supported otherwise false
  56611. */
  56612. static IsSupported(engine: Engine): boolean;
  56613. private readonly _options;
  56614. private _canvas;
  56615. private _mediaRecorder;
  56616. private _recordedChunks;
  56617. private _fileName;
  56618. private _resolve;
  56619. private _reject;
  56620. /**
  56621. * True wether a recording is already in progress.
  56622. */
  56623. readonly isRecording: boolean;
  56624. /**
  56625. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56626. * a video file.
  56627. * @param engine Defines the BabylonJS Engine you wish to record
  56628. * @param options Defines options that can be used to customized the capture
  56629. */
  56630. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56631. /**
  56632. * Stops the current recording before the default capture timeout passed in the startRecording
  56633. * functions.
  56634. */
  56635. stopRecording(): void;
  56636. /**
  56637. * Starts recording the canvas for a max duration specified in parameters.
  56638. * @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.
  56639. * @param maxDuration Defines the maximum recording time in seconds.
  56640. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56641. * @return a promise callback at the end of the recording with the video data in Blob.
  56642. */
  56643. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56644. /**
  56645. * Releases internal resources used during the recording.
  56646. */
  56647. dispose(): void;
  56648. private _handleDataAvailable;
  56649. private _handleError;
  56650. private _handleStop;
  56651. }
  56652. }
  56653. declare module "babylonjs/Misc/workerPool" {
  56654. import { IDisposable } from "babylonjs/scene";
  56655. /**
  56656. * Helper class to push actions to a pool of workers.
  56657. */
  56658. export class WorkerPool implements IDisposable {
  56659. private _workerInfos;
  56660. private _pendingActions;
  56661. /**
  56662. * Constructor
  56663. * @param workers Array of workers to use for actions
  56664. */
  56665. constructor(workers: Array<Worker>);
  56666. /**
  56667. * Terminates all workers and clears any pending actions.
  56668. */
  56669. dispose(): void;
  56670. /**
  56671. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56672. * pended until a worker has completed its action.
  56673. * @param action The action to perform. Call onComplete when the action is complete.
  56674. */
  56675. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56676. private _execute;
  56677. }
  56678. }
  56679. declare module "babylonjs/Misc/screenshotTools" {
  56680. import { Camera } from "babylonjs/Cameras/camera";
  56681. import { Engine } from "babylonjs/Engines/engine";
  56682. /**
  56683. * Class containing a set of static utilities functions for screenshots
  56684. */
  56685. export class ScreenshotTools {
  56686. /**
  56687. * Captures a screenshot of the current rendering
  56688. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56689. * @param engine defines the rendering engine
  56690. * @param camera defines the source camera
  56691. * @param size This parameter can be set to a single number or to an object with the
  56692. * following (optional) properties: precision, width, height. If a single number is passed,
  56693. * it will be used for both width and height. If an object is passed, the screenshot size
  56694. * will be derived from the parameters. The precision property is a multiplier allowing
  56695. * rendering at a higher or lower resolution
  56696. * @param successCallback defines the callback receives a single parameter which contains the
  56697. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56698. * src parameter of an <img> to display it
  56699. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56700. * Check your browser for supported MIME types
  56701. */
  56702. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56703. /**
  56704. * Generates an image screenshot from the specified camera.
  56705. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56706. * @param engine The engine to use for rendering
  56707. * @param camera The camera to use for rendering
  56708. * @param size This parameter can be set to a single number or to an object with the
  56709. * following (optional) properties: precision, width, height. If a single number is passed,
  56710. * it will be used for both width and height. If an object is passed, the screenshot size
  56711. * will be derived from the parameters. The precision property is a multiplier allowing
  56712. * rendering at a higher or lower resolution
  56713. * @param successCallback The callback receives a single parameter which contains the
  56714. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56715. * src parameter of an <img> to display it
  56716. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56717. * Check your browser for supported MIME types
  56718. * @param samples Texture samples (default: 1)
  56719. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56720. * @param fileName A name for for the downloaded file.
  56721. */
  56722. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56723. }
  56724. }
  56725. declare module "babylonjs/Misc/index" {
  56726. export * from "babylonjs/Misc/andOrNotEvaluator";
  56727. export * from "babylonjs/Misc/assetsManager";
  56728. export * from "babylonjs/Misc/dds";
  56729. export * from "babylonjs/Misc/decorators";
  56730. export * from "babylonjs/Misc/deferred";
  56731. export * from "babylonjs/Misc/environmentTextureTools";
  56732. export * from "babylonjs/Misc/filesInput";
  56733. export * from "babylonjs/Misc/HighDynamicRange/index";
  56734. export * from "babylonjs/Misc/khronosTextureContainer";
  56735. export * from "babylonjs/Misc/observable";
  56736. export * from "babylonjs/Misc/performanceMonitor";
  56737. export * from "babylonjs/Misc/promise";
  56738. export * from "babylonjs/Misc/sceneOptimizer";
  56739. export * from "babylonjs/Misc/sceneSerializer";
  56740. export * from "babylonjs/Misc/smartArray";
  56741. export * from "babylonjs/Misc/stringDictionary";
  56742. export * from "babylonjs/Misc/tags";
  56743. export * from "babylonjs/Misc/textureTools";
  56744. export * from "babylonjs/Misc/tga";
  56745. export * from "babylonjs/Misc/tools";
  56746. export * from "babylonjs/Misc/videoRecorder";
  56747. export * from "babylonjs/Misc/virtualJoystick";
  56748. export * from "babylonjs/Misc/workerPool";
  56749. export * from "babylonjs/Misc/logger";
  56750. export * from "babylonjs/Misc/typeStore";
  56751. export * from "babylonjs/Misc/filesInputStore";
  56752. export * from "babylonjs/Misc/deepCopier";
  56753. export * from "babylonjs/Misc/pivotTools";
  56754. export * from "babylonjs/Misc/precisionDate";
  56755. export * from "babylonjs/Misc/screenshotTools";
  56756. export * from "babylonjs/Misc/typeStore";
  56757. }
  56758. declare module "babylonjs/index" {
  56759. export * from "babylonjs/abstractScene";
  56760. export * from "babylonjs/Actions/index";
  56761. export * from "babylonjs/Animations/index";
  56762. export * from "babylonjs/assetContainer";
  56763. export * from "babylonjs/Audio/index";
  56764. export * from "babylonjs/Behaviors/index";
  56765. export * from "babylonjs/Bones/index";
  56766. export * from "babylonjs/Cameras/index";
  56767. export * from "babylonjs/Collisions/index";
  56768. export * from "babylonjs/Culling/index";
  56769. export * from "babylonjs/Debug/index";
  56770. export * from "babylonjs/Engines/index";
  56771. export * from "babylonjs/Events/index";
  56772. export * from "babylonjs/Gamepads/index";
  56773. export * from "babylonjs/Gizmos/index";
  56774. export * from "babylonjs/Helpers/index";
  56775. export * from "babylonjs/Instrumentation/index";
  56776. export * from "babylonjs/Layers/index";
  56777. export * from "babylonjs/LensFlares/index";
  56778. export * from "babylonjs/Lights/index";
  56779. export * from "babylonjs/Loading/index";
  56780. export * from "babylonjs/Materials/index";
  56781. export * from "babylonjs/Maths/index";
  56782. export * from "babylonjs/Meshes/index";
  56783. export * from "babylonjs/Morph/index";
  56784. export * from "babylonjs/node";
  56785. export * from "babylonjs/Offline/index";
  56786. export * from "babylonjs/Particles/index";
  56787. export * from "babylonjs/Physics/index";
  56788. export * from "babylonjs/PostProcesses/index";
  56789. export * from "babylonjs/Probes/index";
  56790. export * from "babylonjs/Rendering/index";
  56791. export * from "babylonjs/scene";
  56792. export * from "babylonjs/sceneComponent";
  56793. export * from "babylonjs/Sprites/index";
  56794. export * from "babylonjs/States/index";
  56795. export * from "babylonjs/Misc/index";
  56796. export * from "babylonjs/types";
  56797. }
  56798. declare module "babylonjs/Animations/pathCursor" {
  56799. import { Path2, Vector3 } from "babylonjs/Maths/math";
  56800. /**
  56801. * A cursor which tracks a point on a path
  56802. */
  56803. export class PathCursor {
  56804. private path;
  56805. /**
  56806. * Stores path cursor callbacks for when an onchange event is triggered
  56807. */
  56808. private _onchange;
  56809. /**
  56810. * The value of the path cursor
  56811. */
  56812. value: number;
  56813. /**
  56814. * The animation array of the path cursor
  56815. */
  56816. animations: Animation[];
  56817. /**
  56818. * Initializes the path cursor
  56819. * @param path The path to track
  56820. */
  56821. constructor(path: Path2);
  56822. /**
  56823. * Gets the cursor point on the path
  56824. * @returns A point on the path cursor at the cursor location
  56825. */
  56826. getPoint(): Vector3;
  56827. /**
  56828. * Moves the cursor ahead by the step amount
  56829. * @param step The amount to move the cursor forward
  56830. * @returns This path cursor
  56831. */
  56832. moveAhead(step?: number): PathCursor;
  56833. /**
  56834. * Moves the cursor behind by the step amount
  56835. * @param step The amount to move the cursor back
  56836. * @returns This path cursor
  56837. */
  56838. moveBack(step?: number): PathCursor;
  56839. /**
  56840. * Moves the cursor by the step amount
  56841. * If the step amount is greater than one, an exception is thrown
  56842. * @param step The amount to move the cursor
  56843. * @returns This path cursor
  56844. */
  56845. move(step: number): PathCursor;
  56846. /**
  56847. * Ensures that the value is limited between zero and one
  56848. * @returns This path cursor
  56849. */
  56850. private ensureLimits;
  56851. /**
  56852. * Runs onchange callbacks on change (used by the animation engine)
  56853. * @returns This path cursor
  56854. */
  56855. private raiseOnChange;
  56856. /**
  56857. * Executes a function on change
  56858. * @param f A path cursor onchange callback
  56859. * @returns This path cursor
  56860. */
  56861. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56862. }
  56863. }
  56864. declare module "babylonjs/Legacy/legacy" {
  56865. import * as Babylon from "babylonjs/index";
  56866. export * from "babylonjs/index";
  56867. }
  56868. declare module "babylonjs/Shaders/blur.fragment" {
  56869. /** @hidden */
  56870. export var blurPixelShader: {
  56871. name: string;
  56872. shader: string;
  56873. };
  56874. }
  56875. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  56876. /** @hidden */
  56877. export var bones300Declaration: {
  56878. name: string;
  56879. shader: string;
  56880. };
  56881. }
  56882. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  56883. /** @hidden */
  56884. export var instances300Declaration: {
  56885. name: string;
  56886. shader: string;
  56887. };
  56888. }
  56889. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  56890. /** @hidden */
  56891. export var pointCloudVertexDeclaration: {
  56892. name: string;
  56893. shader: string;
  56894. };
  56895. }
  56896. // Mixins
  56897. interface Window {
  56898. mozIndexedDB: IDBFactory;
  56899. webkitIndexedDB: IDBFactory;
  56900. msIndexedDB: IDBFactory;
  56901. webkitURL: typeof URL;
  56902. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56903. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56904. WebGLRenderingContext: WebGLRenderingContext;
  56905. MSGesture: MSGesture;
  56906. CANNON: any;
  56907. AudioContext: AudioContext;
  56908. webkitAudioContext: AudioContext;
  56909. PointerEvent: any;
  56910. Math: Math;
  56911. Uint8Array: Uint8ArrayConstructor;
  56912. Float32Array: Float32ArrayConstructor;
  56913. mozURL: typeof URL;
  56914. msURL: typeof URL;
  56915. VRFrameData: any; // WebVR, from specs 1.1
  56916. DracoDecoderModule: any;
  56917. setImmediate(handler: (...args: any[]) => void): number;
  56918. }
  56919. interface Document {
  56920. mozCancelFullScreen(): void;
  56921. msCancelFullScreen(): void;
  56922. webkitCancelFullScreen(): void;
  56923. requestPointerLock(): void;
  56924. exitPointerLock(): void;
  56925. mozFullScreen: boolean;
  56926. msIsFullScreen: boolean;
  56927. readonly webkitIsFullScreen: boolean;
  56928. readonly pointerLockElement: Element;
  56929. mozPointerLockElement: HTMLElement;
  56930. msPointerLockElement: HTMLElement;
  56931. webkitPointerLockElement: HTMLElement;
  56932. }
  56933. interface HTMLCanvasElement {
  56934. requestPointerLock(): void;
  56935. msRequestPointerLock?(): void;
  56936. mozRequestPointerLock?(): void;
  56937. webkitRequestPointerLock?(): void;
  56938. /** Track wether a record is in progress */
  56939. isRecording: boolean;
  56940. /** Capture Stream method defined by some browsers */
  56941. captureStream(fps?: number): MediaStream;
  56942. }
  56943. interface CanvasRenderingContext2D {
  56944. msImageSmoothingEnabled: boolean;
  56945. }
  56946. interface MouseEvent {
  56947. mozMovementX: number;
  56948. mozMovementY: number;
  56949. webkitMovementX: number;
  56950. webkitMovementY: number;
  56951. msMovementX: number;
  56952. msMovementY: number;
  56953. }
  56954. interface Navigator {
  56955. mozGetVRDevices: (any: any) => any;
  56956. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56957. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56958. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56959. webkitGetGamepads(): Gamepad[];
  56960. msGetGamepads(): Gamepad[];
  56961. webkitGamepads(): Gamepad[];
  56962. }
  56963. interface HTMLVideoElement {
  56964. mozSrcObject: any;
  56965. }
  56966. interface Math {
  56967. fround(x: number): number;
  56968. imul(a: number, b: number): number;
  56969. }
  56970. interface WebGLProgram {
  56971. context?: WebGLRenderingContext;
  56972. vertexShader?: WebGLShader;
  56973. fragmentShader?: WebGLShader;
  56974. isParallelCompiled: boolean;
  56975. onCompiled?: () => void;
  56976. }
  56977. interface WebGLRenderingContext {
  56978. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56979. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56980. vertexAttribDivisor(index: number, divisor: number): void;
  56981. createVertexArray(): any;
  56982. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56983. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56984. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56985. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56986. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56987. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56988. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56989. // Queries
  56990. createQuery(): WebGLQuery;
  56991. deleteQuery(query: WebGLQuery): void;
  56992. beginQuery(target: number, query: WebGLQuery): void;
  56993. endQuery(target: number): void;
  56994. getQueryParameter(query: WebGLQuery, pname: number): any;
  56995. getQuery(target: number, pname: number): any;
  56996. MAX_SAMPLES: number;
  56997. RGBA8: number;
  56998. READ_FRAMEBUFFER: number;
  56999. DRAW_FRAMEBUFFER: number;
  57000. UNIFORM_BUFFER: number;
  57001. HALF_FLOAT_OES: number;
  57002. RGBA16F: number;
  57003. RGBA32F: number;
  57004. R32F: number;
  57005. RG32F: number;
  57006. RGB32F: number;
  57007. R16F: number;
  57008. RG16F: number;
  57009. RGB16F: number;
  57010. RED: number;
  57011. RG: number;
  57012. R8: number;
  57013. RG8: number;
  57014. UNSIGNED_INT_24_8: number;
  57015. DEPTH24_STENCIL8: number;
  57016. /* Multiple Render Targets */
  57017. drawBuffers(buffers: number[]): void;
  57018. readBuffer(src: number): void;
  57019. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57020. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57021. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57022. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57023. // Occlusion Query
  57024. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57025. ANY_SAMPLES_PASSED: number;
  57026. QUERY_RESULT_AVAILABLE: number;
  57027. QUERY_RESULT: number;
  57028. }
  57029. interface WebGLBuffer {
  57030. references: number;
  57031. capacity: number;
  57032. is32Bits: boolean;
  57033. }
  57034. interface WebGLProgram {
  57035. transformFeedback?: WebGLTransformFeedback | null;
  57036. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57037. }
  57038. interface EXT_disjoint_timer_query {
  57039. QUERY_COUNTER_BITS_EXT: number;
  57040. TIME_ELAPSED_EXT: number;
  57041. TIMESTAMP_EXT: number;
  57042. GPU_DISJOINT_EXT: number;
  57043. QUERY_RESULT_EXT: number;
  57044. QUERY_RESULT_AVAILABLE_EXT: number;
  57045. queryCounterEXT(query: WebGLQuery, target: number): void;
  57046. createQueryEXT(): WebGLQuery;
  57047. beginQueryEXT(target: number, query: WebGLQuery): void;
  57048. endQueryEXT(target: number): void;
  57049. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57050. deleteQueryEXT(query: WebGLQuery): void;
  57051. }
  57052. interface WebGLUniformLocation {
  57053. _currentState: any;
  57054. }
  57055. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57056. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57057. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57058. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57059. interface WebGLRenderingContext {
  57060. readonly RASTERIZER_DISCARD: number;
  57061. readonly DEPTH_COMPONENT24: number;
  57062. readonly TEXTURE_3D: number;
  57063. readonly TEXTURE_2D_ARRAY: number;
  57064. readonly TEXTURE_COMPARE_FUNC: number;
  57065. readonly TEXTURE_COMPARE_MODE: number;
  57066. readonly COMPARE_REF_TO_TEXTURE: number;
  57067. readonly TEXTURE_WRAP_R: number;
  57068. readonly HALF_FLOAT: number;
  57069. readonly RGB8: number;
  57070. readonly RED_INTEGER: number;
  57071. readonly RG_INTEGER: number;
  57072. readonly RGB_INTEGER: number;
  57073. readonly RGBA_INTEGER: number;
  57074. readonly R8_SNORM: number;
  57075. readonly RG8_SNORM: number;
  57076. readonly RGB8_SNORM: number;
  57077. readonly RGBA8_SNORM: number;
  57078. readonly R8I: number;
  57079. readonly RG8I: number;
  57080. readonly RGB8I: number;
  57081. readonly RGBA8I: number;
  57082. readonly R8UI: number;
  57083. readonly RG8UI: number;
  57084. readonly RGB8UI: number;
  57085. readonly RGBA8UI: number;
  57086. readonly R16I: number;
  57087. readonly RG16I: number;
  57088. readonly RGB16I: number;
  57089. readonly RGBA16I: number;
  57090. readonly R16UI: number;
  57091. readonly RG16UI: number;
  57092. readonly RGB16UI: number;
  57093. readonly RGBA16UI: number;
  57094. readonly R32I: number;
  57095. readonly RG32I: number;
  57096. readonly RGB32I: number;
  57097. readonly RGBA32I: number;
  57098. readonly R32UI: number;
  57099. readonly RG32UI: number;
  57100. readonly RGB32UI: number;
  57101. readonly RGBA32UI: number;
  57102. readonly RGB10_A2UI: number;
  57103. readonly R11F_G11F_B10F: number;
  57104. readonly RGB9_E5: number;
  57105. readonly RGB10_A2: number;
  57106. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57107. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57108. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57109. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57110. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57111. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57112. 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;
  57113. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57114. readonly TRANSFORM_FEEDBACK: number;
  57115. readonly INTERLEAVED_ATTRIBS: number;
  57116. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57117. createTransformFeedback(): WebGLTransformFeedback;
  57118. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57119. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57120. beginTransformFeedback(primitiveMode: number): void;
  57121. endTransformFeedback(): void;
  57122. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57123. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57124. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57125. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57126. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57127. }
  57128. interface ImageBitmap {
  57129. readonly width: number;
  57130. readonly height: number;
  57131. close(): void;
  57132. }
  57133. interface WebGLQuery extends WebGLObject {
  57134. }
  57135. declare var WebGLQuery: {
  57136. prototype: WebGLQuery;
  57137. new(): WebGLQuery;
  57138. };
  57139. interface WebGLSampler extends WebGLObject {
  57140. }
  57141. declare var WebGLSampler: {
  57142. prototype: WebGLSampler;
  57143. new(): WebGLSampler;
  57144. };
  57145. interface WebGLSync extends WebGLObject {
  57146. }
  57147. declare var WebGLSync: {
  57148. prototype: WebGLSync;
  57149. new(): WebGLSync;
  57150. };
  57151. interface WebGLTransformFeedback extends WebGLObject {
  57152. }
  57153. declare var WebGLTransformFeedback: {
  57154. prototype: WebGLTransformFeedback;
  57155. new(): WebGLTransformFeedback;
  57156. };
  57157. interface WebGLVertexArrayObject extends WebGLObject {
  57158. }
  57159. declare var WebGLVertexArrayObject: {
  57160. prototype: WebGLVertexArrayObject;
  57161. new(): WebGLVertexArrayObject;
  57162. };
  57163. // Type definitions for WebVR API
  57164. // Project: https://w3c.github.io/webvr/
  57165. // Definitions by: six a <https://github.com/lostfictions>
  57166. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57167. interface VRDisplay extends EventTarget {
  57168. /**
  57169. * Dictionary of capabilities describing the VRDisplay.
  57170. */
  57171. readonly capabilities: VRDisplayCapabilities;
  57172. /**
  57173. * z-depth defining the far plane of the eye view frustum
  57174. * enables mapping of values in the render target depth
  57175. * attachment to scene coordinates. Initially set to 10000.0.
  57176. */
  57177. depthFar: number;
  57178. /**
  57179. * z-depth defining the near plane of the eye view frustum
  57180. * enables mapping of values in the render target depth
  57181. * attachment to scene coordinates. Initially set to 0.01.
  57182. */
  57183. depthNear: number;
  57184. /**
  57185. * An identifier for this distinct VRDisplay. Used as an
  57186. * association point in the Gamepad API.
  57187. */
  57188. readonly displayId: number;
  57189. /**
  57190. * A display name, a user-readable name identifying it.
  57191. */
  57192. readonly displayName: string;
  57193. readonly isConnected: boolean;
  57194. readonly isPresenting: boolean;
  57195. /**
  57196. * If this VRDisplay supports room-scale experiences, the optional
  57197. * stage attribute contains details on the room-scale parameters.
  57198. */
  57199. readonly stageParameters: VRStageParameters | null;
  57200. /**
  57201. * Passing the value returned by `requestAnimationFrame` to
  57202. * `cancelAnimationFrame` will unregister the callback.
  57203. * @param handle Define the hanle of the request to cancel
  57204. */
  57205. cancelAnimationFrame(handle: number): void;
  57206. /**
  57207. * Stops presenting to the VRDisplay.
  57208. * @returns a promise to know when it stopped
  57209. */
  57210. exitPresent(): Promise<void>;
  57211. /**
  57212. * Return the current VREyeParameters for the given eye.
  57213. * @param whichEye Define the eye we want the parameter for
  57214. * @returns the eye parameters
  57215. */
  57216. getEyeParameters(whichEye: string): VREyeParameters;
  57217. /**
  57218. * Populates the passed VRFrameData with the information required to render
  57219. * the current frame.
  57220. * @param frameData Define the data structure to populate
  57221. * @returns true if ok otherwise false
  57222. */
  57223. getFrameData(frameData: VRFrameData): boolean;
  57224. /**
  57225. * Get the layers currently being presented.
  57226. * @returns the list of VR layers
  57227. */
  57228. getLayers(): VRLayer[];
  57229. /**
  57230. * Return a VRPose containing the future predicted pose of the VRDisplay
  57231. * when the current frame will be presented. The value returned will not
  57232. * change until JavaScript has returned control to the browser.
  57233. *
  57234. * The VRPose will contain the position, orientation, velocity,
  57235. * and acceleration of each of these properties.
  57236. * @returns the pose object
  57237. */
  57238. getPose(): VRPose;
  57239. /**
  57240. * Return the current instantaneous pose of the VRDisplay, with no
  57241. * prediction applied.
  57242. * @returns the current instantaneous pose
  57243. */
  57244. getImmediatePose(): VRPose;
  57245. /**
  57246. * The callback passed to `requestAnimationFrame` will be called
  57247. * any time a new frame should be rendered. When the VRDisplay is
  57248. * presenting the callback will be called at the native refresh
  57249. * rate of the HMD. When not presenting this function acts
  57250. * identically to how window.requestAnimationFrame acts. Content should
  57251. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57252. * asynchronously from other displays and at differing refresh rates.
  57253. * @param callback Define the eaction to run next frame
  57254. * @returns the request handle it
  57255. */
  57256. requestAnimationFrame(callback: FrameRequestCallback): number;
  57257. /**
  57258. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57259. * Repeat calls while already presenting will update the VRLayers being displayed.
  57260. * @param layers Define the list of layer to present
  57261. * @returns a promise to know when the request has been fulfilled
  57262. */
  57263. requestPresent(layers: VRLayer[]): Promise<void>;
  57264. /**
  57265. * Reset the pose for this display, treating its current position and
  57266. * orientation as the "origin/zero" values. VRPose.position,
  57267. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57268. * updated when calling resetPose(). This should be called in only
  57269. * sitting-space experiences.
  57270. */
  57271. resetPose(): void;
  57272. /**
  57273. * The VRLayer provided to the VRDisplay will be captured and presented
  57274. * in the HMD. Calling this function has the same effect on the source
  57275. * canvas as any other operation that uses its source image, and canvases
  57276. * created without preserveDrawingBuffer set to true will be cleared.
  57277. * @param pose Define the pose to submit
  57278. */
  57279. submitFrame(pose?: VRPose): void;
  57280. }
  57281. declare var VRDisplay: {
  57282. prototype: VRDisplay;
  57283. new(): VRDisplay;
  57284. };
  57285. interface VRLayer {
  57286. leftBounds?: number[] | Float32Array | null;
  57287. rightBounds?: number[] | Float32Array | null;
  57288. source?: HTMLCanvasElement | null;
  57289. }
  57290. interface VRDisplayCapabilities {
  57291. readonly canPresent: boolean;
  57292. readonly hasExternalDisplay: boolean;
  57293. readonly hasOrientation: boolean;
  57294. readonly hasPosition: boolean;
  57295. readonly maxLayers: number;
  57296. }
  57297. interface VREyeParameters {
  57298. /** @deprecated */
  57299. readonly fieldOfView: VRFieldOfView;
  57300. readonly offset: Float32Array;
  57301. readonly renderHeight: number;
  57302. readonly renderWidth: number;
  57303. }
  57304. interface VRFieldOfView {
  57305. readonly downDegrees: number;
  57306. readonly leftDegrees: number;
  57307. readonly rightDegrees: number;
  57308. readonly upDegrees: number;
  57309. }
  57310. interface VRFrameData {
  57311. readonly leftProjectionMatrix: Float32Array;
  57312. readonly leftViewMatrix: Float32Array;
  57313. readonly pose: VRPose;
  57314. readonly rightProjectionMatrix: Float32Array;
  57315. readonly rightViewMatrix: Float32Array;
  57316. readonly timestamp: number;
  57317. }
  57318. interface VRPose {
  57319. readonly angularAcceleration: Float32Array | null;
  57320. readonly angularVelocity: Float32Array | null;
  57321. readonly linearAcceleration: Float32Array | null;
  57322. readonly linearVelocity: Float32Array | null;
  57323. readonly orientation: Float32Array | null;
  57324. readonly position: Float32Array | null;
  57325. readonly timestamp: number;
  57326. }
  57327. interface VRStageParameters {
  57328. sittingToStandingTransform?: Float32Array;
  57329. sizeX?: number;
  57330. sizeY?: number;
  57331. }
  57332. interface Navigator {
  57333. getVRDisplays(): Promise<VRDisplay[]>;
  57334. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57335. }
  57336. interface Window {
  57337. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57338. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57339. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57340. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57341. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57342. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57343. }
  57344. interface Gamepad {
  57345. readonly displayId: number;
  57346. }
  57347. interface XRDevice {
  57348. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57349. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57350. }
  57351. interface XRSession {
  57352. getInputSources(): Array<any>;
  57353. baseLayer: XRWebGLLayer;
  57354. requestFrameOfReference(type: string): Promise<void>;
  57355. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57356. end(): Promise<void>;
  57357. requestAnimationFrame: Function;
  57358. addEventListener: Function;
  57359. }
  57360. interface XRSessionCreationOptions {
  57361. outputContext?: WebGLRenderingContext | null;
  57362. immersive?: boolean;
  57363. environmentIntegration?: boolean;
  57364. }
  57365. interface XRLayer {
  57366. getViewport: Function;
  57367. framebufferWidth: number;
  57368. framebufferHeight: number;
  57369. }
  57370. interface XRView {
  57371. projectionMatrix: Float32Array;
  57372. }
  57373. interface XRFrame {
  57374. getDevicePose: Function;
  57375. getInputPose: Function;
  57376. views: Array<XRView>;
  57377. baseLayer: XRLayer;
  57378. }
  57379. interface XRFrameOfReference {
  57380. }
  57381. interface XRWebGLLayer extends XRLayer {
  57382. framebuffer: WebGLFramebuffer;
  57383. }
  57384. declare var XRWebGLLayer: {
  57385. prototype: XRWebGLLayer;
  57386. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57387. };
  57388. declare module "babylonjs" {
  57389. export * from "babylonjs/Legacy/legacy";
  57390. }
  57391. declare module BABYLON {
  57392. /** Alias type for value that can be null */
  57393. export type Nullable<T> = T | null;
  57394. /**
  57395. * Alias type for number that are floats
  57396. * @ignorenaming
  57397. */
  57398. export type float = number;
  57399. /**
  57400. * Alias type for number that are doubles.
  57401. * @ignorenaming
  57402. */
  57403. export type double = number;
  57404. /**
  57405. * Alias type for number that are integer
  57406. * @ignorenaming
  57407. */
  57408. export type int = number;
  57409. /** Alias type for number array or Float32Array */
  57410. export type FloatArray = number[] | Float32Array;
  57411. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57412. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57413. /**
  57414. * Alias for types that can be used by a Buffer or VertexBuffer.
  57415. */
  57416. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57417. /**
  57418. * Alias type for primitive types
  57419. * @ignorenaming
  57420. */
  57421. type Primitive = undefined | null | boolean | string | number | Function;
  57422. /**
  57423. * Type modifier to make all the properties of an object Readonly
  57424. */
  57425. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57426. /**
  57427. * Type modifier to make all the properties of an object Readonly recursively
  57428. */
  57429. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57430. /** @hidden */
  57431. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57432. }
  57433. /** @hidden */
  57434. /** @hidden */
  57435. type DeepImmutableObject<T> = {
  57436. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57437. };
  57438. }
  57439. declare module BABYLON {
  57440. /**
  57441. * Class containing a set of static utilities functions for arrays.
  57442. */
  57443. export class ArrayTools {
  57444. /**
  57445. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57446. * @param size the number of element to construct and put in the array
  57447. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57448. * @returns a new array filled with new objects
  57449. */
  57450. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57451. }
  57452. }
  57453. declare module BABYLON {
  57454. /**
  57455. * Scalar computation library
  57456. */
  57457. export class Scalar {
  57458. /**
  57459. * Two pi constants convenient for computation.
  57460. */
  57461. static TwoPi: number;
  57462. /**
  57463. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57464. * @param a number
  57465. * @param b number
  57466. * @param epsilon (default = 1.401298E-45)
  57467. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57468. */
  57469. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57470. /**
  57471. * Returns a string : the upper case translation of the number i to hexadecimal.
  57472. * @param i number
  57473. * @returns the upper case translation of the number i to hexadecimal.
  57474. */
  57475. static ToHex(i: number): string;
  57476. /**
  57477. * Returns -1 if value is negative and +1 is value is positive.
  57478. * @param value the value
  57479. * @returns the value itself if it's equal to zero.
  57480. */
  57481. static Sign(value: number): number;
  57482. /**
  57483. * Returns the value itself if it's between min and max.
  57484. * Returns min if the value is lower than min.
  57485. * Returns max if the value is greater than max.
  57486. * @param value the value to clmap
  57487. * @param min the min value to clamp to (default: 0)
  57488. * @param max the max value to clamp to (default: 1)
  57489. * @returns the clamped value
  57490. */
  57491. static Clamp(value: number, min?: number, max?: number): number;
  57492. /**
  57493. * the log2 of value.
  57494. * @param value the value to compute log2 of
  57495. * @returns the log2 of value.
  57496. */
  57497. static Log2(value: number): number;
  57498. /**
  57499. * Loops the value, so that it is never larger than length and never smaller than 0.
  57500. *
  57501. * This is similar to the modulo operator but it works with floating point numbers.
  57502. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57503. * With t = 5 and length = 2.5, the result would be 0.0.
  57504. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57505. * @param value the value
  57506. * @param length the length
  57507. * @returns the looped value
  57508. */
  57509. static Repeat(value: number, length: number): number;
  57510. /**
  57511. * Normalize the value between 0.0 and 1.0 using min and max values
  57512. * @param value value to normalize
  57513. * @param min max to normalize between
  57514. * @param max min to normalize between
  57515. * @returns the normalized value
  57516. */
  57517. static Normalize(value: number, min: number, max: number): number;
  57518. /**
  57519. * Denormalize the value from 0.0 and 1.0 using min and max values
  57520. * @param normalized value to denormalize
  57521. * @param min max to denormalize between
  57522. * @param max min to denormalize between
  57523. * @returns the denormalized value
  57524. */
  57525. static Denormalize(normalized: number, min: number, max: number): number;
  57526. /**
  57527. * Calculates the shortest difference between two given angles given in degrees.
  57528. * @param current current angle in degrees
  57529. * @param target target angle in degrees
  57530. * @returns the delta
  57531. */
  57532. static DeltaAngle(current: number, target: number): number;
  57533. /**
  57534. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57535. * @param tx value
  57536. * @param length length
  57537. * @returns The returned value will move back and forth between 0 and length
  57538. */
  57539. static PingPong(tx: number, length: number): number;
  57540. /**
  57541. * Interpolates between min and max with smoothing at the limits.
  57542. *
  57543. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57544. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57545. * @param from from
  57546. * @param to to
  57547. * @param tx value
  57548. * @returns the smooth stepped value
  57549. */
  57550. static SmoothStep(from: number, to: number, tx: number): number;
  57551. /**
  57552. * Moves a value current towards target.
  57553. *
  57554. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57555. * Negative values of maxDelta pushes the value away from target.
  57556. * @param current current value
  57557. * @param target target value
  57558. * @param maxDelta max distance to move
  57559. * @returns resulting value
  57560. */
  57561. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57562. /**
  57563. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57564. *
  57565. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57566. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57567. * @param current current value
  57568. * @param target target value
  57569. * @param maxDelta max distance to move
  57570. * @returns resulting angle
  57571. */
  57572. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57573. /**
  57574. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57575. * @param start start value
  57576. * @param end target value
  57577. * @param amount amount to lerp between
  57578. * @returns the lerped value
  57579. */
  57580. static Lerp(start: number, end: number, amount: number): number;
  57581. /**
  57582. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57583. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57584. * @param start start value
  57585. * @param end target value
  57586. * @param amount amount to lerp between
  57587. * @returns the lerped value
  57588. */
  57589. static LerpAngle(start: number, end: number, amount: number): number;
  57590. /**
  57591. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57592. * @param a start value
  57593. * @param b target value
  57594. * @param value value between a and b
  57595. * @returns the inverseLerp value
  57596. */
  57597. static InverseLerp(a: number, b: number, value: number): number;
  57598. /**
  57599. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57600. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57601. * @param value1 spline value
  57602. * @param tangent1 spline value
  57603. * @param value2 spline value
  57604. * @param tangent2 spline value
  57605. * @param amount input value
  57606. * @returns hermite result
  57607. */
  57608. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57609. /**
  57610. * Returns a random float number between and min and max values
  57611. * @param min min value of random
  57612. * @param max max value of random
  57613. * @returns random value
  57614. */
  57615. static RandomRange(min: number, max: number): number;
  57616. /**
  57617. * This function returns percentage of a number in a given range.
  57618. *
  57619. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57620. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57621. * @param number to convert to percentage
  57622. * @param min min range
  57623. * @param max max range
  57624. * @returns the percentage
  57625. */
  57626. static RangeToPercent(number: number, min: number, max: number): number;
  57627. /**
  57628. * This function returns number that corresponds to the percentage in a given range.
  57629. *
  57630. * PercentToRange(0.34,0,100) will return 34.
  57631. * @param percent to convert to number
  57632. * @param min min range
  57633. * @param max max range
  57634. * @returns the number
  57635. */
  57636. static PercentToRange(percent: number, min: number, max: number): number;
  57637. /**
  57638. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57639. * @param angle The angle to normalize in radian.
  57640. * @return The converted angle.
  57641. */
  57642. static NormalizeRadians(angle: number): number;
  57643. }
  57644. }
  57645. declare module BABYLON {
  57646. /**
  57647. * Constant used to convert a value to gamma space
  57648. * @ignorenaming
  57649. */
  57650. export const ToGammaSpace: number;
  57651. /**
  57652. * Constant used to convert a value to linear space
  57653. * @ignorenaming
  57654. */
  57655. export const ToLinearSpace = 2.2;
  57656. /**
  57657. * Constant used to define the minimal number value in Babylon.js
  57658. * @ignorenaming
  57659. */
  57660. export const Epsilon = 0.001;
  57661. /**
  57662. * Class used to hold a RBG color
  57663. */
  57664. export class Color3 {
  57665. /**
  57666. * Defines the red component (between 0 and 1, default is 0)
  57667. */
  57668. r: number;
  57669. /**
  57670. * Defines the green component (between 0 and 1, default is 0)
  57671. */
  57672. g: number;
  57673. /**
  57674. * Defines the blue component (between 0 and 1, default is 0)
  57675. */
  57676. b: number;
  57677. /**
  57678. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57679. * @param r defines the red component (between 0 and 1, default is 0)
  57680. * @param g defines the green component (between 0 and 1, default is 0)
  57681. * @param b defines the blue component (between 0 and 1, default is 0)
  57682. */
  57683. constructor(
  57684. /**
  57685. * Defines the red component (between 0 and 1, default is 0)
  57686. */
  57687. r?: number,
  57688. /**
  57689. * Defines the green component (between 0 and 1, default is 0)
  57690. */
  57691. g?: number,
  57692. /**
  57693. * Defines the blue component (between 0 and 1, default is 0)
  57694. */
  57695. b?: number);
  57696. /**
  57697. * Creates a string with the Color3 current values
  57698. * @returns the string representation of the Color3 object
  57699. */
  57700. toString(): string;
  57701. /**
  57702. * Returns the string "Color3"
  57703. * @returns "Color3"
  57704. */
  57705. getClassName(): string;
  57706. /**
  57707. * Compute the Color3 hash code
  57708. * @returns an unique number that can be used to hash Color3 objects
  57709. */
  57710. getHashCode(): number;
  57711. /**
  57712. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57713. * @param array defines the array where to store the r,g,b components
  57714. * @param index defines an optional index in the target array to define where to start storing values
  57715. * @returns the current Color3 object
  57716. */
  57717. toArray(array: FloatArray, index?: number): Color3;
  57718. /**
  57719. * Returns a new Color4 object from the current Color3 and the given alpha
  57720. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57721. * @returns a new Color4 object
  57722. */
  57723. toColor4(alpha?: number): Color4;
  57724. /**
  57725. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57726. * @returns the new array
  57727. */
  57728. asArray(): number[];
  57729. /**
  57730. * Returns the luminance value
  57731. * @returns a float value
  57732. */
  57733. toLuminance(): number;
  57734. /**
  57735. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57736. * @param otherColor defines the second operand
  57737. * @returns the new Color3 object
  57738. */
  57739. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57740. /**
  57741. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57742. * @param otherColor defines the second operand
  57743. * @param result defines the Color3 object where to store the result
  57744. * @returns the current Color3
  57745. */
  57746. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57747. /**
  57748. * Determines equality between Color3 objects
  57749. * @param otherColor defines the second operand
  57750. * @returns true if the rgb values are equal to the given ones
  57751. */
  57752. equals(otherColor: DeepImmutable<Color3>): boolean;
  57753. /**
  57754. * Determines equality between the current Color3 object and a set of r,b,g values
  57755. * @param r defines the red component to check
  57756. * @param g defines the green component to check
  57757. * @param b defines the blue component to check
  57758. * @returns true if the rgb values are equal to the given ones
  57759. */
  57760. equalsFloats(r: number, g: number, b: number): boolean;
  57761. /**
  57762. * Multiplies in place each rgb value by scale
  57763. * @param scale defines the scaling factor
  57764. * @returns the updated Color3
  57765. */
  57766. scale(scale: number): Color3;
  57767. /**
  57768. * Multiplies the rgb values by scale and stores the result into "result"
  57769. * @param scale defines the scaling factor
  57770. * @param result defines the Color3 object where to store the result
  57771. * @returns the unmodified current Color3
  57772. */
  57773. scaleToRef(scale: number, result: Color3): Color3;
  57774. /**
  57775. * Scale the current Color3 values by a factor and add the result to a given Color3
  57776. * @param scale defines the scale factor
  57777. * @param result defines color to store the result into
  57778. * @returns the unmodified current Color3
  57779. */
  57780. scaleAndAddToRef(scale: number, result: Color3): Color3;
  57781. /**
  57782. * Clamps the rgb values by the min and max values and stores the result into "result"
  57783. * @param min defines minimum clamping value (default is 0)
  57784. * @param max defines maximum clamping value (default is 1)
  57785. * @param result defines color to store the result into
  57786. * @returns the original Color3
  57787. */
  57788. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  57789. /**
  57790. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  57791. * @param otherColor defines the second operand
  57792. * @returns the new Color3
  57793. */
  57794. add(otherColor: DeepImmutable<Color3>): Color3;
  57795. /**
  57796. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  57797. * @param otherColor defines the second operand
  57798. * @param result defines Color3 object to store the result into
  57799. * @returns the unmodified current Color3
  57800. */
  57801. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57802. /**
  57803. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  57804. * @param otherColor defines the second operand
  57805. * @returns the new Color3
  57806. */
  57807. subtract(otherColor: DeepImmutable<Color3>): Color3;
  57808. /**
  57809. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  57810. * @param otherColor defines the second operand
  57811. * @param result defines Color3 object to store the result into
  57812. * @returns the unmodified current Color3
  57813. */
  57814. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57815. /**
  57816. * Copy the current object
  57817. * @returns a new Color3 copied the current one
  57818. */
  57819. clone(): Color3;
  57820. /**
  57821. * Copies the rgb values from the source in the current Color3
  57822. * @param source defines the source Color3 object
  57823. * @returns the updated Color3 object
  57824. */
  57825. copyFrom(source: DeepImmutable<Color3>): Color3;
  57826. /**
  57827. * Updates the Color3 rgb values from the given floats
  57828. * @param r defines the red component to read from
  57829. * @param g defines the green component to read from
  57830. * @param b defines the blue component to read from
  57831. * @returns the current Color3 object
  57832. */
  57833. copyFromFloats(r: number, g: number, b: number): Color3;
  57834. /**
  57835. * Updates the Color3 rgb values from the given floats
  57836. * @param r defines the red component to read from
  57837. * @param g defines the green component to read from
  57838. * @param b defines the blue component to read from
  57839. * @returns the current Color3 object
  57840. */
  57841. set(r: number, g: number, b: number): Color3;
  57842. /**
  57843. * Compute the Color3 hexadecimal code as a string
  57844. * @returns a string containing the hexadecimal representation of the Color3 object
  57845. */
  57846. toHexString(): string;
  57847. /**
  57848. * Computes a new Color3 converted from the current one to linear space
  57849. * @returns a new Color3 object
  57850. */
  57851. toLinearSpace(): Color3;
  57852. /**
  57853. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  57854. * @param convertedColor defines the Color3 object where to store the linear space version
  57855. * @returns the unmodified Color3
  57856. */
  57857. toLinearSpaceToRef(convertedColor: Color3): Color3;
  57858. /**
  57859. * Computes a new Color3 converted from the current one to gamma space
  57860. * @returns a new Color3 object
  57861. */
  57862. toGammaSpace(): Color3;
  57863. /**
  57864. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  57865. * @param convertedColor defines the Color3 object where to store the gamma space version
  57866. * @returns the unmodified Color3
  57867. */
  57868. toGammaSpaceToRef(convertedColor: Color3): Color3;
  57869. private static _BlackReadOnly;
  57870. /**
  57871. * Creates a new Color3 from the string containing valid hexadecimal values
  57872. * @param hex defines a string containing valid hexadecimal values
  57873. * @returns a new Color3 object
  57874. */
  57875. static FromHexString(hex: string): Color3;
  57876. /**
  57877. * Creates a new Vector3 from the starting index of the given array
  57878. * @param array defines the source array
  57879. * @param offset defines an offset in the source array
  57880. * @returns a new Color3 object
  57881. */
  57882. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  57883. /**
  57884. * Creates a new Color3 from integer values (< 256)
  57885. * @param r defines the red component to read from (value between 0 and 255)
  57886. * @param g defines the green component to read from (value between 0 and 255)
  57887. * @param b defines the blue component to read from (value between 0 and 255)
  57888. * @returns a new Color3 object
  57889. */
  57890. static FromInts(r: number, g: number, b: number): Color3;
  57891. /**
  57892. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57893. * @param start defines the start Color3 value
  57894. * @param end defines the end Color3 value
  57895. * @param amount defines the gradient value between start and end
  57896. * @returns a new Color3 object
  57897. */
  57898. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  57899. /**
  57900. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57901. * @param left defines the start value
  57902. * @param right defines the end value
  57903. * @param amount defines the gradient factor
  57904. * @param result defines the Color3 object where to store the result
  57905. */
  57906. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  57907. /**
  57908. * Returns a Color3 value containing a red color
  57909. * @returns a new Color3 object
  57910. */
  57911. static Red(): Color3;
  57912. /**
  57913. * Returns a Color3 value containing a green color
  57914. * @returns a new Color3 object
  57915. */
  57916. static Green(): Color3;
  57917. /**
  57918. * Returns a Color3 value containing a blue color
  57919. * @returns a new Color3 object
  57920. */
  57921. static Blue(): Color3;
  57922. /**
  57923. * Returns a Color3 value containing a black color
  57924. * @returns a new Color3 object
  57925. */
  57926. static Black(): Color3;
  57927. /**
  57928. * Gets a Color3 value containing a black color that must not be updated
  57929. */
  57930. static readonly BlackReadOnly: DeepImmutable<Color3>;
  57931. /**
  57932. * Returns a Color3 value containing a white color
  57933. * @returns a new Color3 object
  57934. */
  57935. static White(): Color3;
  57936. /**
  57937. * Returns a Color3 value containing a purple color
  57938. * @returns a new Color3 object
  57939. */
  57940. static Purple(): Color3;
  57941. /**
  57942. * Returns a Color3 value containing a magenta color
  57943. * @returns a new Color3 object
  57944. */
  57945. static Magenta(): Color3;
  57946. /**
  57947. * Returns a Color3 value containing a yellow color
  57948. * @returns a new Color3 object
  57949. */
  57950. static Yellow(): Color3;
  57951. /**
  57952. * Returns a Color3 value containing a gray color
  57953. * @returns a new Color3 object
  57954. */
  57955. static Gray(): Color3;
  57956. /**
  57957. * Returns a Color3 value containing a teal color
  57958. * @returns a new Color3 object
  57959. */
  57960. static Teal(): Color3;
  57961. /**
  57962. * Returns a Color3 value containing a random color
  57963. * @returns a new Color3 object
  57964. */
  57965. static Random(): Color3;
  57966. }
  57967. /**
  57968. * Class used to hold a RBGA color
  57969. */
  57970. export class Color4 {
  57971. /**
  57972. * Defines the red component (between 0 and 1, default is 0)
  57973. */
  57974. r: number;
  57975. /**
  57976. * Defines the green component (between 0 and 1, default is 0)
  57977. */
  57978. g: number;
  57979. /**
  57980. * Defines the blue component (between 0 and 1, default is 0)
  57981. */
  57982. b: number;
  57983. /**
  57984. * Defines the alpha component (between 0 and 1, default is 1)
  57985. */
  57986. a: number;
  57987. /**
  57988. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  57989. * @param r defines the red component (between 0 and 1, default is 0)
  57990. * @param g defines the green component (between 0 and 1, default is 0)
  57991. * @param b defines the blue component (between 0 and 1, default is 0)
  57992. * @param a defines the alpha component (between 0 and 1, default is 1)
  57993. */
  57994. constructor(
  57995. /**
  57996. * Defines the red component (between 0 and 1, default is 0)
  57997. */
  57998. r?: number,
  57999. /**
  58000. * Defines the green component (between 0 and 1, default is 0)
  58001. */
  58002. g?: number,
  58003. /**
  58004. * Defines the blue component (between 0 and 1, default is 0)
  58005. */
  58006. b?: number,
  58007. /**
  58008. * Defines the alpha component (between 0 and 1, default is 1)
  58009. */
  58010. a?: number);
  58011. /**
  58012. * Adds in place the given Color4 values to the current Color4 object
  58013. * @param right defines the second operand
  58014. * @returns the current updated Color4 object
  58015. */
  58016. addInPlace(right: DeepImmutable<Color4>): Color4;
  58017. /**
  58018. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58019. * @returns the new array
  58020. */
  58021. asArray(): number[];
  58022. /**
  58023. * Stores from the starting index in the given array the Color4 successive values
  58024. * @param array defines the array where to store the r,g,b components
  58025. * @param index defines an optional index in the target array to define where to start storing values
  58026. * @returns the current Color4 object
  58027. */
  58028. toArray(array: number[], index?: number): Color4;
  58029. /**
  58030. * Determines equality between Color4 objects
  58031. * @param otherColor defines the second operand
  58032. * @returns true if the rgba values are equal to the given ones
  58033. */
  58034. equals(otherColor: DeepImmutable<Color4>): boolean;
  58035. /**
  58036. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58037. * @param right defines the second operand
  58038. * @returns a new Color4 object
  58039. */
  58040. add(right: DeepImmutable<Color4>): Color4;
  58041. /**
  58042. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58043. * @param right defines the second operand
  58044. * @returns a new Color4 object
  58045. */
  58046. subtract(right: DeepImmutable<Color4>): Color4;
  58047. /**
  58048. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58049. * @param right defines the second operand
  58050. * @param result defines the Color4 object where to store the result
  58051. * @returns the current Color4 object
  58052. */
  58053. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58054. /**
  58055. * Creates a new Color4 with the current Color4 values multiplied by scale
  58056. * @param scale defines the scaling factor to apply
  58057. * @returns a new Color4 object
  58058. */
  58059. scale(scale: number): Color4;
  58060. /**
  58061. * Multiplies the current Color4 values by scale and stores the result in "result"
  58062. * @param scale defines the scaling factor to apply
  58063. * @param result defines the Color4 object where to store the result
  58064. * @returns the current unmodified Color4
  58065. */
  58066. scaleToRef(scale: number, result: Color4): Color4;
  58067. /**
  58068. * Scale the current Color4 values by a factor and add the result to a given Color4
  58069. * @param scale defines the scale factor
  58070. * @param result defines the Color4 object where to store the result
  58071. * @returns the unmodified current Color4
  58072. */
  58073. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58074. /**
  58075. * Clamps the rgb values by the min and max values and stores the result into "result"
  58076. * @param min defines minimum clamping value (default is 0)
  58077. * @param max defines maximum clamping value (default is 1)
  58078. * @param result defines color to store the result into.
  58079. * @returns the cuurent Color4
  58080. */
  58081. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58082. /**
  58083. * Multipy an Color4 value by another and return a new Color4 object
  58084. * @param color defines the Color4 value to multiply by
  58085. * @returns a new Color4 object
  58086. */
  58087. multiply(color: Color4): Color4;
  58088. /**
  58089. * Multipy a Color4 value by another and push the result in a reference value
  58090. * @param color defines the Color4 value to multiply by
  58091. * @param result defines the Color4 to fill the result in
  58092. * @returns the result Color4
  58093. */
  58094. multiplyToRef(color: Color4, result: Color4): Color4;
  58095. /**
  58096. * Creates a string with the Color4 current values
  58097. * @returns the string representation of the Color4 object
  58098. */
  58099. toString(): string;
  58100. /**
  58101. * Returns the string "Color4"
  58102. * @returns "Color4"
  58103. */
  58104. getClassName(): string;
  58105. /**
  58106. * Compute the Color4 hash code
  58107. * @returns an unique number that can be used to hash Color4 objects
  58108. */
  58109. getHashCode(): number;
  58110. /**
  58111. * Creates a new Color4 copied from the current one
  58112. * @returns a new Color4 object
  58113. */
  58114. clone(): Color4;
  58115. /**
  58116. * Copies the given Color4 values into the current one
  58117. * @param source defines the source Color4 object
  58118. * @returns the current updated Color4 object
  58119. */
  58120. copyFrom(source: Color4): Color4;
  58121. /**
  58122. * Copies the given float values into the current one
  58123. * @param r defines the red component to read from
  58124. * @param g defines the green component to read from
  58125. * @param b defines the blue component to read from
  58126. * @param a defines the alpha component to read from
  58127. * @returns the current updated Color4 object
  58128. */
  58129. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58130. /**
  58131. * Copies the given float values into the current one
  58132. * @param r defines the red component to read from
  58133. * @param g defines the green component to read from
  58134. * @param b defines the blue component to read from
  58135. * @param a defines the alpha component to read from
  58136. * @returns the current updated Color4 object
  58137. */
  58138. set(r: number, g: number, b: number, a: number): Color4;
  58139. /**
  58140. * Compute the Color4 hexadecimal code as a string
  58141. * @returns a string containing the hexadecimal representation of the Color4 object
  58142. */
  58143. toHexString(): string;
  58144. /**
  58145. * Computes a new Color4 converted from the current one to linear space
  58146. * @returns a new Color4 object
  58147. */
  58148. toLinearSpace(): Color4;
  58149. /**
  58150. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58151. * @param convertedColor defines the Color4 object where to store the linear space version
  58152. * @returns the unmodified Color4
  58153. */
  58154. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58155. /**
  58156. * Computes a new Color4 converted from the current one to gamma space
  58157. * @returns a new Color4 object
  58158. */
  58159. toGammaSpace(): Color4;
  58160. /**
  58161. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58162. * @param convertedColor defines the Color4 object where to store the gamma space version
  58163. * @returns the unmodified Color4
  58164. */
  58165. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58166. /**
  58167. * Creates a new Color4 from the string containing valid hexadecimal values
  58168. * @param hex defines a string containing valid hexadecimal values
  58169. * @returns a new Color4 object
  58170. */
  58171. static FromHexString(hex: string): Color4;
  58172. /**
  58173. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58174. * @param left defines the start value
  58175. * @param right defines the end value
  58176. * @param amount defines the gradient factor
  58177. * @returns a new Color4 object
  58178. */
  58179. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58180. /**
  58181. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58182. * @param left defines the start value
  58183. * @param right defines the end value
  58184. * @param amount defines the gradient factor
  58185. * @param result defines the Color4 object where to store data
  58186. */
  58187. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58188. /**
  58189. * Creates a new Color4 from a Color3 and an alpha value
  58190. * @param color3 defines the source Color3 to read from
  58191. * @param alpha defines the alpha component (1.0 by default)
  58192. * @returns a new Color4 object
  58193. */
  58194. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58195. /**
  58196. * Creates a new Color4 from the starting index element of the given array
  58197. * @param array defines the source array to read from
  58198. * @param offset defines the offset in the source array
  58199. * @returns a new Color4 object
  58200. */
  58201. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58202. /**
  58203. * Creates a new Color3 from integer values (< 256)
  58204. * @param r defines the red component to read from (value between 0 and 255)
  58205. * @param g defines the green component to read from (value between 0 and 255)
  58206. * @param b defines the blue component to read from (value between 0 and 255)
  58207. * @param a defines the alpha component to read from (value between 0 and 255)
  58208. * @returns a new Color3 object
  58209. */
  58210. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58211. /**
  58212. * Check the content of a given array and convert it to an array containing RGBA data
  58213. * If the original array was already containing count * 4 values then it is returned directly
  58214. * @param colors defines the array to check
  58215. * @param count defines the number of RGBA data to expect
  58216. * @returns an array containing count * 4 values (RGBA)
  58217. */
  58218. static CheckColors4(colors: number[], count: number): number[];
  58219. }
  58220. /**
  58221. * Class representing a vector containing 2 coordinates
  58222. */
  58223. export class Vector2 {
  58224. /** defines the first coordinate */
  58225. x: number;
  58226. /** defines the second coordinate */
  58227. y: number;
  58228. /**
  58229. * Creates a new Vector2 from the given x and y coordinates
  58230. * @param x defines the first coordinate
  58231. * @param y defines the second coordinate
  58232. */
  58233. constructor(
  58234. /** defines the first coordinate */
  58235. x?: number,
  58236. /** defines the second coordinate */
  58237. y?: number);
  58238. /**
  58239. * Gets a string with the Vector2 coordinates
  58240. * @returns a string with the Vector2 coordinates
  58241. */
  58242. toString(): string;
  58243. /**
  58244. * Gets class name
  58245. * @returns the string "Vector2"
  58246. */
  58247. getClassName(): string;
  58248. /**
  58249. * Gets current vector hash code
  58250. * @returns the Vector2 hash code as a number
  58251. */
  58252. getHashCode(): number;
  58253. /**
  58254. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58255. * @param array defines the source array
  58256. * @param index defines the offset in source array
  58257. * @returns the current Vector2
  58258. */
  58259. toArray(array: FloatArray, index?: number): Vector2;
  58260. /**
  58261. * Copy the current vector to an array
  58262. * @returns a new array with 2 elements: the Vector2 coordinates.
  58263. */
  58264. asArray(): number[];
  58265. /**
  58266. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58267. * @param source defines the source Vector2
  58268. * @returns the current updated Vector2
  58269. */
  58270. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58271. /**
  58272. * Sets the Vector2 coordinates with the given floats
  58273. * @param x defines the first coordinate
  58274. * @param y defines the second coordinate
  58275. * @returns the current updated Vector2
  58276. */
  58277. copyFromFloats(x: number, y: number): Vector2;
  58278. /**
  58279. * Sets the Vector2 coordinates with the given floats
  58280. * @param x defines the first coordinate
  58281. * @param y defines the second coordinate
  58282. * @returns the current updated Vector2
  58283. */
  58284. set(x: number, y: number): Vector2;
  58285. /**
  58286. * Add another vector with the current one
  58287. * @param otherVector defines the other vector
  58288. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58289. */
  58290. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58291. /**
  58292. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58293. * @param otherVector defines the other vector
  58294. * @param result defines the target vector
  58295. * @returns the unmodified current Vector2
  58296. */
  58297. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58298. /**
  58299. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58300. * @param otherVector defines the other vector
  58301. * @returns the current updated Vector2
  58302. */
  58303. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58304. /**
  58305. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58306. * @param otherVector defines the other vector
  58307. * @returns a new Vector2
  58308. */
  58309. addVector3(otherVector: Vector3): Vector2;
  58310. /**
  58311. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58312. * @param otherVector defines the other vector
  58313. * @returns a new Vector2
  58314. */
  58315. subtract(otherVector: Vector2): Vector2;
  58316. /**
  58317. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58318. * @param otherVector defines the other vector
  58319. * @param result defines the target vector
  58320. * @returns the unmodified current Vector2
  58321. */
  58322. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58323. /**
  58324. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58325. * @param otherVector defines the other vector
  58326. * @returns the current updated Vector2
  58327. */
  58328. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58329. /**
  58330. * Multiplies in place the current Vector2 coordinates by the given ones
  58331. * @param otherVector defines the other vector
  58332. * @returns the current updated Vector2
  58333. */
  58334. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58335. /**
  58336. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58337. * @param otherVector defines the other vector
  58338. * @returns a new Vector2
  58339. */
  58340. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58341. /**
  58342. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58343. * @param otherVector defines the other vector
  58344. * @param result defines the target vector
  58345. * @returns the unmodified current Vector2
  58346. */
  58347. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58348. /**
  58349. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58350. * @param x defines the first coordinate
  58351. * @param y defines the second coordinate
  58352. * @returns a new Vector2
  58353. */
  58354. multiplyByFloats(x: number, y: number): Vector2;
  58355. /**
  58356. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58357. * @param otherVector defines the other vector
  58358. * @returns a new Vector2
  58359. */
  58360. divide(otherVector: Vector2): Vector2;
  58361. /**
  58362. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58363. * @param otherVector defines the other vector
  58364. * @param result defines the target vector
  58365. * @returns the unmodified current Vector2
  58366. */
  58367. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58368. /**
  58369. * Divides the current Vector2 coordinates by the given ones
  58370. * @param otherVector defines the other vector
  58371. * @returns the current updated Vector2
  58372. */
  58373. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58374. /**
  58375. * Gets a new Vector2 with current Vector2 negated coordinates
  58376. * @returns a new Vector2
  58377. */
  58378. negate(): Vector2;
  58379. /**
  58380. * Multiply the Vector2 coordinates by scale
  58381. * @param scale defines the scaling factor
  58382. * @returns the current updated Vector2
  58383. */
  58384. scaleInPlace(scale: number): Vector2;
  58385. /**
  58386. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58387. * @param scale defines the scaling factor
  58388. * @returns a new Vector2
  58389. */
  58390. scale(scale: number): Vector2;
  58391. /**
  58392. * Scale the current Vector2 values by a factor to a given Vector2
  58393. * @param scale defines the scale factor
  58394. * @param result defines the Vector2 object where to store the result
  58395. * @returns the unmodified current Vector2
  58396. */
  58397. scaleToRef(scale: number, result: Vector2): Vector2;
  58398. /**
  58399. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58400. * @param scale defines the scale factor
  58401. * @param result defines the Vector2 object where to store the result
  58402. * @returns the unmodified current Vector2
  58403. */
  58404. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58405. /**
  58406. * Gets a boolean if two vectors are equals
  58407. * @param otherVector defines the other vector
  58408. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58409. */
  58410. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58411. /**
  58412. * Gets a boolean if two vectors are equals (using an epsilon value)
  58413. * @param otherVector defines the other vector
  58414. * @param epsilon defines the minimal distance to consider equality
  58415. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58416. */
  58417. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58418. /**
  58419. * Gets a new Vector2 from current Vector2 floored values
  58420. * @returns a new Vector2
  58421. */
  58422. floor(): Vector2;
  58423. /**
  58424. * Gets a new Vector2 from current Vector2 floored values
  58425. * @returns a new Vector2
  58426. */
  58427. fract(): Vector2;
  58428. /**
  58429. * Gets the length of the vector
  58430. * @returns the vector length (float)
  58431. */
  58432. length(): number;
  58433. /**
  58434. * Gets the vector squared length
  58435. * @returns the vector squared length (float)
  58436. */
  58437. lengthSquared(): number;
  58438. /**
  58439. * Normalize the vector
  58440. * @returns the current updated Vector2
  58441. */
  58442. normalize(): Vector2;
  58443. /**
  58444. * Gets a new Vector2 copied from the Vector2
  58445. * @returns a new Vector2
  58446. */
  58447. clone(): Vector2;
  58448. /**
  58449. * Gets a new Vector2(0, 0)
  58450. * @returns a new Vector2
  58451. */
  58452. static Zero(): Vector2;
  58453. /**
  58454. * Gets a new Vector2(1, 1)
  58455. * @returns a new Vector2
  58456. */
  58457. static One(): Vector2;
  58458. /**
  58459. * Gets a new Vector2 set from the given index element of the given array
  58460. * @param array defines the data source
  58461. * @param offset defines the offset in the data source
  58462. * @returns a new Vector2
  58463. */
  58464. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58465. /**
  58466. * Sets "result" from the given index element of the given array
  58467. * @param array defines the data source
  58468. * @param offset defines the offset in the data source
  58469. * @param result defines the target vector
  58470. */
  58471. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58472. /**
  58473. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58474. * @param value1 defines 1st point of control
  58475. * @param value2 defines 2nd point of control
  58476. * @param value3 defines 3rd point of control
  58477. * @param value4 defines 4th point of control
  58478. * @param amount defines the interpolation factor
  58479. * @returns a new Vector2
  58480. */
  58481. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58482. /**
  58483. * 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".
  58484. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58485. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58486. * @param value defines the value to clamp
  58487. * @param min defines the lower limit
  58488. * @param max defines the upper limit
  58489. * @returns a new Vector2
  58490. */
  58491. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58492. /**
  58493. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58494. * @param value1 defines the 1st control point
  58495. * @param tangent1 defines the outgoing tangent
  58496. * @param value2 defines the 2nd control point
  58497. * @param tangent2 defines the incoming tangent
  58498. * @param amount defines the interpolation factor
  58499. * @returns a new Vector2
  58500. */
  58501. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58502. /**
  58503. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58504. * @param start defines the start vector
  58505. * @param end defines the end vector
  58506. * @param amount defines the interpolation factor
  58507. * @returns a new Vector2
  58508. */
  58509. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58510. /**
  58511. * Gets the dot product of the vector "left" and the vector "right"
  58512. * @param left defines first vector
  58513. * @param right defines second vector
  58514. * @returns the dot product (float)
  58515. */
  58516. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58517. /**
  58518. * Returns a new Vector2 equal to the normalized given vector
  58519. * @param vector defines the vector to normalize
  58520. * @returns a new Vector2
  58521. */
  58522. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58523. /**
  58524. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58525. * @param left defines 1st vector
  58526. * @param right defines 2nd vector
  58527. * @returns a new Vector2
  58528. */
  58529. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58530. /**
  58531. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58532. * @param left defines 1st vector
  58533. * @param right defines 2nd vector
  58534. * @returns a new Vector2
  58535. */
  58536. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58537. /**
  58538. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58539. * @param vector defines the vector to transform
  58540. * @param transformation defines the matrix to apply
  58541. * @returns a new Vector2
  58542. */
  58543. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58544. /**
  58545. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58546. * @param vector defines the vector to transform
  58547. * @param transformation defines the matrix to apply
  58548. * @param result defines the target vector
  58549. */
  58550. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58551. /**
  58552. * Determines if a given vector is included in a triangle
  58553. * @param p defines the vector to test
  58554. * @param p0 defines 1st triangle point
  58555. * @param p1 defines 2nd triangle point
  58556. * @param p2 defines 3rd triangle point
  58557. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58558. */
  58559. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58560. /**
  58561. * Gets the distance between the vectors "value1" and "value2"
  58562. * @param value1 defines first vector
  58563. * @param value2 defines second vector
  58564. * @returns the distance between vectors
  58565. */
  58566. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58567. /**
  58568. * Returns the squared distance between the vectors "value1" and "value2"
  58569. * @param value1 defines first vector
  58570. * @param value2 defines second vector
  58571. * @returns the squared distance between vectors
  58572. */
  58573. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58574. /**
  58575. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58576. * @param value1 defines first vector
  58577. * @param value2 defines second vector
  58578. * @returns a new Vector2
  58579. */
  58580. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58581. /**
  58582. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58583. * @param p defines the middle point
  58584. * @param segA defines one point of the segment
  58585. * @param segB defines the other point of the segment
  58586. * @returns the shortest distance
  58587. */
  58588. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58589. }
  58590. /**
  58591. * Classed used to store (x,y,z) vector representation
  58592. * A Vector3 is the main object used in 3D geometry
  58593. * It can represent etiher the coordinates of a point the space, either a direction
  58594. * Reminder: js uses a left handed forward facing system
  58595. */
  58596. export class Vector3 {
  58597. /**
  58598. * Defines the first coordinates (on X axis)
  58599. */
  58600. x: number;
  58601. /**
  58602. * Defines the second coordinates (on Y axis)
  58603. */
  58604. y: number;
  58605. /**
  58606. * Defines the third coordinates (on Z axis)
  58607. */
  58608. z: number;
  58609. private static _UpReadOnly;
  58610. /**
  58611. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58612. * @param x defines the first coordinates (on X axis)
  58613. * @param y defines the second coordinates (on Y axis)
  58614. * @param z defines the third coordinates (on Z axis)
  58615. */
  58616. constructor(
  58617. /**
  58618. * Defines the first coordinates (on X axis)
  58619. */
  58620. x?: number,
  58621. /**
  58622. * Defines the second coordinates (on Y axis)
  58623. */
  58624. y?: number,
  58625. /**
  58626. * Defines the third coordinates (on Z axis)
  58627. */
  58628. z?: number);
  58629. /**
  58630. * Creates a string representation of the Vector3
  58631. * @returns a string with the Vector3 coordinates.
  58632. */
  58633. toString(): string;
  58634. /**
  58635. * Gets the class name
  58636. * @returns the string "Vector3"
  58637. */
  58638. getClassName(): string;
  58639. /**
  58640. * Creates the Vector3 hash code
  58641. * @returns a number which tends to be unique between Vector3 instances
  58642. */
  58643. getHashCode(): number;
  58644. /**
  58645. * Creates an array containing three elements : the coordinates of the Vector3
  58646. * @returns a new array of numbers
  58647. */
  58648. asArray(): number[];
  58649. /**
  58650. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58651. * @param array defines the destination array
  58652. * @param index defines the offset in the destination array
  58653. * @returns the current Vector3
  58654. */
  58655. toArray(array: FloatArray, index?: number): Vector3;
  58656. /**
  58657. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58658. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58659. */
  58660. toQuaternion(): Quaternion;
  58661. /**
  58662. * Adds the given vector to the current Vector3
  58663. * @param otherVector defines the second operand
  58664. * @returns the current updated Vector3
  58665. */
  58666. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58667. /**
  58668. * Adds the given coordinates to the current Vector3
  58669. * @param x defines the x coordinate of the operand
  58670. * @param y defines the y coordinate of the operand
  58671. * @param z defines the z coordinate of the operand
  58672. * @returns the current updated Vector3
  58673. */
  58674. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58675. /**
  58676. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58677. * @param otherVector defines the second operand
  58678. * @returns the resulting Vector3
  58679. */
  58680. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58681. /**
  58682. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58683. * @param otherVector defines the second operand
  58684. * @param result defines the Vector3 object where to store the result
  58685. * @returns the current Vector3
  58686. */
  58687. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58688. /**
  58689. * Subtract the given vector from the current Vector3
  58690. * @param otherVector defines the second operand
  58691. * @returns the current updated Vector3
  58692. */
  58693. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58694. /**
  58695. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58696. * @param otherVector defines the second operand
  58697. * @returns the resulting Vector3
  58698. */
  58699. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58700. /**
  58701. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58702. * @param otherVector defines the second operand
  58703. * @param result defines the Vector3 object where to store the result
  58704. * @returns the current Vector3
  58705. */
  58706. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58707. /**
  58708. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58709. * @param x defines the x coordinate of the operand
  58710. * @param y defines the y coordinate of the operand
  58711. * @param z defines the z coordinate of the operand
  58712. * @returns the resulting Vector3
  58713. */
  58714. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58715. /**
  58716. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58717. * @param x defines the x coordinate of the operand
  58718. * @param y defines the y coordinate of the operand
  58719. * @param z defines the z coordinate of the operand
  58720. * @param result defines the Vector3 object where to store the result
  58721. * @returns the current Vector3
  58722. */
  58723. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58724. /**
  58725. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58726. * @returns a new Vector3
  58727. */
  58728. negate(): Vector3;
  58729. /**
  58730. * Multiplies the Vector3 coordinates by the float "scale"
  58731. * @param scale defines the multiplier factor
  58732. * @returns the current updated Vector3
  58733. */
  58734. scaleInPlace(scale: number): Vector3;
  58735. /**
  58736. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58737. * @param scale defines the multiplier factor
  58738. * @returns a new Vector3
  58739. */
  58740. scale(scale: number): Vector3;
  58741. /**
  58742. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58743. * @param scale defines the multiplier factor
  58744. * @param result defines the Vector3 object where to store the result
  58745. * @returns the current Vector3
  58746. */
  58747. scaleToRef(scale: number, result: Vector3): Vector3;
  58748. /**
  58749. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  58750. * @param scale defines the scale factor
  58751. * @param result defines the Vector3 object where to store the result
  58752. * @returns the unmodified current Vector3
  58753. */
  58754. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  58755. /**
  58756. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  58757. * @param otherVector defines the second operand
  58758. * @returns true if both vectors are equals
  58759. */
  58760. equals(otherVector: DeepImmutable<Vector3>): boolean;
  58761. /**
  58762. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  58763. * @param otherVector defines the second operand
  58764. * @param epsilon defines the minimal distance to define values as equals
  58765. * @returns true if both vectors are distant less than epsilon
  58766. */
  58767. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  58768. /**
  58769. * Returns true if the current Vector3 coordinates equals the given floats
  58770. * @param x defines the x coordinate of the operand
  58771. * @param y defines the y coordinate of the operand
  58772. * @param z defines the z coordinate of the operand
  58773. * @returns true if both vectors are equals
  58774. */
  58775. equalsToFloats(x: number, y: number, z: number): boolean;
  58776. /**
  58777. * Multiplies the current Vector3 coordinates by the given ones
  58778. * @param otherVector defines the second operand
  58779. * @returns the current updated Vector3
  58780. */
  58781. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58782. /**
  58783. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  58784. * @param otherVector defines the second operand
  58785. * @returns the new Vector3
  58786. */
  58787. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  58788. /**
  58789. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  58790. * @param otherVector defines the second operand
  58791. * @param result defines the Vector3 object where to store the result
  58792. * @returns the current Vector3
  58793. */
  58794. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58795. /**
  58796. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  58797. * @param x defines the x coordinate of the operand
  58798. * @param y defines the y coordinate of the operand
  58799. * @param z defines the z coordinate of the operand
  58800. * @returns the new Vector3
  58801. */
  58802. multiplyByFloats(x: number, y: number, z: number): Vector3;
  58803. /**
  58804. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  58805. * @param otherVector defines the second operand
  58806. * @returns the new Vector3
  58807. */
  58808. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  58809. /**
  58810. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  58811. * @param otherVector defines the second operand
  58812. * @param result defines the Vector3 object where to store the result
  58813. * @returns the current Vector3
  58814. */
  58815. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58816. /**
  58817. * Divides the current Vector3 coordinates by the given ones.
  58818. * @param otherVector defines the second operand
  58819. * @returns the current updated Vector3
  58820. */
  58821. divideInPlace(otherVector: Vector3): Vector3;
  58822. /**
  58823. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  58824. * @param other defines the second operand
  58825. * @returns the current updated Vector3
  58826. */
  58827. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58828. /**
  58829. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  58830. * @param other defines the second operand
  58831. * @returns the current updated Vector3
  58832. */
  58833. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58834. /**
  58835. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  58836. * @param x defines the x coordinate of the operand
  58837. * @param y defines the y coordinate of the operand
  58838. * @param z defines the z coordinate of the operand
  58839. * @returns the current updated Vector3
  58840. */
  58841. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58842. /**
  58843. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  58844. * @param x defines the x coordinate of the operand
  58845. * @param y defines the y coordinate of the operand
  58846. * @param z defines the z coordinate of the operand
  58847. * @returns the current updated Vector3
  58848. */
  58849. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58850. /**
  58851. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  58852. * Check if is non uniform within a certain amount of decimal places to account for this
  58853. * @param epsilon the amount the values can differ
  58854. * @returns if the the vector is non uniform to a certain number of decimal places
  58855. */
  58856. isNonUniformWithinEpsilon(epsilon: number): boolean;
  58857. /**
  58858. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  58859. */
  58860. readonly isNonUniform: boolean;
  58861. /**
  58862. * Gets a new Vector3 from current Vector3 floored values
  58863. * @returns a new Vector3
  58864. */
  58865. floor(): Vector3;
  58866. /**
  58867. * Gets a new Vector3 from current Vector3 floored values
  58868. * @returns a new Vector3
  58869. */
  58870. fract(): Vector3;
  58871. /**
  58872. * Gets the length of the Vector3
  58873. * @returns the length of the Vecto3
  58874. */
  58875. length(): number;
  58876. /**
  58877. * Gets the squared length of the Vector3
  58878. * @returns squared length of the Vector3
  58879. */
  58880. lengthSquared(): number;
  58881. /**
  58882. * Normalize the current Vector3.
  58883. * Please note that this is an in place operation.
  58884. * @returns the current updated Vector3
  58885. */
  58886. normalize(): Vector3;
  58887. /**
  58888. * Reorders the x y z properties of the vector in place
  58889. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  58890. * @returns the current updated vector
  58891. */
  58892. reorderInPlace(order: string): this;
  58893. /**
  58894. * Rotates the vector around 0,0,0 by a quaternion
  58895. * @param quaternion the rotation quaternion
  58896. * @param result vector to store the result
  58897. * @returns the resulting vector
  58898. */
  58899. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  58900. /**
  58901. * Rotates a vector around a given point
  58902. * @param quaternion the rotation quaternion
  58903. * @param point the point to rotate around
  58904. * @param result vector to store the result
  58905. * @returns the resulting vector
  58906. */
  58907. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  58908. /**
  58909. * Normalize the current Vector3 with the given input length.
  58910. * Please note that this is an in place operation.
  58911. * @param len the length of the vector
  58912. * @returns the current updated Vector3
  58913. */
  58914. normalizeFromLength(len: number): Vector3;
  58915. /**
  58916. * Normalize the current Vector3 to a new vector
  58917. * @returns the new Vector3
  58918. */
  58919. normalizeToNew(): Vector3;
  58920. /**
  58921. * Normalize the current Vector3 to the reference
  58922. * @param reference define the Vector3 to update
  58923. * @returns the updated Vector3
  58924. */
  58925. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  58926. /**
  58927. * Creates a new Vector3 copied from the current Vector3
  58928. * @returns the new Vector3
  58929. */
  58930. clone(): Vector3;
  58931. /**
  58932. * Copies the given vector coordinates to the current Vector3 ones
  58933. * @param source defines the source Vector3
  58934. * @returns the current updated Vector3
  58935. */
  58936. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  58937. /**
  58938. * Copies the given floats to the current Vector3 coordinates
  58939. * @param x defines the x coordinate of the operand
  58940. * @param y defines the y coordinate of the operand
  58941. * @param z defines the z coordinate of the operand
  58942. * @returns the current updated Vector3
  58943. */
  58944. copyFromFloats(x: number, y: number, z: number): Vector3;
  58945. /**
  58946. * Copies the given floats to the current Vector3 coordinates
  58947. * @param x defines the x coordinate of the operand
  58948. * @param y defines the y coordinate of the operand
  58949. * @param z defines the z coordinate of the operand
  58950. * @returns the current updated Vector3
  58951. */
  58952. set(x: number, y: number, z: number): Vector3;
  58953. /**
  58954. * Copies the given float to the current Vector3 coordinates
  58955. * @param v defines the x, y and z coordinates of the operand
  58956. * @returns the current updated Vector3
  58957. */
  58958. setAll(v: number): Vector3;
  58959. /**
  58960. * Get the clip factor between two vectors
  58961. * @param vector0 defines the first operand
  58962. * @param vector1 defines the second operand
  58963. * @param axis defines the axis to use
  58964. * @param size defines the size along the axis
  58965. * @returns the clip factor
  58966. */
  58967. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58968. /**
  58969. * Get angle between two vectors
  58970. * @param vector0 angle between vector0 and vector1
  58971. * @param vector1 angle between vector0 and vector1
  58972. * @param normal direction of the normal
  58973. * @return the angle between vector0 and vector1
  58974. */
  58975. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  58976. /**
  58977. * Returns a new Vector3 set from the index "offset" of the given array
  58978. * @param array defines the source array
  58979. * @param offset defines the offset in the source array
  58980. * @returns the new Vector3
  58981. */
  58982. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  58983. /**
  58984. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  58985. * This function is deprecated. Use FromArray instead
  58986. * @param array defines the source array
  58987. * @param offset defines the offset in the source array
  58988. * @returns the new Vector3
  58989. */
  58990. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  58991. /**
  58992. * Sets the given vector "result" with the element values from the index "offset" of the given array
  58993. * @param array defines the source array
  58994. * @param offset defines the offset in the source array
  58995. * @param result defines the Vector3 where to store the result
  58996. */
  58997. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  58998. /**
  58999. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59000. * This function is deprecated. Use FromArrayToRef instead.
  59001. * @param array defines the source array
  59002. * @param offset defines the offset in the source array
  59003. * @param result defines the Vector3 where to store the result
  59004. */
  59005. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59006. /**
  59007. * Sets the given vector "result" with the given floats.
  59008. * @param x defines the x coordinate of the source
  59009. * @param y defines the y coordinate of the source
  59010. * @param z defines the z coordinate of the source
  59011. * @param result defines the Vector3 where to store the result
  59012. */
  59013. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59014. /**
  59015. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59016. * @returns a new empty Vector3
  59017. */
  59018. static Zero(): Vector3;
  59019. /**
  59020. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59021. * @returns a new unit Vector3
  59022. */
  59023. static One(): Vector3;
  59024. /**
  59025. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59026. * @returns a new up Vector3
  59027. */
  59028. static Up(): Vector3;
  59029. /**
  59030. * Gets a up Vector3 that must not be updated
  59031. */
  59032. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59033. /**
  59034. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59035. * @returns a new down Vector3
  59036. */
  59037. static Down(): Vector3;
  59038. /**
  59039. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59040. * @returns a new forward Vector3
  59041. */
  59042. static Forward(): Vector3;
  59043. /**
  59044. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59045. * @returns a new forward Vector3
  59046. */
  59047. static Backward(): Vector3;
  59048. /**
  59049. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59050. * @returns a new right Vector3
  59051. */
  59052. static Right(): Vector3;
  59053. /**
  59054. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59055. * @returns a new left Vector3
  59056. */
  59057. static Left(): Vector3;
  59058. /**
  59059. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59060. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59061. * @param vector defines the Vector3 to transform
  59062. * @param transformation defines the transformation matrix
  59063. * @returns the transformed Vector3
  59064. */
  59065. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59066. /**
  59067. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59068. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59069. * @param vector defines the Vector3 to transform
  59070. * @param transformation defines the transformation matrix
  59071. * @param result defines the Vector3 where to store the result
  59072. */
  59073. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59074. /**
  59075. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59076. * This method computes tranformed coordinates only, not transformed direction vectors
  59077. * @param x define the x coordinate of the source vector
  59078. * @param y define the y coordinate of the source vector
  59079. * @param z define the z coordinate of the source vector
  59080. * @param transformation defines the transformation matrix
  59081. * @param result defines the Vector3 where to store the result
  59082. */
  59083. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59084. /**
  59085. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59086. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59087. * @param vector defines the Vector3 to transform
  59088. * @param transformation defines the transformation matrix
  59089. * @returns the new Vector3
  59090. */
  59091. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59092. /**
  59093. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59094. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59095. * @param vector defines the Vector3 to transform
  59096. * @param transformation defines the transformation matrix
  59097. * @param result defines the Vector3 where to store the result
  59098. */
  59099. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59100. /**
  59101. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59102. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59103. * @param x define the x coordinate of the source vector
  59104. * @param y define the y coordinate of the source vector
  59105. * @param z define the z coordinate of the source vector
  59106. * @param transformation defines the transformation matrix
  59107. * @param result defines the Vector3 where to store the result
  59108. */
  59109. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59110. /**
  59111. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59112. * @param value1 defines the first control point
  59113. * @param value2 defines the second control point
  59114. * @param value3 defines the third control point
  59115. * @param value4 defines the fourth control point
  59116. * @param amount defines the amount on the spline to use
  59117. * @returns the new Vector3
  59118. */
  59119. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59120. /**
  59121. * 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"
  59122. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59123. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59124. * @param value defines the current value
  59125. * @param min defines the lower range value
  59126. * @param max defines the upper range value
  59127. * @returns the new Vector3
  59128. */
  59129. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59130. /**
  59131. * 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"
  59132. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59133. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59134. * @param value defines the current value
  59135. * @param min defines the lower range value
  59136. * @param max defines the upper range value
  59137. * @param result defines the Vector3 where to store the result
  59138. */
  59139. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59140. /**
  59141. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59142. * @param value1 defines the first control point
  59143. * @param tangent1 defines the first tangent vector
  59144. * @param value2 defines the second control point
  59145. * @param tangent2 defines the second tangent vector
  59146. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59147. * @returns the new Vector3
  59148. */
  59149. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59150. /**
  59151. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59152. * @param start defines the start value
  59153. * @param end defines the end value
  59154. * @param amount max defines amount between both (between 0 and 1)
  59155. * @returns the new Vector3
  59156. */
  59157. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59158. /**
  59159. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59160. * @param start defines the start value
  59161. * @param end defines the end value
  59162. * @param amount max defines amount between both (between 0 and 1)
  59163. * @param result defines the Vector3 where to store the result
  59164. */
  59165. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59166. /**
  59167. * Returns the dot product (float) between the vectors "left" and "right"
  59168. * @param left defines the left operand
  59169. * @param right defines the right operand
  59170. * @returns the dot product
  59171. */
  59172. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59173. /**
  59174. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59175. * The cross product is then orthogonal to both "left" and "right"
  59176. * @param left defines the left operand
  59177. * @param right defines the right operand
  59178. * @returns the cross product
  59179. */
  59180. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59181. /**
  59182. * Sets the given vector "result" with the cross product of "left" and "right"
  59183. * The cross product is then orthogonal to both "left" and "right"
  59184. * @param left defines the left operand
  59185. * @param right defines the right operand
  59186. * @param result defines the Vector3 where to store the result
  59187. */
  59188. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59189. /**
  59190. * Returns a new Vector3 as the normalization of the given vector
  59191. * @param vector defines the Vector3 to normalize
  59192. * @returns the new Vector3
  59193. */
  59194. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59195. /**
  59196. * Sets the given vector "result" with the normalization of the given first vector
  59197. * @param vector defines the Vector3 to normalize
  59198. * @param result defines the Vector3 where to store the result
  59199. */
  59200. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59201. /**
  59202. * Project a Vector3 onto screen space
  59203. * @param vector defines the Vector3 to project
  59204. * @param world defines the world matrix to use
  59205. * @param transform defines the transform (view x projection) matrix to use
  59206. * @param viewport defines the screen viewport to use
  59207. * @returns the new Vector3
  59208. */
  59209. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59210. /** @hidden */
  59211. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59212. /**
  59213. * Unproject from screen space to object space
  59214. * @param source defines the screen space Vector3 to use
  59215. * @param viewportWidth defines the current width of the viewport
  59216. * @param viewportHeight defines the current height of the viewport
  59217. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59218. * @param transform defines the transform (view x projection) matrix to use
  59219. * @returns the new Vector3
  59220. */
  59221. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59222. /**
  59223. * Unproject from screen space to object space
  59224. * @param source defines the screen space Vector3 to use
  59225. * @param viewportWidth defines the current width of the viewport
  59226. * @param viewportHeight defines the current height of the viewport
  59227. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59228. * @param view defines the view matrix to use
  59229. * @param projection defines the projection matrix to use
  59230. * @returns the new Vector3
  59231. */
  59232. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59233. /**
  59234. * Unproject from screen space to object space
  59235. * @param source defines the screen space Vector3 to use
  59236. * @param viewportWidth defines the current width of the viewport
  59237. * @param viewportHeight defines the current height of the viewport
  59238. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59239. * @param view defines the view matrix to use
  59240. * @param projection defines the projection matrix to use
  59241. * @param result defines the Vector3 where to store the result
  59242. */
  59243. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59244. /**
  59245. * Unproject from screen space to object space
  59246. * @param sourceX defines the screen space x coordinate to use
  59247. * @param sourceY defines the screen space y coordinate to use
  59248. * @param sourceZ defines the screen space z coordinate to use
  59249. * @param viewportWidth defines the current width of the viewport
  59250. * @param viewportHeight defines the current height of the viewport
  59251. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59252. * @param view defines the view matrix to use
  59253. * @param projection defines the projection matrix to use
  59254. * @param result defines the Vector3 where to store the result
  59255. */
  59256. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59257. /**
  59258. * Gets the minimal coordinate values between two Vector3
  59259. * @param left defines the first operand
  59260. * @param right defines the second operand
  59261. * @returns the new Vector3
  59262. */
  59263. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59264. /**
  59265. * Gets the maximal coordinate values between two Vector3
  59266. * @param left defines the first operand
  59267. * @param right defines the second operand
  59268. * @returns the new Vector3
  59269. */
  59270. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59271. /**
  59272. * Returns the distance between the vectors "value1" and "value2"
  59273. * @param value1 defines the first operand
  59274. * @param value2 defines the second operand
  59275. * @returns the distance
  59276. */
  59277. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59278. /**
  59279. * Returns the squared distance between the vectors "value1" and "value2"
  59280. * @param value1 defines the first operand
  59281. * @param value2 defines the second operand
  59282. * @returns the squared distance
  59283. */
  59284. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59285. /**
  59286. * Returns a new Vector3 located at the center between "value1" and "value2"
  59287. * @param value1 defines the first operand
  59288. * @param value2 defines the second operand
  59289. * @returns the new Vector3
  59290. */
  59291. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59292. /**
  59293. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59294. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59295. * to something in order to rotate it from its local system to the given target system
  59296. * Note: axis1, axis2 and axis3 are normalized during this operation
  59297. * @param axis1 defines the first axis
  59298. * @param axis2 defines the second axis
  59299. * @param axis3 defines the third axis
  59300. * @returns a new Vector3
  59301. */
  59302. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59303. /**
  59304. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59305. * @param axis1 defines the first axis
  59306. * @param axis2 defines the second axis
  59307. * @param axis3 defines the third axis
  59308. * @param ref defines the Vector3 where to store the result
  59309. */
  59310. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59311. }
  59312. /**
  59313. * Vector4 class created for EulerAngle class conversion to Quaternion
  59314. */
  59315. export class Vector4 {
  59316. /** x value of the vector */
  59317. x: number;
  59318. /** y value of the vector */
  59319. y: number;
  59320. /** z value of the vector */
  59321. z: number;
  59322. /** w value of the vector */
  59323. w: number;
  59324. /**
  59325. * Creates a Vector4 object from the given floats.
  59326. * @param x x value of the vector
  59327. * @param y y value of the vector
  59328. * @param z z value of the vector
  59329. * @param w w value of the vector
  59330. */
  59331. constructor(
  59332. /** x value of the vector */
  59333. x: number,
  59334. /** y value of the vector */
  59335. y: number,
  59336. /** z value of the vector */
  59337. z: number,
  59338. /** w value of the vector */
  59339. w: number);
  59340. /**
  59341. * Returns the string with the Vector4 coordinates.
  59342. * @returns a string containing all the vector values
  59343. */
  59344. toString(): string;
  59345. /**
  59346. * Returns the string "Vector4".
  59347. * @returns "Vector4"
  59348. */
  59349. getClassName(): string;
  59350. /**
  59351. * Returns the Vector4 hash code.
  59352. * @returns a unique hash code
  59353. */
  59354. getHashCode(): number;
  59355. /**
  59356. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59357. * @returns the resulting array
  59358. */
  59359. asArray(): number[];
  59360. /**
  59361. * Populates the given array from the given index with the Vector4 coordinates.
  59362. * @param array array to populate
  59363. * @param index index of the array to start at (default: 0)
  59364. * @returns the Vector4.
  59365. */
  59366. toArray(array: FloatArray, index?: number): Vector4;
  59367. /**
  59368. * Adds the given vector to the current Vector4.
  59369. * @param otherVector the vector to add
  59370. * @returns the updated Vector4.
  59371. */
  59372. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59373. /**
  59374. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59375. * @param otherVector the vector to add
  59376. * @returns the resulting vector
  59377. */
  59378. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59379. /**
  59380. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59381. * @param otherVector the vector to add
  59382. * @param result the vector to store the result
  59383. * @returns the current Vector4.
  59384. */
  59385. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59386. /**
  59387. * Subtract in place the given vector from the current Vector4.
  59388. * @param otherVector the vector to subtract
  59389. * @returns the updated Vector4.
  59390. */
  59391. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59392. /**
  59393. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59394. * @param otherVector the vector to add
  59395. * @returns the new vector with the result
  59396. */
  59397. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59398. /**
  59399. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59400. * @param otherVector the vector to subtract
  59401. * @param result the vector to store the result
  59402. * @returns the current Vector4.
  59403. */
  59404. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59405. /**
  59406. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59407. */
  59408. /**
  59409. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59410. * @param x value to subtract
  59411. * @param y value to subtract
  59412. * @param z value to subtract
  59413. * @param w value to subtract
  59414. * @returns new vector containing the result
  59415. */
  59416. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59417. /**
  59418. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59419. * @param x value to subtract
  59420. * @param y value to subtract
  59421. * @param z value to subtract
  59422. * @param w value to subtract
  59423. * @param result the vector to store the result in
  59424. * @returns the current Vector4.
  59425. */
  59426. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59427. /**
  59428. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59429. * @returns a new vector with the negated values
  59430. */
  59431. negate(): Vector4;
  59432. /**
  59433. * Multiplies the current Vector4 coordinates by scale (float).
  59434. * @param scale the number to scale with
  59435. * @returns the updated Vector4.
  59436. */
  59437. scaleInPlace(scale: number): Vector4;
  59438. /**
  59439. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59440. * @param scale the number to scale with
  59441. * @returns a new vector with the result
  59442. */
  59443. scale(scale: number): Vector4;
  59444. /**
  59445. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59446. * @param scale the number to scale with
  59447. * @param result a vector to store the result in
  59448. * @returns the current Vector4.
  59449. */
  59450. scaleToRef(scale: number, result: Vector4): Vector4;
  59451. /**
  59452. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59453. * @param scale defines the scale factor
  59454. * @param result defines the Vector4 object where to store the result
  59455. * @returns the unmodified current Vector4
  59456. */
  59457. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59458. /**
  59459. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59460. * @param otherVector the vector to compare against
  59461. * @returns true if they are equal
  59462. */
  59463. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59464. /**
  59465. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59466. * @param otherVector vector to compare against
  59467. * @param epsilon (Default: very small number)
  59468. * @returns true if they are equal
  59469. */
  59470. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59471. /**
  59472. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59473. * @param x x value to compare against
  59474. * @param y y value to compare against
  59475. * @param z z value to compare against
  59476. * @param w w value to compare against
  59477. * @returns true if equal
  59478. */
  59479. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59480. /**
  59481. * Multiplies in place the current Vector4 by the given one.
  59482. * @param otherVector vector to multiple with
  59483. * @returns the updated Vector4.
  59484. */
  59485. multiplyInPlace(otherVector: Vector4): Vector4;
  59486. /**
  59487. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59488. * @param otherVector vector to multiple with
  59489. * @returns resulting new vector
  59490. */
  59491. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59492. /**
  59493. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59494. * @param otherVector vector to multiple with
  59495. * @param result vector to store the result
  59496. * @returns the current Vector4.
  59497. */
  59498. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59499. /**
  59500. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59501. * @param x x value multiply with
  59502. * @param y y value multiply with
  59503. * @param z z value multiply with
  59504. * @param w w value multiply with
  59505. * @returns resulting new vector
  59506. */
  59507. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59508. /**
  59509. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59510. * @param otherVector vector to devide with
  59511. * @returns resulting new vector
  59512. */
  59513. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59514. /**
  59515. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59516. * @param otherVector vector to devide with
  59517. * @param result vector to store the result
  59518. * @returns the current Vector4.
  59519. */
  59520. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59521. /**
  59522. * Divides the current Vector3 coordinates by the given ones.
  59523. * @param otherVector vector to devide with
  59524. * @returns the updated Vector3.
  59525. */
  59526. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59527. /**
  59528. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59529. * @param other defines the second operand
  59530. * @returns the current updated Vector4
  59531. */
  59532. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59533. /**
  59534. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59535. * @param other defines the second operand
  59536. * @returns the current updated Vector4
  59537. */
  59538. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59539. /**
  59540. * Gets a new Vector4 from current Vector4 floored values
  59541. * @returns a new Vector4
  59542. */
  59543. floor(): Vector4;
  59544. /**
  59545. * Gets a new Vector4 from current Vector3 floored values
  59546. * @returns a new Vector4
  59547. */
  59548. fract(): Vector4;
  59549. /**
  59550. * Returns the Vector4 length (float).
  59551. * @returns the length
  59552. */
  59553. length(): number;
  59554. /**
  59555. * Returns the Vector4 squared length (float).
  59556. * @returns the length squared
  59557. */
  59558. lengthSquared(): number;
  59559. /**
  59560. * Normalizes in place the Vector4.
  59561. * @returns the updated Vector4.
  59562. */
  59563. normalize(): Vector4;
  59564. /**
  59565. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59566. * @returns this converted to a new vector3
  59567. */
  59568. toVector3(): Vector3;
  59569. /**
  59570. * Returns a new Vector4 copied from the current one.
  59571. * @returns the new cloned vector
  59572. */
  59573. clone(): Vector4;
  59574. /**
  59575. * Updates the current Vector4 with the given one coordinates.
  59576. * @param source the source vector to copy from
  59577. * @returns the updated Vector4.
  59578. */
  59579. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59580. /**
  59581. * Updates the current Vector4 coordinates with the given floats.
  59582. * @param x float to copy from
  59583. * @param y float to copy from
  59584. * @param z float to copy from
  59585. * @param w float to copy from
  59586. * @returns the updated Vector4.
  59587. */
  59588. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59589. /**
  59590. * Updates the current Vector4 coordinates with the given floats.
  59591. * @param x float to set from
  59592. * @param y float to set from
  59593. * @param z float to set from
  59594. * @param w float to set from
  59595. * @returns the updated Vector4.
  59596. */
  59597. set(x: number, y: number, z: number, w: number): Vector4;
  59598. /**
  59599. * Copies the given float to the current Vector3 coordinates
  59600. * @param v defines the x, y, z and w coordinates of the operand
  59601. * @returns the current updated Vector3
  59602. */
  59603. setAll(v: number): Vector4;
  59604. /**
  59605. * Returns a new Vector4 set from the starting index of the given array.
  59606. * @param array the array to pull values from
  59607. * @param offset the offset into the array to start at
  59608. * @returns the new vector
  59609. */
  59610. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59611. /**
  59612. * Updates the given vector "result" from the starting index of the given array.
  59613. * @param array the array to pull values from
  59614. * @param offset the offset into the array to start at
  59615. * @param result the vector to store the result in
  59616. */
  59617. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59618. /**
  59619. * Updates the given vector "result" from the starting index of the given Float32Array.
  59620. * @param array the array to pull values from
  59621. * @param offset the offset into the array to start at
  59622. * @param result the vector to store the result in
  59623. */
  59624. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59625. /**
  59626. * Updates the given vector "result" coordinates from the given floats.
  59627. * @param x float to set from
  59628. * @param y float to set from
  59629. * @param z float to set from
  59630. * @param w float to set from
  59631. * @param result the vector to the floats in
  59632. */
  59633. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59634. /**
  59635. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59636. * @returns the new vector
  59637. */
  59638. static Zero(): Vector4;
  59639. /**
  59640. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59641. * @returns the new vector
  59642. */
  59643. static One(): Vector4;
  59644. /**
  59645. * Returns a new normalized Vector4 from the given one.
  59646. * @param vector the vector to normalize
  59647. * @returns the vector
  59648. */
  59649. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59650. /**
  59651. * Updates the given vector "result" from the normalization of the given one.
  59652. * @param vector the vector to normalize
  59653. * @param result the vector to store the result in
  59654. */
  59655. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59656. /**
  59657. * Returns a vector with the minimum values from the left and right vectors
  59658. * @param left left vector to minimize
  59659. * @param right right vector to minimize
  59660. * @returns a new vector with the minimum of the left and right vector values
  59661. */
  59662. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59663. /**
  59664. * Returns a vector with the maximum values from the left and right vectors
  59665. * @param left left vector to maximize
  59666. * @param right right vector to maximize
  59667. * @returns a new vector with the maximum of the left and right vector values
  59668. */
  59669. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59670. /**
  59671. * Returns the distance (float) between the vectors "value1" and "value2".
  59672. * @param value1 value to calulate the distance between
  59673. * @param value2 value to calulate the distance between
  59674. * @return the distance between the two vectors
  59675. */
  59676. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59677. /**
  59678. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59679. * @param value1 value to calulate the distance between
  59680. * @param value2 value to calulate the distance between
  59681. * @return the distance between the two vectors squared
  59682. */
  59683. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59684. /**
  59685. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59686. * @param value1 value to calulate the center between
  59687. * @param value2 value to calulate the center between
  59688. * @return the center between the two vectors
  59689. */
  59690. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59691. /**
  59692. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59693. * This methods computes transformed normalized direction vectors only.
  59694. * @param vector the vector to transform
  59695. * @param transformation the transformation matrix to apply
  59696. * @returns the new vector
  59697. */
  59698. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59699. /**
  59700. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59701. * This methods computes transformed normalized direction vectors only.
  59702. * @param vector the vector to transform
  59703. * @param transformation the transformation matrix to apply
  59704. * @param result the vector to store the result in
  59705. */
  59706. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59707. /**
  59708. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59709. * This methods computes transformed normalized direction vectors only.
  59710. * @param x value to transform
  59711. * @param y value to transform
  59712. * @param z value to transform
  59713. * @param w value to transform
  59714. * @param transformation the transformation matrix to apply
  59715. * @param result the vector to store the results in
  59716. */
  59717. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59718. /**
  59719. * Creates a new Vector4 from a Vector3
  59720. * @param source defines the source data
  59721. * @param w defines the 4th component (default is 0)
  59722. * @returns a new Vector4
  59723. */
  59724. static FromVector3(source: Vector3, w?: number): Vector4;
  59725. }
  59726. /**
  59727. * Interface for the size containing width and height
  59728. */
  59729. export interface ISize {
  59730. /**
  59731. * Width
  59732. */
  59733. width: number;
  59734. /**
  59735. * Heighht
  59736. */
  59737. height: number;
  59738. }
  59739. /**
  59740. * Size containing widht and height
  59741. */
  59742. export class Size implements ISize {
  59743. /**
  59744. * Width
  59745. */
  59746. width: number;
  59747. /**
  59748. * Height
  59749. */
  59750. height: number;
  59751. /**
  59752. * Creates a Size object from the given width and height (floats).
  59753. * @param width width of the new size
  59754. * @param height height of the new size
  59755. */
  59756. constructor(width: number, height: number);
  59757. /**
  59758. * Returns a string with the Size width and height
  59759. * @returns a string with the Size width and height
  59760. */
  59761. toString(): string;
  59762. /**
  59763. * "Size"
  59764. * @returns the string "Size"
  59765. */
  59766. getClassName(): string;
  59767. /**
  59768. * Returns the Size hash code.
  59769. * @returns a hash code for a unique width and height
  59770. */
  59771. getHashCode(): number;
  59772. /**
  59773. * Updates the current size from the given one.
  59774. * @param src the given size
  59775. */
  59776. copyFrom(src: Size): void;
  59777. /**
  59778. * Updates in place the current Size from the given floats.
  59779. * @param width width of the new size
  59780. * @param height height of the new size
  59781. * @returns the updated Size.
  59782. */
  59783. copyFromFloats(width: number, height: number): Size;
  59784. /**
  59785. * Updates in place the current Size from the given floats.
  59786. * @param width width to set
  59787. * @param height height to set
  59788. * @returns the updated Size.
  59789. */
  59790. set(width: number, height: number): Size;
  59791. /**
  59792. * Multiplies the width and height by numbers
  59793. * @param w factor to multiple the width by
  59794. * @param h factor to multiple the height by
  59795. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  59796. */
  59797. multiplyByFloats(w: number, h: number): Size;
  59798. /**
  59799. * Clones the size
  59800. * @returns a new Size copied from the given one.
  59801. */
  59802. clone(): Size;
  59803. /**
  59804. * True if the current Size and the given one width and height are strictly equal.
  59805. * @param other the other size to compare against
  59806. * @returns True if the current Size and the given one width and height are strictly equal.
  59807. */
  59808. equals(other: Size): boolean;
  59809. /**
  59810. * The surface of the Size : width * height (float).
  59811. */
  59812. readonly surface: number;
  59813. /**
  59814. * Create a new size of zero
  59815. * @returns a new Size set to (0.0, 0.0)
  59816. */
  59817. static Zero(): Size;
  59818. /**
  59819. * Sums the width and height of two sizes
  59820. * @param otherSize size to add to this size
  59821. * @returns a new Size set as the addition result of the current Size and the given one.
  59822. */
  59823. add(otherSize: Size): Size;
  59824. /**
  59825. * Subtracts the width and height of two
  59826. * @param otherSize size to subtract to this size
  59827. * @returns a new Size set as the subtraction result of the given one from the current Size.
  59828. */
  59829. subtract(otherSize: Size): Size;
  59830. /**
  59831. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  59832. * @param start starting size to lerp between
  59833. * @param end end size to lerp between
  59834. * @param amount amount to lerp between the start and end values
  59835. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  59836. */
  59837. static Lerp(start: Size, end: Size, amount: number): Size;
  59838. }
  59839. /**
  59840. * Class used to store quaternion data
  59841. * @see https://en.wikipedia.org/wiki/Quaternion
  59842. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  59843. */
  59844. export class Quaternion {
  59845. /** defines the first component (0 by default) */
  59846. x: number;
  59847. /** defines the second component (0 by default) */
  59848. y: number;
  59849. /** defines the third component (0 by default) */
  59850. z: number;
  59851. /** defines the fourth component (1.0 by default) */
  59852. w: number;
  59853. /**
  59854. * Creates a new Quaternion from the given floats
  59855. * @param x defines the first component (0 by default)
  59856. * @param y defines the second component (0 by default)
  59857. * @param z defines the third component (0 by default)
  59858. * @param w defines the fourth component (1.0 by default)
  59859. */
  59860. constructor(
  59861. /** defines the first component (0 by default) */
  59862. x?: number,
  59863. /** defines the second component (0 by default) */
  59864. y?: number,
  59865. /** defines the third component (0 by default) */
  59866. z?: number,
  59867. /** defines the fourth component (1.0 by default) */
  59868. w?: number);
  59869. /**
  59870. * Gets a string representation for the current quaternion
  59871. * @returns a string with the Quaternion coordinates
  59872. */
  59873. toString(): string;
  59874. /**
  59875. * Gets the class name of the quaternion
  59876. * @returns the string "Quaternion"
  59877. */
  59878. getClassName(): string;
  59879. /**
  59880. * Gets a hash code for this quaternion
  59881. * @returns the quaternion hash code
  59882. */
  59883. getHashCode(): number;
  59884. /**
  59885. * Copy the quaternion to an array
  59886. * @returns a new array populated with 4 elements from the quaternion coordinates
  59887. */
  59888. asArray(): number[];
  59889. /**
  59890. * Check if two quaternions are equals
  59891. * @param otherQuaternion defines the second operand
  59892. * @return true if the current quaternion and the given one coordinates are strictly equals
  59893. */
  59894. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  59895. /**
  59896. * Clone the current quaternion
  59897. * @returns a new quaternion copied from the current one
  59898. */
  59899. clone(): Quaternion;
  59900. /**
  59901. * Copy a quaternion to the current one
  59902. * @param other defines the other quaternion
  59903. * @returns the updated current quaternion
  59904. */
  59905. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  59906. /**
  59907. * Updates the current quaternion with the given float coordinates
  59908. * @param x defines the x coordinate
  59909. * @param y defines the y coordinate
  59910. * @param z defines the z coordinate
  59911. * @param w defines the w coordinate
  59912. * @returns the updated current quaternion
  59913. */
  59914. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  59915. /**
  59916. * Updates the current quaternion from the given float coordinates
  59917. * @param x defines the x coordinate
  59918. * @param y defines the y coordinate
  59919. * @param z defines the z coordinate
  59920. * @param w defines the w coordinate
  59921. * @returns the updated current quaternion
  59922. */
  59923. set(x: number, y: number, z: number, w: number): Quaternion;
  59924. /**
  59925. * Adds two quaternions
  59926. * @param other defines the second operand
  59927. * @returns a new quaternion as the addition result of the given one and the current quaternion
  59928. */
  59929. add(other: DeepImmutable<Quaternion>): Quaternion;
  59930. /**
  59931. * Add a quaternion to the current one
  59932. * @param other defines the quaternion to add
  59933. * @returns the current quaternion
  59934. */
  59935. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  59936. /**
  59937. * Subtract two quaternions
  59938. * @param other defines the second operand
  59939. * @returns a new quaternion as the subtraction result of the given one from the current one
  59940. */
  59941. subtract(other: Quaternion): Quaternion;
  59942. /**
  59943. * Multiplies the current quaternion by a scale factor
  59944. * @param value defines the scale factor
  59945. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  59946. */
  59947. scale(value: number): Quaternion;
  59948. /**
  59949. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  59950. * @param scale defines the scale factor
  59951. * @param result defines the Quaternion object where to store the result
  59952. * @returns the unmodified current quaternion
  59953. */
  59954. scaleToRef(scale: number, result: Quaternion): Quaternion;
  59955. /**
  59956. * Multiplies in place the current quaternion by a scale factor
  59957. * @param value defines the scale factor
  59958. * @returns the current modified quaternion
  59959. */
  59960. scaleInPlace(value: number): Quaternion;
  59961. /**
  59962. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59963. * @param scale defines the scale factor
  59964. * @param result defines the Quaternion object where to store the result
  59965. * @returns the unmodified current quaternion
  59966. */
  59967. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59968. /**
  59969. * Multiplies two quaternions
  59970. * @param q1 defines the second operand
  59971. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  59972. */
  59973. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  59974. /**
  59975. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  59976. * @param q1 defines the second operand
  59977. * @param result defines the target quaternion
  59978. * @returns the current quaternion
  59979. */
  59980. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  59981. /**
  59982. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  59983. * @param q1 defines the second operand
  59984. * @returns the currentupdated quaternion
  59985. */
  59986. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  59987. /**
  59988. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  59989. * @param ref defines the target quaternion
  59990. * @returns the current quaternion
  59991. */
  59992. conjugateToRef(ref: Quaternion): Quaternion;
  59993. /**
  59994. * Conjugates in place (1-q) the current quaternion
  59995. * @returns the current updated quaternion
  59996. */
  59997. conjugateInPlace(): Quaternion;
  59998. /**
  59999. * Conjugates in place (1-q) the current quaternion
  60000. * @returns a new quaternion
  60001. */
  60002. conjugate(): Quaternion;
  60003. /**
  60004. * Gets length of current quaternion
  60005. * @returns the quaternion length (float)
  60006. */
  60007. length(): number;
  60008. /**
  60009. * Normalize in place the current quaternion
  60010. * @returns the current updated quaternion
  60011. */
  60012. normalize(): Quaternion;
  60013. /**
  60014. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60015. * @param order is a reserved parameter and is ignore for now
  60016. * @returns a new Vector3 containing the Euler angles
  60017. */
  60018. toEulerAngles(order?: string): Vector3;
  60019. /**
  60020. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60021. * @param result defines the vector which will be filled with the Euler angles
  60022. * @param order is a reserved parameter and is ignore for now
  60023. * @returns the current unchanged quaternion
  60024. */
  60025. toEulerAnglesToRef(result: Vector3): Quaternion;
  60026. /**
  60027. * Updates the given rotation matrix with the current quaternion values
  60028. * @param result defines the target matrix
  60029. * @returns the current unchanged quaternion
  60030. */
  60031. toRotationMatrix(result: Matrix): Quaternion;
  60032. /**
  60033. * Updates the current quaternion from the given rotation matrix values
  60034. * @param matrix defines the source matrix
  60035. * @returns the current updated quaternion
  60036. */
  60037. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60038. /**
  60039. * Creates a new quaternion from a rotation matrix
  60040. * @param matrix defines the source matrix
  60041. * @returns a new quaternion created from the given rotation matrix values
  60042. */
  60043. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60044. /**
  60045. * Updates the given quaternion with the given rotation matrix values
  60046. * @param matrix defines the source matrix
  60047. * @param result defines the target quaternion
  60048. */
  60049. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60050. /**
  60051. * Returns the dot product (float) between the quaternions "left" and "right"
  60052. * @param left defines the left operand
  60053. * @param right defines the right operand
  60054. * @returns the dot product
  60055. */
  60056. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60057. /**
  60058. * Checks if the two quaternions are close to each other
  60059. * @param quat0 defines the first quaternion to check
  60060. * @param quat1 defines the second quaternion to check
  60061. * @returns true if the two quaternions are close to each other
  60062. */
  60063. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60064. /**
  60065. * Creates an empty quaternion
  60066. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60067. */
  60068. static Zero(): Quaternion;
  60069. /**
  60070. * Inverse a given quaternion
  60071. * @param q defines the source quaternion
  60072. * @returns a new quaternion as the inverted current quaternion
  60073. */
  60074. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60075. /**
  60076. * Inverse a given quaternion
  60077. * @param q defines the source quaternion
  60078. * @param result the quaternion the result will be stored in
  60079. * @returns the result quaternion
  60080. */
  60081. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60082. /**
  60083. * Creates an identity quaternion
  60084. * @returns the identity quaternion
  60085. */
  60086. static Identity(): Quaternion;
  60087. /**
  60088. * Gets a boolean indicating if the given quaternion is identity
  60089. * @param quaternion defines the quaternion to check
  60090. * @returns true if the quaternion is identity
  60091. */
  60092. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60093. /**
  60094. * Creates a quaternion from a rotation around an axis
  60095. * @param axis defines the axis to use
  60096. * @param angle defines the angle to use
  60097. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60098. */
  60099. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60100. /**
  60101. * Creates a rotation around an axis and stores it into the given quaternion
  60102. * @param axis defines the axis to use
  60103. * @param angle defines the angle to use
  60104. * @param result defines the target quaternion
  60105. * @returns the target quaternion
  60106. */
  60107. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60108. /**
  60109. * Creates a new quaternion from data stored into an array
  60110. * @param array defines the data source
  60111. * @param offset defines the offset in the source array where the data starts
  60112. * @returns a new quaternion
  60113. */
  60114. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60115. /**
  60116. * Create a quaternion from Euler rotation angles
  60117. * @param x Pitch
  60118. * @param y Yaw
  60119. * @param z Roll
  60120. * @returns the new Quaternion
  60121. */
  60122. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60123. /**
  60124. * Updates a quaternion from Euler rotation angles
  60125. * @param x Pitch
  60126. * @param y Yaw
  60127. * @param z Roll
  60128. * @param result the quaternion to store the result
  60129. * @returns the updated quaternion
  60130. */
  60131. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60132. /**
  60133. * Create a quaternion from Euler rotation vector
  60134. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60135. * @returns the new Quaternion
  60136. */
  60137. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60138. /**
  60139. * Updates a quaternion from Euler rotation vector
  60140. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60141. * @param result the quaternion to store the result
  60142. * @returns the updated quaternion
  60143. */
  60144. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60145. /**
  60146. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60147. * @param yaw defines the rotation around Y axis
  60148. * @param pitch defines the rotation around X axis
  60149. * @param roll defines the rotation around Z axis
  60150. * @returns the new quaternion
  60151. */
  60152. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60153. /**
  60154. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60155. * @param yaw defines the rotation around Y axis
  60156. * @param pitch defines the rotation around X axis
  60157. * @param roll defines the rotation around Z axis
  60158. * @param result defines the target quaternion
  60159. */
  60160. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60161. /**
  60162. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60163. * @param alpha defines the rotation around first axis
  60164. * @param beta defines the rotation around second axis
  60165. * @param gamma defines the rotation around third axis
  60166. * @returns the new quaternion
  60167. */
  60168. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60169. /**
  60170. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60171. * @param alpha defines the rotation around first axis
  60172. * @param beta defines the rotation around second axis
  60173. * @param gamma defines the rotation around third axis
  60174. * @param result defines the target quaternion
  60175. */
  60176. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60177. /**
  60178. * 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)
  60179. * @param axis1 defines the first axis
  60180. * @param axis2 defines the second axis
  60181. * @param axis3 defines the third axis
  60182. * @returns the new quaternion
  60183. */
  60184. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60185. /**
  60186. * 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
  60187. * @param axis1 defines the first axis
  60188. * @param axis2 defines the second axis
  60189. * @param axis3 defines the third axis
  60190. * @param ref defines the target quaternion
  60191. */
  60192. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60193. /**
  60194. * Interpolates between two quaternions
  60195. * @param left defines first quaternion
  60196. * @param right defines second quaternion
  60197. * @param amount defines the gradient to use
  60198. * @returns the new interpolated quaternion
  60199. */
  60200. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60201. /**
  60202. * Interpolates between two quaternions and stores it into a target quaternion
  60203. * @param left defines first quaternion
  60204. * @param right defines second quaternion
  60205. * @param amount defines the gradient to use
  60206. * @param result defines the target quaternion
  60207. */
  60208. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60209. /**
  60210. * Interpolate between two quaternions using Hermite interpolation
  60211. * @param value1 defines first quaternion
  60212. * @param tangent1 defines the incoming tangent
  60213. * @param value2 defines second quaternion
  60214. * @param tangent2 defines the outgoing tangent
  60215. * @param amount defines the target quaternion
  60216. * @returns the new interpolated quaternion
  60217. */
  60218. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60219. }
  60220. /**
  60221. * Class used to store matrix data (4x4)
  60222. */
  60223. export class Matrix {
  60224. private static _updateFlagSeed;
  60225. private static _identityReadOnly;
  60226. private _isIdentity;
  60227. private _isIdentityDirty;
  60228. private _isIdentity3x2;
  60229. private _isIdentity3x2Dirty;
  60230. /**
  60231. * Gets the update flag of the matrix which is an unique number for the matrix.
  60232. * It will be incremented every time the matrix data change.
  60233. * You can use it to speed the comparison between two versions of the same matrix.
  60234. */
  60235. updateFlag: number;
  60236. private readonly _m;
  60237. /**
  60238. * Gets the internal data of the matrix
  60239. */
  60240. readonly m: DeepImmutable<Float32Array>;
  60241. /** @hidden */
  60242. _markAsUpdated(): void;
  60243. /** @hidden */
  60244. private _updateIdentityStatus;
  60245. /**
  60246. * Creates an empty matrix (filled with zeros)
  60247. */
  60248. constructor();
  60249. /**
  60250. * Check if the current matrix is identity
  60251. * @returns true is the matrix is the identity matrix
  60252. */
  60253. isIdentity(): boolean;
  60254. /**
  60255. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60256. * @returns true is the matrix is the identity matrix
  60257. */
  60258. isIdentityAs3x2(): boolean;
  60259. /**
  60260. * Gets the determinant of the matrix
  60261. * @returns the matrix determinant
  60262. */
  60263. determinant(): number;
  60264. /**
  60265. * Returns the matrix as a Float32Array
  60266. * @returns the matrix underlying array
  60267. */
  60268. toArray(): DeepImmutable<Float32Array>;
  60269. /**
  60270. * Returns the matrix as a Float32Array
  60271. * @returns the matrix underlying array.
  60272. */
  60273. asArray(): DeepImmutable<Float32Array>;
  60274. /**
  60275. * Inverts the current matrix in place
  60276. * @returns the current inverted matrix
  60277. */
  60278. invert(): Matrix;
  60279. /**
  60280. * Sets all the matrix elements to zero
  60281. * @returns the current matrix
  60282. */
  60283. reset(): Matrix;
  60284. /**
  60285. * Adds the current matrix with a second one
  60286. * @param other defines the matrix to add
  60287. * @returns a new matrix as the addition of the current matrix and the given one
  60288. */
  60289. add(other: DeepImmutable<Matrix>): Matrix;
  60290. /**
  60291. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60292. * @param other defines the matrix to add
  60293. * @param result defines the target matrix
  60294. * @returns the current matrix
  60295. */
  60296. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60297. /**
  60298. * Adds in place the given matrix to the current matrix
  60299. * @param other defines the second operand
  60300. * @returns the current updated matrix
  60301. */
  60302. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60303. /**
  60304. * Sets the given matrix to the current inverted Matrix
  60305. * @param other defines the target matrix
  60306. * @returns the unmodified current matrix
  60307. */
  60308. invertToRef(other: Matrix): Matrix;
  60309. /**
  60310. * add a value at the specified position in the current Matrix
  60311. * @param index the index of the value within the matrix. between 0 and 15.
  60312. * @param value the value to be added
  60313. * @returns the current updated matrix
  60314. */
  60315. addAtIndex(index: number, value: number): Matrix;
  60316. /**
  60317. * mutiply the specified position in the current Matrix by a value
  60318. * @param index the index of the value within the matrix. between 0 and 15.
  60319. * @param value the value to be added
  60320. * @returns the current updated matrix
  60321. */
  60322. multiplyAtIndex(index: number, value: number): Matrix;
  60323. /**
  60324. * Inserts the translation vector (using 3 floats) in the current matrix
  60325. * @param x defines the 1st component of the translation
  60326. * @param y defines the 2nd component of the translation
  60327. * @param z defines the 3rd component of the translation
  60328. * @returns the current updated matrix
  60329. */
  60330. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60331. /**
  60332. * Inserts the translation vector in the current matrix
  60333. * @param vector3 defines the translation to insert
  60334. * @returns the current updated matrix
  60335. */
  60336. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60337. /**
  60338. * Gets the translation value of the current matrix
  60339. * @returns a new Vector3 as the extracted translation from the matrix
  60340. */
  60341. getTranslation(): Vector3;
  60342. /**
  60343. * Fill a Vector3 with the extracted translation from the matrix
  60344. * @param result defines the Vector3 where to store the translation
  60345. * @returns the current matrix
  60346. */
  60347. getTranslationToRef(result: Vector3): Matrix;
  60348. /**
  60349. * Remove rotation and scaling part from the matrix
  60350. * @returns the updated matrix
  60351. */
  60352. removeRotationAndScaling(): Matrix;
  60353. /**
  60354. * Multiply two matrices
  60355. * @param other defines the second operand
  60356. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60357. */
  60358. multiply(other: DeepImmutable<Matrix>): Matrix;
  60359. /**
  60360. * Copy the current matrix from the given one
  60361. * @param other defines the source matrix
  60362. * @returns the current updated matrix
  60363. */
  60364. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60365. /**
  60366. * Populates the given array from the starting index with the current matrix values
  60367. * @param array defines the target array
  60368. * @param offset defines the offset in the target array where to start storing values
  60369. * @returns the current matrix
  60370. */
  60371. copyToArray(array: Float32Array, offset?: number): Matrix;
  60372. /**
  60373. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60374. * @param other defines the second operand
  60375. * @param result defines the matrix where to store the multiplication
  60376. * @returns the current matrix
  60377. */
  60378. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60379. /**
  60380. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60381. * @param other defines the second operand
  60382. * @param result defines the array where to store the multiplication
  60383. * @param offset defines the offset in the target array where to start storing values
  60384. * @returns the current matrix
  60385. */
  60386. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60387. /**
  60388. * Check equality between this matrix and a second one
  60389. * @param value defines the second matrix to compare
  60390. * @returns true is the current matrix and the given one values are strictly equal
  60391. */
  60392. equals(value: DeepImmutable<Matrix>): boolean;
  60393. /**
  60394. * Clone the current matrix
  60395. * @returns a new matrix from the current matrix
  60396. */
  60397. clone(): Matrix;
  60398. /**
  60399. * Returns the name of the current matrix class
  60400. * @returns the string "Matrix"
  60401. */
  60402. getClassName(): string;
  60403. /**
  60404. * Gets the hash code of the current matrix
  60405. * @returns the hash code
  60406. */
  60407. getHashCode(): number;
  60408. /**
  60409. * Decomposes the current Matrix into a translation, rotation and scaling components
  60410. * @param scale defines the scale vector3 given as a reference to update
  60411. * @param rotation defines the rotation quaternion given as a reference to update
  60412. * @param translation defines the translation vector3 given as a reference to update
  60413. * @returns true if operation was successful
  60414. */
  60415. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60416. /**
  60417. * Gets specific row of the matrix
  60418. * @param index defines the number of the row to get
  60419. * @returns the index-th row of the current matrix as a new Vector4
  60420. */
  60421. getRow(index: number): Nullable<Vector4>;
  60422. /**
  60423. * Sets the index-th row of the current matrix to the vector4 values
  60424. * @param index defines the number of the row to set
  60425. * @param row defines the target vector4
  60426. * @returns the updated current matrix
  60427. */
  60428. setRow(index: number, row: Vector4): Matrix;
  60429. /**
  60430. * Compute the transpose of the matrix
  60431. * @returns the new transposed matrix
  60432. */
  60433. transpose(): Matrix;
  60434. /**
  60435. * Compute the transpose of the matrix and store it in a given matrix
  60436. * @param result defines the target matrix
  60437. * @returns the current matrix
  60438. */
  60439. transposeToRef(result: Matrix): Matrix;
  60440. /**
  60441. * Sets the index-th row of the current matrix with the given 4 x float values
  60442. * @param index defines the row index
  60443. * @param x defines the x component to set
  60444. * @param y defines the y component to set
  60445. * @param z defines the z component to set
  60446. * @param w defines the w component to set
  60447. * @returns the updated current matrix
  60448. */
  60449. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60450. /**
  60451. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60452. * @param scale defines the scale factor
  60453. * @returns a new matrix
  60454. */
  60455. scale(scale: number): Matrix;
  60456. /**
  60457. * Scale the current matrix values by a factor to a given result matrix
  60458. * @param scale defines the scale factor
  60459. * @param result defines the matrix to store the result
  60460. * @returns the current matrix
  60461. */
  60462. scaleToRef(scale: number, result: Matrix): Matrix;
  60463. /**
  60464. * Scale the current matrix values by a factor and add the result to a given matrix
  60465. * @param scale defines the scale factor
  60466. * @param result defines the Matrix to store the result
  60467. * @returns the current matrix
  60468. */
  60469. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60470. /**
  60471. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60472. * @param ref matrix to store the result
  60473. */
  60474. toNormalMatrix(ref: Matrix): void;
  60475. /**
  60476. * Gets only rotation part of the current matrix
  60477. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60478. */
  60479. getRotationMatrix(): Matrix;
  60480. /**
  60481. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60482. * @param result defines the target matrix to store data to
  60483. * @returns the current matrix
  60484. */
  60485. getRotationMatrixToRef(result: Matrix): Matrix;
  60486. /**
  60487. * Toggles model matrix from being right handed to left handed in place and vice versa
  60488. */
  60489. toggleModelMatrixHandInPlace(): void;
  60490. /**
  60491. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60492. */
  60493. toggleProjectionMatrixHandInPlace(): void;
  60494. /**
  60495. * Creates a matrix from an array
  60496. * @param array defines the source array
  60497. * @param offset defines an offset in the source array
  60498. * @returns a new Matrix set from the starting index of the given array
  60499. */
  60500. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60501. /**
  60502. * Copy the content of an array into a given matrix
  60503. * @param array defines the source array
  60504. * @param offset defines an offset in the source array
  60505. * @param result defines the target matrix
  60506. */
  60507. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60508. /**
  60509. * Stores an array into a matrix after having multiplied each component by a given factor
  60510. * @param array defines the source array
  60511. * @param offset defines the offset in the source array
  60512. * @param scale defines the scaling factor
  60513. * @param result defines the target matrix
  60514. */
  60515. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60516. /**
  60517. * Gets an identity matrix that must not be updated
  60518. */
  60519. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60520. /**
  60521. * Stores a list of values (16) inside a given matrix
  60522. * @param initialM11 defines 1st value of 1st row
  60523. * @param initialM12 defines 2nd value of 1st row
  60524. * @param initialM13 defines 3rd value of 1st row
  60525. * @param initialM14 defines 4th value of 1st row
  60526. * @param initialM21 defines 1st value of 2nd row
  60527. * @param initialM22 defines 2nd value of 2nd row
  60528. * @param initialM23 defines 3rd value of 2nd row
  60529. * @param initialM24 defines 4th value of 2nd row
  60530. * @param initialM31 defines 1st value of 3rd row
  60531. * @param initialM32 defines 2nd value of 3rd row
  60532. * @param initialM33 defines 3rd value of 3rd row
  60533. * @param initialM34 defines 4th value of 3rd row
  60534. * @param initialM41 defines 1st value of 4th row
  60535. * @param initialM42 defines 2nd value of 4th row
  60536. * @param initialM43 defines 3rd value of 4th row
  60537. * @param initialM44 defines 4th value of 4th row
  60538. * @param result defines the target matrix
  60539. */
  60540. 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;
  60541. /**
  60542. * Creates new matrix from a list of values (16)
  60543. * @param initialM11 defines 1st value of 1st row
  60544. * @param initialM12 defines 2nd value of 1st row
  60545. * @param initialM13 defines 3rd value of 1st row
  60546. * @param initialM14 defines 4th value of 1st row
  60547. * @param initialM21 defines 1st value of 2nd row
  60548. * @param initialM22 defines 2nd value of 2nd row
  60549. * @param initialM23 defines 3rd value of 2nd row
  60550. * @param initialM24 defines 4th value of 2nd row
  60551. * @param initialM31 defines 1st value of 3rd row
  60552. * @param initialM32 defines 2nd value of 3rd row
  60553. * @param initialM33 defines 3rd value of 3rd row
  60554. * @param initialM34 defines 4th value of 3rd row
  60555. * @param initialM41 defines 1st value of 4th row
  60556. * @param initialM42 defines 2nd value of 4th row
  60557. * @param initialM43 defines 3rd value of 4th row
  60558. * @param initialM44 defines 4th value of 4th row
  60559. * @returns the new matrix
  60560. */
  60561. 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;
  60562. /**
  60563. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60564. * @param scale defines the scale vector3
  60565. * @param rotation defines the rotation quaternion
  60566. * @param translation defines the translation vector3
  60567. * @returns a new matrix
  60568. */
  60569. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60570. /**
  60571. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60572. * @param scale defines the scale vector3
  60573. * @param rotation defines the rotation quaternion
  60574. * @param translation defines the translation vector3
  60575. * @param result defines the target matrix
  60576. */
  60577. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60578. /**
  60579. * Creates a new identity matrix
  60580. * @returns a new identity matrix
  60581. */
  60582. static Identity(): Matrix;
  60583. /**
  60584. * Creates a new identity matrix and stores the result in a given matrix
  60585. * @param result defines the target matrix
  60586. */
  60587. static IdentityToRef(result: Matrix): void;
  60588. /**
  60589. * Creates a new zero matrix
  60590. * @returns a new zero matrix
  60591. */
  60592. static Zero(): Matrix;
  60593. /**
  60594. * Creates a new rotation matrix for "angle" radians around the X axis
  60595. * @param angle defines the angle (in radians) to use
  60596. * @return the new matrix
  60597. */
  60598. static RotationX(angle: number): Matrix;
  60599. /**
  60600. * Creates a new matrix as the invert of a given matrix
  60601. * @param source defines the source matrix
  60602. * @returns the new matrix
  60603. */
  60604. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60605. /**
  60606. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60607. * @param angle defines the angle (in radians) to use
  60608. * @param result defines the target matrix
  60609. */
  60610. static RotationXToRef(angle: number, result: Matrix): void;
  60611. /**
  60612. * Creates a new rotation matrix for "angle" radians around the Y axis
  60613. * @param angle defines the angle (in radians) to use
  60614. * @return the new matrix
  60615. */
  60616. static RotationY(angle: number): Matrix;
  60617. /**
  60618. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60619. * @param angle defines the angle (in radians) to use
  60620. * @param result defines the target matrix
  60621. */
  60622. static RotationYToRef(angle: number, result: Matrix): void;
  60623. /**
  60624. * Creates a new rotation matrix for "angle" radians around the Z axis
  60625. * @param angle defines the angle (in radians) to use
  60626. * @return the new matrix
  60627. */
  60628. static RotationZ(angle: number): Matrix;
  60629. /**
  60630. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60631. * @param angle defines the angle (in radians) to use
  60632. * @param result defines the target matrix
  60633. */
  60634. static RotationZToRef(angle: number, result: Matrix): void;
  60635. /**
  60636. * Creates a new rotation matrix for "angle" radians around the given axis
  60637. * @param axis defines the axis to use
  60638. * @param angle defines the angle (in radians) to use
  60639. * @return the new matrix
  60640. */
  60641. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60642. /**
  60643. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60644. * @param axis defines the axis to use
  60645. * @param angle defines the angle (in radians) to use
  60646. * @param result defines the target matrix
  60647. */
  60648. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60649. /**
  60650. * Creates a rotation matrix
  60651. * @param yaw defines the yaw angle in radians (Y axis)
  60652. * @param pitch defines the pitch angle in radians (X axis)
  60653. * @param roll defines the roll angle in radians (X axis)
  60654. * @returns the new rotation matrix
  60655. */
  60656. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60657. /**
  60658. * Creates a rotation matrix and stores it in a given matrix
  60659. * @param yaw defines the yaw angle in radians (Y axis)
  60660. * @param pitch defines the pitch angle in radians (X axis)
  60661. * @param roll defines the roll angle in radians (X axis)
  60662. * @param result defines the target matrix
  60663. */
  60664. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60665. /**
  60666. * Creates a scaling matrix
  60667. * @param x defines the scale factor on X axis
  60668. * @param y defines the scale factor on Y axis
  60669. * @param z defines the scale factor on Z axis
  60670. * @returns the new matrix
  60671. */
  60672. static Scaling(x: number, y: number, z: number): Matrix;
  60673. /**
  60674. * Creates a scaling matrix and stores it in a given matrix
  60675. * @param x defines the scale factor on X axis
  60676. * @param y defines the scale factor on Y axis
  60677. * @param z defines the scale factor on Z axis
  60678. * @param result defines the target matrix
  60679. */
  60680. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60681. /**
  60682. * Creates a translation matrix
  60683. * @param x defines the translation on X axis
  60684. * @param y defines the translation on Y axis
  60685. * @param z defines the translationon Z axis
  60686. * @returns the new matrix
  60687. */
  60688. static Translation(x: number, y: number, z: number): Matrix;
  60689. /**
  60690. * Creates a translation matrix and stores it in a given matrix
  60691. * @param x defines the translation on X axis
  60692. * @param y defines the translation on Y axis
  60693. * @param z defines the translationon Z axis
  60694. * @param result defines the target matrix
  60695. */
  60696. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60697. /**
  60698. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60699. * @param startValue defines the start value
  60700. * @param endValue defines the end value
  60701. * @param gradient defines the gradient factor
  60702. * @returns the new matrix
  60703. */
  60704. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60705. /**
  60706. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60707. * @param startValue defines the start value
  60708. * @param endValue defines the end value
  60709. * @param gradient defines the gradient factor
  60710. * @param result defines the Matrix object where to store data
  60711. */
  60712. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60713. /**
  60714. * Builds a new matrix whose values are computed by:
  60715. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60716. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60717. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60718. * @param startValue defines the first matrix
  60719. * @param endValue defines the second matrix
  60720. * @param gradient defines the gradient between the two matrices
  60721. * @returns the new matrix
  60722. */
  60723. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60724. /**
  60725. * Update a matrix to values which are computed by:
  60726. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60727. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60728. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60729. * @param startValue defines the first matrix
  60730. * @param endValue defines the second matrix
  60731. * @param gradient defines the gradient between the two matrices
  60732. * @param result defines the target matrix
  60733. */
  60734. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60735. /**
  60736. * 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"
  60737. * This function works in left handed mode
  60738. * @param eye defines the final position of the entity
  60739. * @param target defines where the entity should look at
  60740. * @param up defines the up vector for the entity
  60741. * @returns the new matrix
  60742. */
  60743. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60744. /**
  60745. * 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".
  60746. * This function works in left handed mode
  60747. * @param eye defines the final position of the entity
  60748. * @param target defines where the entity should look at
  60749. * @param up defines the up vector for the entity
  60750. * @param result defines the target matrix
  60751. */
  60752. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60753. /**
  60754. * 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"
  60755. * This function works in right handed mode
  60756. * @param eye defines the final position of the entity
  60757. * @param target defines where the entity should look at
  60758. * @param up defines the up vector for the entity
  60759. * @returns the new matrix
  60760. */
  60761. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60762. /**
  60763. * 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".
  60764. * This function works in right handed mode
  60765. * @param eye defines the final position of the entity
  60766. * @param target defines where the entity should look at
  60767. * @param up defines the up vector for the entity
  60768. * @param result defines the target matrix
  60769. */
  60770. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60771. /**
  60772. * Create a left-handed orthographic projection matrix
  60773. * @param width defines the viewport width
  60774. * @param height defines the viewport height
  60775. * @param znear defines the near clip plane
  60776. * @param zfar defines the far clip plane
  60777. * @returns a new matrix as a left-handed orthographic projection matrix
  60778. */
  60779. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60780. /**
  60781. * Store a left-handed orthographic projection to a given matrix
  60782. * @param width defines the viewport width
  60783. * @param height defines the viewport height
  60784. * @param znear defines the near clip plane
  60785. * @param zfar defines the far clip plane
  60786. * @param result defines the target matrix
  60787. */
  60788. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  60789. /**
  60790. * Create a left-handed orthographic projection matrix
  60791. * @param left defines the viewport left coordinate
  60792. * @param right defines the viewport right coordinate
  60793. * @param bottom defines the viewport bottom coordinate
  60794. * @param top defines the viewport top coordinate
  60795. * @param znear defines the near clip plane
  60796. * @param zfar defines the far clip plane
  60797. * @returns a new matrix as a left-handed orthographic projection matrix
  60798. */
  60799. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60800. /**
  60801. * Stores a left-handed orthographic projection into a given matrix
  60802. * @param left defines the viewport left coordinate
  60803. * @param right defines the viewport right coordinate
  60804. * @param bottom defines the viewport bottom coordinate
  60805. * @param top defines the viewport top coordinate
  60806. * @param znear defines the near clip plane
  60807. * @param zfar defines the far clip plane
  60808. * @param result defines the target matrix
  60809. */
  60810. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60811. /**
  60812. * Creates a right-handed orthographic projection matrix
  60813. * @param left defines the viewport left coordinate
  60814. * @param right defines the viewport right coordinate
  60815. * @param bottom defines the viewport bottom coordinate
  60816. * @param top defines the viewport top coordinate
  60817. * @param znear defines the near clip plane
  60818. * @param zfar defines the far clip plane
  60819. * @returns a new matrix as a right-handed orthographic projection matrix
  60820. */
  60821. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60822. /**
  60823. * Stores a right-handed orthographic projection into a given matrix
  60824. * @param left defines the viewport left coordinate
  60825. * @param right defines the viewport right coordinate
  60826. * @param bottom defines the viewport bottom coordinate
  60827. * @param top defines the viewport top coordinate
  60828. * @param znear defines the near clip plane
  60829. * @param zfar defines the far clip plane
  60830. * @param result defines the target matrix
  60831. */
  60832. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60833. /**
  60834. * Creates a left-handed perspective projection matrix
  60835. * @param width defines the viewport width
  60836. * @param height defines the viewport height
  60837. * @param znear defines the near clip plane
  60838. * @param zfar defines the far clip plane
  60839. * @returns a new matrix as a left-handed perspective projection matrix
  60840. */
  60841. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60842. /**
  60843. * Creates a left-handed perspective projection matrix
  60844. * @param fov defines the horizontal field of view
  60845. * @param aspect defines the aspect ratio
  60846. * @param znear defines the near clip plane
  60847. * @param zfar defines the far clip plane
  60848. * @returns a new matrix as a left-handed perspective projection matrix
  60849. */
  60850. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60851. /**
  60852. * Stores a left-handed perspective projection into a given matrix
  60853. * @param fov defines the horizontal field of view
  60854. * @param aspect defines the aspect ratio
  60855. * @param znear defines the near clip plane
  60856. * @param zfar defines the far clip plane
  60857. * @param result defines the target matrix
  60858. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60859. */
  60860. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60861. /**
  60862. * Creates a right-handed perspective projection matrix
  60863. * @param fov defines the horizontal field of view
  60864. * @param aspect defines the aspect ratio
  60865. * @param znear defines the near clip plane
  60866. * @param zfar defines the far clip plane
  60867. * @returns a new matrix as a right-handed perspective projection matrix
  60868. */
  60869. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60870. /**
  60871. * Stores a right-handed perspective projection into a given matrix
  60872. * @param fov defines the horizontal field of view
  60873. * @param aspect defines the aspect ratio
  60874. * @param znear defines the near clip plane
  60875. * @param zfar defines the far clip plane
  60876. * @param result defines the target matrix
  60877. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60878. */
  60879. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60880. /**
  60881. * Stores a perspective projection for WebVR info a given matrix
  60882. * @param fov defines the field of view
  60883. * @param znear defines the near clip plane
  60884. * @param zfar defines the far clip plane
  60885. * @param result defines the target matrix
  60886. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  60887. */
  60888. static PerspectiveFovWebVRToRef(fov: {
  60889. upDegrees: number;
  60890. downDegrees: number;
  60891. leftDegrees: number;
  60892. rightDegrees: number;
  60893. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  60894. /**
  60895. * Computes a complete transformation matrix
  60896. * @param viewport defines the viewport to use
  60897. * @param world defines the world matrix
  60898. * @param view defines the view matrix
  60899. * @param projection defines the projection matrix
  60900. * @param zmin defines the near clip plane
  60901. * @param zmax defines the far clip plane
  60902. * @returns the transformation matrix
  60903. */
  60904. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  60905. /**
  60906. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  60907. * @param matrix defines the matrix to use
  60908. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  60909. */
  60910. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  60911. /**
  60912. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  60913. * @param matrix defines the matrix to use
  60914. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  60915. */
  60916. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  60917. /**
  60918. * Compute the transpose of a given matrix
  60919. * @param matrix defines the matrix to transpose
  60920. * @returns the new matrix
  60921. */
  60922. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  60923. /**
  60924. * Compute the transpose of a matrix and store it in a target matrix
  60925. * @param matrix defines the matrix to transpose
  60926. * @param result defines the target matrix
  60927. */
  60928. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  60929. /**
  60930. * Computes a reflection matrix from a plane
  60931. * @param plane defines the reflection plane
  60932. * @returns a new matrix
  60933. */
  60934. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  60935. /**
  60936. * Computes a reflection matrix from a plane
  60937. * @param plane defines the reflection plane
  60938. * @param result defines the target matrix
  60939. */
  60940. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  60941. /**
  60942. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  60943. * @param xaxis defines the value of the 1st axis
  60944. * @param yaxis defines the value of the 2nd axis
  60945. * @param zaxis defines the value of the 3rd axis
  60946. * @param result defines the target matrix
  60947. */
  60948. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  60949. /**
  60950. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  60951. * @param quat defines the quaternion to use
  60952. * @param result defines the target matrix
  60953. */
  60954. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  60955. }
  60956. /**
  60957. * Represens a plane by the equation ax + by + cz + d = 0
  60958. */
  60959. export class Plane {
  60960. /**
  60961. * Normal of the plane (a,b,c)
  60962. */
  60963. normal: Vector3;
  60964. /**
  60965. * d component of the plane
  60966. */
  60967. d: number;
  60968. /**
  60969. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  60970. * @param a a component of the plane
  60971. * @param b b component of the plane
  60972. * @param c c component of the plane
  60973. * @param d d component of the plane
  60974. */
  60975. constructor(a: number, b: number, c: number, d: number);
  60976. /**
  60977. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  60978. */
  60979. asArray(): number[];
  60980. /**
  60981. * @returns a new plane copied from the current Plane.
  60982. */
  60983. clone(): Plane;
  60984. /**
  60985. * @returns the string "Plane".
  60986. */
  60987. getClassName(): string;
  60988. /**
  60989. * @returns the Plane hash code.
  60990. */
  60991. getHashCode(): number;
  60992. /**
  60993. * Normalize the current Plane in place.
  60994. * @returns the updated Plane.
  60995. */
  60996. normalize(): Plane;
  60997. /**
  60998. * Applies a transformation the plane and returns the result
  60999. * @param transformation the transformation matrix to be applied to the plane
  61000. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61001. */
  61002. transform(transformation: DeepImmutable<Matrix>): Plane;
  61003. /**
  61004. * Calcualtte the dot product between the point and the plane normal
  61005. * @param point point to calculate the dot product with
  61006. * @returns the dot product (float) of the point coordinates and the plane normal.
  61007. */
  61008. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61009. /**
  61010. * Updates the current Plane from the plane defined by the three given points.
  61011. * @param point1 one of the points used to contruct the plane
  61012. * @param point2 one of the points used to contruct the plane
  61013. * @param point3 one of the points used to contruct the plane
  61014. * @returns the updated Plane.
  61015. */
  61016. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61017. /**
  61018. * Checks if the plane is facing a given direction
  61019. * @param direction the direction to check if the plane is facing
  61020. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61021. * @returns True is the vector "direction" is the same side than the plane normal.
  61022. */
  61023. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61024. /**
  61025. * Calculates the distance to a point
  61026. * @param point point to calculate distance to
  61027. * @returns the signed distance (float) from the given point to the Plane.
  61028. */
  61029. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61030. /**
  61031. * Creates a plane from an array
  61032. * @param array the array to create a plane from
  61033. * @returns a new Plane from the given array.
  61034. */
  61035. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61036. /**
  61037. * Creates a plane from three points
  61038. * @param point1 point used to create the plane
  61039. * @param point2 point used to create the plane
  61040. * @param point3 point used to create the plane
  61041. * @returns a new Plane defined by the three given points.
  61042. */
  61043. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61044. /**
  61045. * Creates a plane from an origin point and a normal
  61046. * @param origin origin of the plane to be constructed
  61047. * @param normal normal of the plane to be constructed
  61048. * @returns a new Plane the normal vector to this plane at the given origin point.
  61049. * Note : the vector "normal" is updated because normalized.
  61050. */
  61051. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61052. /**
  61053. * Calculates the distance from a plane and a point
  61054. * @param origin origin of the plane to be constructed
  61055. * @param normal normal of the plane to be constructed
  61056. * @param point point to calculate distance to
  61057. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61058. */
  61059. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61060. }
  61061. /**
  61062. * Class used to represent a viewport on screen
  61063. */
  61064. export class Viewport {
  61065. /** viewport left coordinate */
  61066. x: number;
  61067. /** viewport top coordinate */
  61068. y: number;
  61069. /**viewport width */
  61070. width: number;
  61071. /** viewport height */
  61072. height: number;
  61073. /**
  61074. * Creates a Viewport object located at (x, y) and sized (width, height)
  61075. * @param x defines viewport left coordinate
  61076. * @param y defines viewport top coordinate
  61077. * @param width defines the viewport width
  61078. * @param height defines the viewport height
  61079. */
  61080. constructor(
  61081. /** viewport left coordinate */
  61082. x: number,
  61083. /** viewport top coordinate */
  61084. y: number,
  61085. /**viewport width */
  61086. width: number,
  61087. /** viewport height */
  61088. height: number);
  61089. /**
  61090. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61091. * @param renderWidth defines the rendering width
  61092. * @param renderHeight defines the rendering height
  61093. * @returns a new Viewport
  61094. */
  61095. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61096. /**
  61097. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61098. * @param renderWidth defines the rendering width
  61099. * @param renderHeight defines the rendering height
  61100. * @param ref defines the target viewport
  61101. * @returns the current viewport
  61102. */
  61103. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61104. /**
  61105. * Returns a new Viewport copied from the current one
  61106. * @returns a new Viewport
  61107. */
  61108. clone(): Viewport;
  61109. }
  61110. /**
  61111. * Reprasents a camera frustum
  61112. */
  61113. export class Frustum {
  61114. /**
  61115. * Gets the planes representing the frustum
  61116. * @param transform matrix to be applied to the returned planes
  61117. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61118. */
  61119. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61120. /**
  61121. * Gets the near frustum plane transformed by the transform matrix
  61122. * @param transform transformation matrix to be applied to the resulting frustum plane
  61123. * @param frustumPlane the resuling frustum plane
  61124. */
  61125. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61126. /**
  61127. * Gets the far frustum plane transformed by the transform matrix
  61128. * @param transform transformation matrix to be applied to the resulting frustum plane
  61129. * @param frustumPlane the resuling frustum plane
  61130. */
  61131. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61132. /**
  61133. * Gets the left frustum plane transformed by the transform matrix
  61134. * @param transform transformation matrix to be applied to the resulting frustum plane
  61135. * @param frustumPlane the resuling frustum plane
  61136. */
  61137. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61138. /**
  61139. * Gets the right frustum plane transformed by the transform matrix
  61140. * @param transform transformation matrix to be applied to the resulting frustum plane
  61141. * @param frustumPlane the resuling frustum plane
  61142. */
  61143. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61144. /**
  61145. * Gets the top frustum plane transformed by the transform matrix
  61146. * @param transform transformation matrix to be applied to the resulting frustum plane
  61147. * @param frustumPlane the resuling frustum plane
  61148. */
  61149. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61150. /**
  61151. * Gets the bottom frustum plane transformed by the transform matrix
  61152. * @param transform transformation matrix to be applied to the resulting frustum plane
  61153. * @param frustumPlane the resuling frustum plane
  61154. */
  61155. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61156. /**
  61157. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61158. * @param transform transformation matrix to be applied to the resulting frustum planes
  61159. * @param frustumPlanes the resuling frustum planes
  61160. */
  61161. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61162. }
  61163. /** Defines supported spaces */
  61164. export enum Space {
  61165. /** Local (object) space */
  61166. LOCAL = 0,
  61167. /** World space */
  61168. WORLD = 1,
  61169. /** Bone space */
  61170. BONE = 2
  61171. }
  61172. /** Defines the 3 main axes */
  61173. export class Axis {
  61174. /** X axis */
  61175. static X: Vector3;
  61176. /** Y axis */
  61177. static Y: Vector3;
  61178. /** Z axis */
  61179. static Z: Vector3;
  61180. }
  61181. /** Class used to represent a Bezier curve */
  61182. export class BezierCurve {
  61183. /**
  61184. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61185. * @param t defines the time
  61186. * @param x1 defines the left coordinate on X axis
  61187. * @param y1 defines the left coordinate on Y axis
  61188. * @param x2 defines the right coordinate on X axis
  61189. * @param y2 defines the right coordinate on Y axis
  61190. * @returns the interpolated value
  61191. */
  61192. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61193. }
  61194. /**
  61195. * Defines potential orientation for back face culling
  61196. */
  61197. export enum Orientation {
  61198. /**
  61199. * Clockwise
  61200. */
  61201. CW = 0,
  61202. /** Counter clockwise */
  61203. CCW = 1
  61204. }
  61205. /**
  61206. * Defines angle representation
  61207. */
  61208. export class Angle {
  61209. private _radians;
  61210. /**
  61211. * Creates an Angle object of "radians" radians (float).
  61212. * @param radians the angle in radians
  61213. */
  61214. constructor(radians: number);
  61215. /**
  61216. * Get value in degrees
  61217. * @returns the Angle value in degrees (float)
  61218. */
  61219. degrees(): number;
  61220. /**
  61221. * Get value in radians
  61222. * @returns the Angle value in radians (float)
  61223. */
  61224. radians(): number;
  61225. /**
  61226. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61227. * @param a defines first vector
  61228. * @param b defines second vector
  61229. * @returns a new Angle
  61230. */
  61231. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61232. /**
  61233. * Gets a new Angle object from the given float in radians
  61234. * @param radians defines the angle value in radians
  61235. * @returns a new Angle
  61236. */
  61237. static FromRadians(radians: number): Angle;
  61238. /**
  61239. * Gets a new Angle object from the given float in degrees
  61240. * @param degrees defines the angle value in degrees
  61241. * @returns a new Angle
  61242. */
  61243. static FromDegrees(degrees: number): Angle;
  61244. }
  61245. /**
  61246. * This represents an arc in a 2d space.
  61247. */
  61248. export class Arc2 {
  61249. /** Defines the start point of the arc */
  61250. startPoint: Vector2;
  61251. /** Defines the mid point of the arc */
  61252. midPoint: Vector2;
  61253. /** Defines the end point of the arc */
  61254. endPoint: Vector2;
  61255. /**
  61256. * Defines the center point of the arc.
  61257. */
  61258. centerPoint: Vector2;
  61259. /**
  61260. * Defines the radius of the arc.
  61261. */
  61262. radius: number;
  61263. /**
  61264. * Defines the angle of the arc (from mid point to end point).
  61265. */
  61266. angle: Angle;
  61267. /**
  61268. * Defines the start angle of the arc (from start point to middle point).
  61269. */
  61270. startAngle: Angle;
  61271. /**
  61272. * Defines the orientation of the arc (clock wise/counter clock wise).
  61273. */
  61274. orientation: Orientation;
  61275. /**
  61276. * Creates an Arc object from the three given points : start, middle and end.
  61277. * @param startPoint Defines the start point of the arc
  61278. * @param midPoint Defines the midlle point of the arc
  61279. * @param endPoint Defines the end point of the arc
  61280. */
  61281. constructor(
  61282. /** Defines the start point of the arc */
  61283. startPoint: Vector2,
  61284. /** Defines the mid point of the arc */
  61285. midPoint: Vector2,
  61286. /** Defines the end point of the arc */
  61287. endPoint: Vector2);
  61288. }
  61289. /**
  61290. * Represents a 2D path made up of multiple 2D points
  61291. */
  61292. export class Path2 {
  61293. private _points;
  61294. private _length;
  61295. /**
  61296. * If the path start and end point are the same
  61297. */
  61298. closed: boolean;
  61299. /**
  61300. * Creates a Path2 object from the starting 2D coordinates x and y.
  61301. * @param x the starting points x value
  61302. * @param y the starting points y value
  61303. */
  61304. constructor(x: number, y: number);
  61305. /**
  61306. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61307. * @param x the added points x value
  61308. * @param y the added points y value
  61309. * @returns the updated Path2.
  61310. */
  61311. addLineTo(x: number, y: number): Path2;
  61312. /**
  61313. * 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.
  61314. * @param midX middle point x value
  61315. * @param midY middle point y value
  61316. * @param endX end point x value
  61317. * @param endY end point y value
  61318. * @param numberOfSegments (default: 36)
  61319. * @returns the updated Path2.
  61320. */
  61321. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61322. /**
  61323. * Closes the Path2.
  61324. * @returns the Path2.
  61325. */
  61326. close(): Path2;
  61327. /**
  61328. * Gets the sum of the distance between each sequential point in the path
  61329. * @returns the Path2 total length (float).
  61330. */
  61331. length(): number;
  61332. /**
  61333. * Gets the points which construct the path
  61334. * @returns the Path2 internal array of points.
  61335. */
  61336. getPoints(): Vector2[];
  61337. /**
  61338. * Retreives the point at the distance aways from the starting point
  61339. * @param normalizedLengthPosition the length along the path to retreive the point from
  61340. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61341. */
  61342. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61343. /**
  61344. * Creates a new path starting from an x and y position
  61345. * @param x starting x value
  61346. * @param y starting y value
  61347. * @returns a new Path2 starting at the coordinates (x, y).
  61348. */
  61349. static StartingAt(x: number, y: number): Path2;
  61350. }
  61351. /**
  61352. * Represents a 3D path made up of multiple 3D points
  61353. */
  61354. export class Path3D {
  61355. /**
  61356. * an array of Vector3, the curve axis of the Path3D
  61357. */
  61358. path: Vector3[];
  61359. private _curve;
  61360. private _distances;
  61361. private _tangents;
  61362. private _normals;
  61363. private _binormals;
  61364. private _raw;
  61365. /**
  61366. * new Path3D(path, normal, raw)
  61367. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61368. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61369. * @param path an array of Vector3, the curve axis of the Path3D
  61370. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61371. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61372. */
  61373. constructor(
  61374. /**
  61375. * an array of Vector3, the curve axis of the Path3D
  61376. */
  61377. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61378. /**
  61379. * Returns the Path3D array of successive Vector3 designing its curve.
  61380. * @returns the Path3D array of successive Vector3 designing its curve.
  61381. */
  61382. getCurve(): Vector3[];
  61383. /**
  61384. * Returns an array populated with tangent vectors on each Path3D curve point.
  61385. * @returns an array populated with tangent vectors on each Path3D curve point.
  61386. */
  61387. getTangents(): Vector3[];
  61388. /**
  61389. * Returns an array populated with normal vectors on each Path3D curve point.
  61390. * @returns an array populated with normal vectors on each Path3D curve point.
  61391. */
  61392. getNormals(): Vector3[];
  61393. /**
  61394. * Returns an array populated with binormal vectors on each Path3D curve point.
  61395. * @returns an array populated with binormal vectors on each Path3D curve point.
  61396. */
  61397. getBinormals(): Vector3[];
  61398. /**
  61399. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61400. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61401. */
  61402. getDistances(): number[];
  61403. /**
  61404. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61405. * @param path path which all values are copied into the curves points
  61406. * @param firstNormal which should be projected onto the curve
  61407. * @returns the same object updated.
  61408. */
  61409. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61410. private _compute;
  61411. private _getFirstNonNullVector;
  61412. private _getLastNonNullVector;
  61413. private _normalVector;
  61414. }
  61415. /**
  61416. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61417. * A Curve3 is designed from a series of successive Vector3.
  61418. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61419. */
  61420. export class Curve3 {
  61421. private _points;
  61422. private _length;
  61423. /**
  61424. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61425. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61426. * @param v1 (Vector3) the control point
  61427. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61428. * @param nbPoints (integer) the wanted number of points in the curve
  61429. * @returns the created Curve3
  61430. */
  61431. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61432. /**
  61433. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61434. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61435. * @param v1 (Vector3) the first control point
  61436. * @param v2 (Vector3) the second control point
  61437. * @param v3 (Vector3) the end point of the Cubic Bezier
  61438. * @param nbPoints (integer) the wanted number of points in the curve
  61439. * @returns the created Curve3
  61440. */
  61441. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61442. /**
  61443. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61444. * @param p1 (Vector3) the origin point of the Hermite Spline
  61445. * @param t1 (Vector3) the tangent vector at the origin point
  61446. * @param p2 (Vector3) the end point of the Hermite Spline
  61447. * @param t2 (Vector3) the tangent vector at the end point
  61448. * @param nbPoints (integer) the wanted number of points in the curve
  61449. * @returns the created Curve3
  61450. */
  61451. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61452. /**
  61453. * Returns a Curve3 object along a CatmullRom Spline curve :
  61454. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61455. * @param nbPoints (integer) the wanted number of points between each curve control points
  61456. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61457. * @returns the created Curve3
  61458. */
  61459. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61460. /**
  61461. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61462. * A Curve3 is designed from a series of successive Vector3.
  61463. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61464. * @param points points which make up the curve
  61465. */
  61466. constructor(points: Vector3[]);
  61467. /**
  61468. * @returns the Curve3 stored array of successive Vector3
  61469. */
  61470. getPoints(): Vector3[];
  61471. /**
  61472. * @returns the computed length (float) of the curve.
  61473. */
  61474. length(): number;
  61475. /**
  61476. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61477. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61478. * curveA and curveB keep unchanged.
  61479. * @param curve the curve to continue from this curve
  61480. * @returns the newly constructed curve
  61481. */
  61482. continue(curve: DeepImmutable<Curve3>): Curve3;
  61483. private _computeLength;
  61484. }
  61485. /**
  61486. * Contains position and normal vectors for a vertex
  61487. */
  61488. export class PositionNormalVertex {
  61489. /** the position of the vertex (defaut: 0,0,0) */
  61490. position: Vector3;
  61491. /** the normal of the vertex (defaut: 0,1,0) */
  61492. normal: Vector3;
  61493. /**
  61494. * Creates a PositionNormalVertex
  61495. * @param position the position of the vertex (defaut: 0,0,0)
  61496. * @param normal the normal of the vertex (defaut: 0,1,0)
  61497. */
  61498. constructor(
  61499. /** the position of the vertex (defaut: 0,0,0) */
  61500. position?: Vector3,
  61501. /** the normal of the vertex (defaut: 0,1,0) */
  61502. normal?: Vector3);
  61503. /**
  61504. * Clones the PositionNormalVertex
  61505. * @returns the cloned PositionNormalVertex
  61506. */
  61507. clone(): PositionNormalVertex;
  61508. }
  61509. /**
  61510. * Contains position, normal and uv vectors for a vertex
  61511. */
  61512. export class PositionNormalTextureVertex {
  61513. /** the position of the vertex (defaut: 0,0,0) */
  61514. position: Vector3;
  61515. /** the normal of the vertex (defaut: 0,1,0) */
  61516. normal: Vector3;
  61517. /** the uv of the vertex (default: 0,0) */
  61518. uv: Vector2;
  61519. /**
  61520. * Creates a PositionNormalTextureVertex
  61521. * @param position the position of the vertex (defaut: 0,0,0)
  61522. * @param normal the normal of the vertex (defaut: 0,1,0)
  61523. * @param uv the uv of the vertex (default: 0,0)
  61524. */
  61525. constructor(
  61526. /** the position of the vertex (defaut: 0,0,0) */
  61527. position?: Vector3,
  61528. /** the normal of the vertex (defaut: 0,1,0) */
  61529. normal?: Vector3,
  61530. /** the uv of the vertex (default: 0,0) */
  61531. uv?: Vector2);
  61532. /**
  61533. * Clones the PositionNormalTextureVertex
  61534. * @returns the cloned PositionNormalTextureVertex
  61535. */
  61536. clone(): PositionNormalTextureVertex;
  61537. }
  61538. /**
  61539. * @hidden
  61540. */
  61541. export class Tmp {
  61542. static Color3: Color3[];
  61543. static Color4: Color4[];
  61544. static Vector2: Vector2[];
  61545. static Vector3: Vector3[];
  61546. static Vector4: Vector4[];
  61547. static Quaternion: Quaternion[];
  61548. static Matrix: Matrix[];
  61549. }
  61550. }
  61551. declare module BABYLON {
  61552. /**
  61553. * Class used to enable access to offline support
  61554. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61555. */
  61556. export interface IOfflineProvider {
  61557. /**
  61558. * Gets a boolean indicating if scene must be saved in the database
  61559. */
  61560. enableSceneOffline: boolean;
  61561. /**
  61562. * Gets a boolean indicating if textures must be saved in the database
  61563. */
  61564. enableTexturesOffline: boolean;
  61565. /**
  61566. * Open the offline support and make it available
  61567. * @param successCallback defines the callback to call on success
  61568. * @param errorCallback defines the callback to call on error
  61569. */
  61570. open(successCallback: () => void, errorCallback: () => void): void;
  61571. /**
  61572. * Loads an image from the offline support
  61573. * @param url defines the url to load from
  61574. * @param image defines the target DOM image
  61575. */
  61576. loadImage(url: string, image: HTMLImageElement): void;
  61577. /**
  61578. * Loads a file from offline support
  61579. * @param url defines the URL to load from
  61580. * @param sceneLoaded defines a callback to call on success
  61581. * @param progressCallBack defines a callback to call when progress changed
  61582. * @param errorCallback defines a callback to call on error
  61583. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61584. */
  61585. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61586. }
  61587. }
  61588. declare module BABYLON {
  61589. /**
  61590. * A class serves as a medium between the observable and its observers
  61591. */
  61592. export class EventState {
  61593. /**
  61594. * Create a new EventState
  61595. * @param mask defines the mask associated with this state
  61596. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61597. * @param target defines the original target of the state
  61598. * @param currentTarget defines the current target of the state
  61599. */
  61600. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61601. /**
  61602. * Initialize the current event state
  61603. * @param mask defines the mask associated with this state
  61604. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61605. * @param target defines the original target of the state
  61606. * @param currentTarget defines the current target of the state
  61607. * @returns the current event state
  61608. */
  61609. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61610. /**
  61611. * An Observer can set this property to true to prevent subsequent observers of being notified
  61612. */
  61613. skipNextObservers: boolean;
  61614. /**
  61615. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61616. */
  61617. mask: number;
  61618. /**
  61619. * The object that originally notified the event
  61620. */
  61621. target?: any;
  61622. /**
  61623. * The current object in the bubbling phase
  61624. */
  61625. currentTarget?: any;
  61626. /**
  61627. * This will be populated with the return value of the last function that was executed.
  61628. * If it is the first function in the callback chain it will be the event data.
  61629. */
  61630. lastReturnValue?: any;
  61631. }
  61632. /**
  61633. * Represent an Observer registered to a given Observable object.
  61634. */
  61635. export class Observer<T> {
  61636. /**
  61637. * Defines the callback to call when the observer is notified
  61638. */
  61639. callback: (eventData: T, eventState: EventState) => void;
  61640. /**
  61641. * Defines the mask of the observer (used to filter notifications)
  61642. */
  61643. mask: number;
  61644. /**
  61645. * Defines the current scope used to restore the JS context
  61646. */
  61647. scope: any;
  61648. /** @hidden */
  61649. _willBeUnregistered: boolean;
  61650. /**
  61651. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61652. */
  61653. unregisterOnNextCall: boolean;
  61654. /**
  61655. * Creates a new observer
  61656. * @param callback defines the callback to call when the observer is notified
  61657. * @param mask defines the mask of the observer (used to filter notifications)
  61658. * @param scope defines the current scope used to restore the JS context
  61659. */
  61660. constructor(
  61661. /**
  61662. * Defines the callback to call when the observer is notified
  61663. */
  61664. callback: (eventData: T, eventState: EventState) => void,
  61665. /**
  61666. * Defines the mask of the observer (used to filter notifications)
  61667. */
  61668. mask: number,
  61669. /**
  61670. * Defines the current scope used to restore the JS context
  61671. */
  61672. scope?: any);
  61673. }
  61674. /**
  61675. * Represent a list of observers registered to multiple Observables object.
  61676. */
  61677. export class MultiObserver<T> {
  61678. private _observers;
  61679. private _observables;
  61680. /**
  61681. * Release associated resources
  61682. */
  61683. dispose(): void;
  61684. /**
  61685. * Raise a callback when one of the observable will notify
  61686. * @param observables defines a list of observables to watch
  61687. * @param callback defines the callback to call on notification
  61688. * @param mask defines the mask used to filter notifications
  61689. * @param scope defines the current scope used to restore the JS context
  61690. * @returns the new MultiObserver
  61691. */
  61692. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61693. }
  61694. /**
  61695. * The Observable class is a simple implementation of the Observable pattern.
  61696. *
  61697. * 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.
  61698. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61699. * 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).
  61700. * 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.
  61701. */
  61702. export class Observable<T> {
  61703. private _observers;
  61704. private _eventState;
  61705. private _onObserverAdded;
  61706. /**
  61707. * Creates a new observable
  61708. * @param onObserverAdded defines a callback to call when a new observer is added
  61709. */
  61710. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61711. /**
  61712. * Create a new Observer with the specified callback
  61713. * @param callback the callback that will be executed for that Observer
  61714. * @param mask the mask used to filter observers
  61715. * @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.
  61716. * @param scope optional scope for the callback to be called from
  61717. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61718. * @returns the new observer created for the callback
  61719. */
  61720. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61721. /**
  61722. * Create a new Observer with the specified callback and unregisters after the next notification
  61723. * @param callback the callback that will be executed for that Observer
  61724. * @returns the new observer created for the callback
  61725. */
  61726. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61727. /**
  61728. * Remove an Observer from the Observable object
  61729. * @param observer the instance of the Observer to remove
  61730. * @returns false if it doesn't belong to this Observable
  61731. */
  61732. remove(observer: Nullable<Observer<T>>): boolean;
  61733. /**
  61734. * Remove a callback from the Observable object
  61735. * @param callback the callback to remove
  61736. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61737. * @returns false if it doesn't belong to this Observable
  61738. */
  61739. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61740. private _deferUnregister;
  61741. private _remove;
  61742. /**
  61743. * Notify all Observers by calling their respective callback with the given data
  61744. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61745. * @param eventData defines the data to send to all observers
  61746. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  61747. * @param target defines the original target of the state
  61748. * @param currentTarget defines the current target of the state
  61749. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  61750. */
  61751. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  61752. /**
  61753. * Calling this will execute each callback, expecting it to be a promise or return a value.
  61754. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  61755. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  61756. * and it is crucial that all callbacks will be executed.
  61757. * The order of the callbacks is kept, callbacks are not executed parallel.
  61758. *
  61759. * @param eventData The data to be sent to each callback
  61760. * @param mask is used to filter observers defaults to -1
  61761. * @param target defines the callback target (see EventState)
  61762. * @param currentTarget defines he current object in the bubbling phase
  61763. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  61764. */
  61765. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  61766. /**
  61767. * Notify a specific observer
  61768. * @param observer defines the observer to notify
  61769. * @param eventData defines the data to be sent to each callback
  61770. * @param mask is used to filter observers defaults to -1
  61771. */
  61772. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  61773. /**
  61774. * Gets a boolean indicating if the observable has at least one observer
  61775. * @returns true is the Observable has at least one Observer registered
  61776. */
  61777. hasObservers(): boolean;
  61778. /**
  61779. * Clear the list of observers
  61780. */
  61781. clear(): void;
  61782. /**
  61783. * Clone the current observable
  61784. * @returns a new observable
  61785. */
  61786. clone(): Observable<T>;
  61787. /**
  61788. * Does this observable handles observer registered with a given mask
  61789. * @param mask defines the mask to be tested
  61790. * @return whether or not one observer registered with the given mask is handeled
  61791. **/
  61792. hasSpecificMask(mask?: number): boolean;
  61793. }
  61794. }
  61795. declare module BABYLON {
  61796. /**
  61797. * Class used to help managing file picking and drag'n'drop
  61798. * File Storage
  61799. */
  61800. export class FilesInputStore {
  61801. /**
  61802. * List of files ready to be loaded
  61803. */
  61804. static FilesToLoad: {
  61805. [key: string]: File;
  61806. };
  61807. }
  61808. }
  61809. declare module BABYLON {
  61810. /** Defines the cross module used constants to avoid circular dependncies */
  61811. export class Constants {
  61812. /** Defines that alpha blending is disabled */
  61813. static readonly ALPHA_DISABLE: number;
  61814. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  61815. static readonly ALPHA_ADD: number;
  61816. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  61817. static readonly ALPHA_COMBINE: number;
  61818. /** Defines that alpha blending to DEST - SRC * DEST */
  61819. static readonly ALPHA_SUBTRACT: number;
  61820. /** Defines that alpha blending to SRC * DEST */
  61821. static readonly ALPHA_MULTIPLY: number;
  61822. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  61823. static readonly ALPHA_MAXIMIZED: number;
  61824. /** Defines that alpha blending to SRC + DEST */
  61825. static readonly ALPHA_ONEONE: number;
  61826. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  61827. static readonly ALPHA_PREMULTIPLIED: number;
  61828. /**
  61829. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  61830. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  61831. */
  61832. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  61833. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  61834. static readonly ALPHA_INTERPOLATE: number;
  61835. /**
  61836. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  61837. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  61838. */
  61839. static readonly ALPHA_SCREENMODE: number;
  61840. /** Defines that the ressource is not delayed*/
  61841. static readonly DELAYLOADSTATE_NONE: number;
  61842. /** Defines that the ressource was successfully delay loaded */
  61843. static readonly DELAYLOADSTATE_LOADED: number;
  61844. /** Defines that the ressource is currently delay loading */
  61845. static readonly DELAYLOADSTATE_LOADING: number;
  61846. /** Defines that the ressource is delayed and has not started loading */
  61847. static readonly DELAYLOADSTATE_NOTLOADED: number;
  61848. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  61849. static readonly NEVER: number;
  61850. /** 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 */
  61851. static readonly ALWAYS: number;
  61852. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  61853. static readonly LESS: number;
  61854. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  61855. static readonly EQUAL: number;
  61856. /** 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 */
  61857. static readonly LEQUAL: number;
  61858. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  61859. static readonly GREATER: number;
  61860. /** 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 */
  61861. static readonly GEQUAL: number;
  61862. /** 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 */
  61863. static readonly NOTEQUAL: number;
  61864. /** Passed to stencilOperation to specify that stencil value must be kept */
  61865. static readonly KEEP: number;
  61866. /** Passed to stencilOperation to specify that stencil value must be replaced */
  61867. static readonly REPLACE: number;
  61868. /** Passed to stencilOperation to specify that stencil value must be incremented */
  61869. static readonly INCR: number;
  61870. /** Passed to stencilOperation to specify that stencil value must be decremented */
  61871. static readonly DECR: number;
  61872. /** Passed to stencilOperation to specify that stencil value must be inverted */
  61873. static readonly INVERT: number;
  61874. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  61875. static readonly INCR_WRAP: number;
  61876. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  61877. static readonly DECR_WRAP: number;
  61878. /** Texture is not repeating outside of 0..1 UVs */
  61879. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  61880. /** Texture is repeating outside of 0..1 UVs */
  61881. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  61882. /** Texture is repeating and mirrored */
  61883. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  61884. /** ALPHA */
  61885. static readonly TEXTUREFORMAT_ALPHA: number;
  61886. /** LUMINANCE */
  61887. static readonly TEXTUREFORMAT_LUMINANCE: number;
  61888. /** LUMINANCE_ALPHA */
  61889. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  61890. /** RGB */
  61891. static readonly TEXTUREFORMAT_RGB: number;
  61892. /** RGBA */
  61893. static readonly TEXTUREFORMAT_RGBA: number;
  61894. /** RED */
  61895. static readonly TEXTUREFORMAT_RED: number;
  61896. /** RED (2nd reference) */
  61897. static readonly TEXTUREFORMAT_R: number;
  61898. /** RG */
  61899. static readonly TEXTUREFORMAT_RG: number;
  61900. /** RED_INTEGER */
  61901. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  61902. /** RED_INTEGER (2nd reference) */
  61903. static readonly TEXTUREFORMAT_R_INTEGER: number;
  61904. /** RG_INTEGER */
  61905. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  61906. /** RGB_INTEGER */
  61907. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  61908. /** RGBA_INTEGER */
  61909. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  61910. /** UNSIGNED_BYTE */
  61911. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  61912. /** UNSIGNED_BYTE (2nd reference) */
  61913. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  61914. /** FLOAT */
  61915. static readonly TEXTURETYPE_FLOAT: number;
  61916. /** HALF_FLOAT */
  61917. static readonly TEXTURETYPE_HALF_FLOAT: number;
  61918. /** BYTE */
  61919. static readonly TEXTURETYPE_BYTE: number;
  61920. /** SHORT */
  61921. static readonly TEXTURETYPE_SHORT: number;
  61922. /** UNSIGNED_SHORT */
  61923. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  61924. /** INT */
  61925. static readonly TEXTURETYPE_INT: number;
  61926. /** UNSIGNED_INT */
  61927. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  61928. /** UNSIGNED_SHORT_4_4_4_4 */
  61929. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  61930. /** UNSIGNED_SHORT_5_5_5_1 */
  61931. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  61932. /** UNSIGNED_SHORT_5_6_5 */
  61933. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  61934. /** UNSIGNED_INT_2_10_10_10_REV */
  61935. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  61936. /** UNSIGNED_INT_24_8 */
  61937. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  61938. /** UNSIGNED_INT_10F_11F_11F_REV */
  61939. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  61940. /** UNSIGNED_INT_5_9_9_9_REV */
  61941. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  61942. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  61943. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61944. /** nearest is mag = nearest and min = nearest and mip = linear */
  61945. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  61946. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61947. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  61948. /** Trilinear is mag = linear and min = linear and mip = linear */
  61949. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  61950. /** nearest is mag = nearest and min = nearest and mip = linear */
  61951. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  61952. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61953. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  61954. /** Trilinear is mag = linear and min = linear and mip = linear */
  61955. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  61956. /** mag = nearest and min = nearest and mip = nearest */
  61957. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61958. /** mag = nearest and min = linear and mip = nearest */
  61959. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61960. /** mag = nearest and min = linear and mip = linear */
  61961. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61962. /** mag = nearest and min = linear and mip = none */
  61963. static readonly TEXTURE_NEAREST_LINEAR: number;
  61964. /** mag = nearest and min = nearest and mip = none */
  61965. static readonly TEXTURE_NEAREST_NEAREST: number;
  61966. /** mag = linear and min = nearest and mip = nearest */
  61967. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61968. /** mag = linear and min = nearest and mip = linear */
  61969. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  61970. /** mag = linear and min = linear and mip = none */
  61971. static readonly TEXTURE_LINEAR_LINEAR: number;
  61972. /** mag = linear and min = nearest and mip = none */
  61973. static readonly TEXTURE_LINEAR_NEAREST: number;
  61974. /** Explicit coordinates mode */
  61975. static readonly TEXTURE_EXPLICIT_MODE: number;
  61976. /** Spherical coordinates mode */
  61977. static readonly TEXTURE_SPHERICAL_MODE: number;
  61978. /** Planar coordinates mode */
  61979. static readonly TEXTURE_PLANAR_MODE: number;
  61980. /** Cubic coordinates mode */
  61981. static readonly TEXTURE_CUBIC_MODE: number;
  61982. /** Projection coordinates mode */
  61983. static readonly TEXTURE_PROJECTION_MODE: number;
  61984. /** Skybox coordinates mode */
  61985. static readonly TEXTURE_SKYBOX_MODE: number;
  61986. /** Inverse Cubic coordinates mode */
  61987. static readonly TEXTURE_INVCUBIC_MODE: number;
  61988. /** Equirectangular coordinates mode */
  61989. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  61990. /** Equirectangular Fixed coordinates mode */
  61991. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  61992. /** Equirectangular Fixed Mirrored coordinates mode */
  61993. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  61994. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  61995. static readonly SCALEMODE_FLOOR: number;
  61996. /** Defines that texture rescaling will look for the nearest power of 2 size */
  61997. static readonly SCALEMODE_NEAREST: number;
  61998. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  61999. static readonly SCALEMODE_CEILING: number;
  62000. /**
  62001. * The dirty texture flag value
  62002. */
  62003. static readonly MATERIAL_TextureDirtyFlag: number;
  62004. /**
  62005. * The dirty light flag value
  62006. */
  62007. static readonly MATERIAL_LightDirtyFlag: number;
  62008. /**
  62009. * The dirty fresnel flag value
  62010. */
  62011. static readonly MATERIAL_FresnelDirtyFlag: number;
  62012. /**
  62013. * The dirty attribute flag value
  62014. */
  62015. static readonly MATERIAL_AttributesDirtyFlag: number;
  62016. /**
  62017. * The dirty misc flag value
  62018. */
  62019. static readonly MATERIAL_MiscDirtyFlag: number;
  62020. /**
  62021. * The all dirty flag value
  62022. */
  62023. static readonly MATERIAL_AllDirtyFlag: number;
  62024. /**
  62025. * Returns the triangle fill mode
  62026. */
  62027. static readonly MATERIAL_TriangleFillMode: number;
  62028. /**
  62029. * Returns the wireframe mode
  62030. */
  62031. static readonly MATERIAL_WireFrameFillMode: number;
  62032. /**
  62033. * Returns the point fill mode
  62034. */
  62035. static readonly MATERIAL_PointFillMode: number;
  62036. /**
  62037. * Returns the point list draw mode
  62038. */
  62039. static readonly MATERIAL_PointListDrawMode: number;
  62040. /**
  62041. * Returns the line list draw mode
  62042. */
  62043. static readonly MATERIAL_LineListDrawMode: number;
  62044. /**
  62045. * Returns the line loop draw mode
  62046. */
  62047. static readonly MATERIAL_LineLoopDrawMode: number;
  62048. /**
  62049. * Returns the line strip draw mode
  62050. */
  62051. static readonly MATERIAL_LineStripDrawMode: number;
  62052. /**
  62053. * Returns the triangle strip draw mode
  62054. */
  62055. static readonly MATERIAL_TriangleStripDrawMode: number;
  62056. /**
  62057. * Returns the triangle fan draw mode
  62058. */
  62059. static readonly MATERIAL_TriangleFanDrawMode: number;
  62060. /**
  62061. * Stores the clock-wise side orientation
  62062. */
  62063. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62064. /**
  62065. * Stores the counter clock-wise side orientation
  62066. */
  62067. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62068. /**
  62069. * Nothing
  62070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62071. */
  62072. static readonly ACTION_NothingTrigger: number;
  62073. /**
  62074. * On pick
  62075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62076. */
  62077. static readonly ACTION_OnPickTrigger: number;
  62078. /**
  62079. * On left pick
  62080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62081. */
  62082. static readonly ACTION_OnLeftPickTrigger: number;
  62083. /**
  62084. * On right pick
  62085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62086. */
  62087. static readonly ACTION_OnRightPickTrigger: number;
  62088. /**
  62089. * On center pick
  62090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62091. */
  62092. static readonly ACTION_OnCenterPickTrigger: number;
  62093. /**
  62094. * On pick down
  62095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62096. */
  62097. static readonly ACTION_OnPickDownTrigger: number;
  62098. /**
  62099. * On double pick
  62100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62101. */
  62102. static readonly ACTION_OnDoublePickTrigger: number;
  62103. /**
  62104. * On pick up
  62105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62106. */
  62107. static readonly ACTION_OnPickUpTrigger: number;
  62108. /**
  62109. * On pick out.
  62110. * This trigger will only be raised if you also declared a OnPickDown
  62111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62112. */
  62113. static readonly ACTION_OnPickOutTrigger: number;
  62114. /**
  62115. * On long press
  62116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62117. */
  62118. static readonly ACTION_OnLongPressTrigger: number;
  62119. /**
  62120. * On pointer over
  62121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62122. */
  62123. static readonly ACTION_OnPointerOverTrigger: number;
  62124. /**
  62125. * On pointer out
  62126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62127. */
  62128. static readonly ACTION_OnPointerOutTrigger: number;
  62129. /**
  62130. * On every frame
  62131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62132. */
  62133. static readonly ACTION_OnEveryFrameTrigger: number;
  62134. /**
  62135. * On intersection enter
  62136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62137. */
  62138. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62139. /**
  62140. * On intersection exit
  62141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62142. */
  62143. static readonly ACTION_OnIntersectionExitTrigger: number;
  62144. /**
  62145. * On key down
  62146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62147. */
  62148. static readonly ACTION_OnKeyDownTrigger: number;
  62149. /**
  62150. * On key up
  62151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62152. */
  62153. static readonly ACTION_OnKeyUpTrigger: number;
  62154. /**
  62155. * Billboard mode will only apply to Y axis
  62156. */
  62157. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62158. /**
  62159. * Billboard mode will apply to all axes
  62160. */
  62161. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62162. /**
  62163. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62164. */
  62165. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62166. /**
  62167. * Gets or sets base Assets URL
  62168. */
  62169. static readonly PARTICLES_BaseAssetsUrl: string;
  62170. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62171. * Test order :
  62172. * Is the bounding sphere outside the frustum ?
  62173. * If not, are the bounding box vertices outside the frustum ?
  62174. * It not, then the cullable object is in the frustum.
  62175. */
  62176. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62177. /** Culling strategy : Bounding Sphere Only.
  62178. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62179. * It's also less accurate than the standard because some not visible objects can still be selected.
  62180. * Test : is the bounding sphere outside the frustum ?
  62181. * If not, then the cullable object is in the frustum.
  62182. */
  62183. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62184. /** Culling strategy : Optimistic Inclusion.
  62185. * This in an inclusion test first, then the standard exclusion test.
  62186. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62187. * 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.
  62188. * Anyway, it's as accurate as the standard strategy.
  62189. * Test :
  62190. * Is the cullable object bounding sphere center in the frustum ?
  62191. * If not, apply the default culling strategy.
  62192. */
  62193. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62194. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62195. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62196. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62197. * 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.
  62198. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62199. * Test :
  62200. * Is the cullable object bounding sphere center in the frustum ?
  62201. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62202. */
  62203. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62204. /**
  62205. * No logging while loading
  62206. */
  62207. static readonly SCENELOADER_NO_LOGGING: number;
  62208. /**
  62209. * Minimal logging while loading
  62210. */
  62211. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62212. /**
  62213. * Summary logging while loading
  62214. */
  62215. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62216. /**
  62217. * Detailled logging while loading
  62218. */
  62219. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62220. }
  62221. }
  62222. declare module BABYLON {
  62223. /**
  62224. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62225. * Babylon.js
  62226. */
  62227. export class DomManagement {
  62228. /**
  62229. * Checks if the window object exists
  62230. * @returns true if the window object exists
  62231. */
  62232. static IsWindowObjectExist(): boolean;
  62233. /**
  62234. * Extracts text content from a DOM element hierarchy
  62235. * @param element defines the root element
  62236. * @returns a string
  62237. */
  62238. static GetDOMTextContent(element: HTMLElement): string;
  62239. }
  62240. }
  62241. declare module BABYLON {
  62242. /**
  62243. * Logger used througouht the application to allow configuration of
  62244. * the log level required for the messages.
  62245. */
  62246. export class Logger {
  62247. /**
  62248. * No log
  62249. */
  62250. static readonly NoneLogLevel: number;
  62251. /**
  62252. * Only message logs
  62253. */
  62254. static readonly MessageLogLevel: number;
  62255. /**
  62256. * Only warning logs
  62257. */
  62258. static readonly WarningLogLevel: number;
  62259. /**
  62260. * Only error logs
  62261. */
  62262. static readonly ErrorLogLevel: number;
  62263. /**
  62264. * All logs
  62265. */
  62266. static readonly AllLogLevel: number;
  62267. private static _LogCache;
  62268. /**
  62269. * Gets a value indicating the number of loading errors
  62270. * @ignorenaming
  62271. */
  62272. static errorsCount: number;
  62273. /**
  62274. * Callback called when a new log is added
  62275. */
  62276. static OnNewCacheEntry: (entry: string) => void;
  62277. private static _AddLogEntry;
  62278. private static _FormatMessage;
  62279. private static _LogDisabled;
  62280. private static _LogEnabled;
  62281. private static _WarnDisabled;
  62282. private static _WarnEnabled;
  62283. private static _ErrorDisabled;
  62284. private static _ErrorEnabled;
  62285. /**
  62286. * Log a message to the console
  62287. */
  62288. static Log: (message: string) => void;
  62289. /**
  62290. * Write a warning message to the console
  62291. */
  62292. static Warn: (message: string) => void;
  62293. /**
  62294. * Write an error message to the console
  62295. */
  62296. static Error: (message: string) => void;
  62297. /**
  62298. * Gets current log cache (list of logs)
  62299. */
  62300. static readonly LogCache: string;
  62301. /**
  62302. * Clears the log cache
  62303. */
  62304. static ClearLogCache(): void;
  62305. /**
  62306. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62307. */
  62308. static LogLevels: number;
  62309. }
  62310. }
  62311. declare module BABYLON {
  62312. /** @hidden */
  62313. export class _TypeStore {
  62314. /** @hidden */
  62315. static RegisteredTypes: {
  62316. [key: string]: Object;
  62317. };
  62318. /** @hidden */
  62319. static GetClass(fqdn: string): any;
  62320. }
  62321. }
  62322. declare module BABYLON {
  62323. /**
  62324. * Class containing a set of static utilities functions for deep copy.
  62325. */
  62326. export class DeepCopier {
  62327. /**
  62328. * Tries to copy an object by duplicating every property
  62329. * @param source defines the source object
  62330. * @param destination defines the target object
  62331. * @param doNotCopyList defines a list of properties to avoid
  62332. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62333. */
  62334. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62335. }
  62336. }
  62337. declare module BABYLON {
  62338. /**
  62339. * Class containing a set of static utilities functions for precision date
  62340. */
  62341. export class PrecisionDate {
  62342. /**
  62343. * Gets either window.performance.now() if supported or Date.now() else
  62344. */
  62345. static readonly Now: number;
  62346. }
  62347. }
  62348. declare module BABYLON {
  62349. /** @hidden */
  62350. export class _DevTools {
  62351. static WarnImport(name: string): string;
  62352. }
  62353. }
  62354. declare module BABYLON {
  62355. /**
  62356. * Class used to evalaute queries containing `and` and `or` operators
  62357. */
  62358. export class AndOrNotEvaluator {
  62359. /**
  62360. * Evaluate a query
  62361. * @param query defines the query to evaluate
  62362. * @param evaluateCallback defines the callback used to filter result
  62363. * @returns true if the query matches
  62364. */
  62365. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62366. private static _HandleParenthesisContent;
  62367. private static _SimplifyNegation;
  62368. }
  62369. }
  62370. declare module BABYLON {
  62371. /**
  62372. * Class used to store custom tags
  62373. */
  62374. export class Tags {
  62375. /**
  62376. * Adds support for tags on the given object
  62377. * @param obj defines the object to use
  62378. */
  62379. static EnableFor(obj: any): void;
  62380. /**
  62381. * Removes tags support
  62382. * @param obj defines the object to use
  62383. */
  62384. static DisableFor(obj: any): void;
  62385. /**
  62386. * Gets a boolean indicating if the given object has tags
  62387. * @param obj defines the object to use
  62388. * @returns a boolean
  62389. */
  62390. static HasTags(obj: any): boolean;
  62391. /**
  62392. * Gets the tags available on a given object
  62393. * @param obj defines the object to use
  62394. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62395. * @returns the tags
  62396. */
  62397. static GetTags(obj: any, asString?: boolean): any;
  62398. /**
  62399. * Adds tags to an object
  62400. * @param obj defines the object to use
  62401. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62402. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62403. */
  62404. static AddTagsTo(obj: any, tagsString: string): void;
  62405. /**
  62406. * @hidden
  62407. */
  62408. static _AddTagTo(obj: any, tag: string): void;
  62409. /**
  62410. * Removes specific tags from a specific object
  62411. * @param obj defines the object to use
  62412. * @param tagsString defines the tags to remove
  62413. */
  62414. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62415. /**
  62416. * @hidden
  62417. */
  62418. static _RemoveTagFrom(obj: any, tag: string): void;
  62419. /**
  62420. * Defines if tags hosted on an object match a given query
  62421. * @param obj defines the object to use
  62422. * @param tagsQuery defines the tag query
  62423. * @returns a boolean
  62424. */
  62425. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62426. }
  62427. }
  62428. declare module BABYLON {
  62429. /**
  62430. * Manages the defines for the Material
  62431. */
  62432. export class MaterialDefines {
  62433. private _keys;
  62434. private _isDirty;
  62435. /** @hidden */
  62436. _renderId: number;
  62437. /** @hidden */
  62438. _areLightsDirty: boolean;
  62439. /** @hidden */
  62440. _areAttributesDirty: boolean;
  62441. /** @hidden */
  62442. _areTexturesDirty: boolean;
  62443. /** @hidden */
  62444. _areFresnelDirty: boolean;
  62445. /** @hidden */
  62446. _areMiscDirty: boolean;
  62447. /** @hidden */
  62448. _areImageProcessingDirty: boolean;
  62449. /** @hidden */
  62450. _normals: boolean;
  62451. /** @hidden */
  62452. _uvs: boolean;
  62453. /** @hidden */
  62454. _needNormals: boolean;
  62455. /** @hidden */
  62456. _needUVs: boolean;
  62457. /**
  62458. * Specifies if the material needs to be re-calculated
  62459. */
  62460. readonly isDirty: boolean;
  62461. /**
  62462. * Marks the material to indicate that it has been re-calculated
  62463. */
  62464. markAsProcessed(): void;
  62465. /**
  62466. * Marks the material to indicate that it needs to be re-calculated
  62467. */
  62468. markAsUnprocessed(): void;
  62469. /**
  62470. * Marks the material to indicate all of its defines need to be re-calculated
  62471. */
  62472. markAllAsDirty(): void;
  62473. /**
  62474. * Marks the material to indicate that image processing needs to be re-calculated
  62475. */
  62476. markAsImageProcessingDirty(): void;
  62477. /**
  62478. * Marks the material to indicate the lights need to be re-calculated
  62479. */
  62480. markAsLightDirty(): void;
  62481. /**
  62482. * Marks the attribute state as changed
  62483. */
  62484. markAsAttributesDirty(): void;
  62485. /**
  62486. * Marks the texture state as changed
  62487. */
  62488. markAsTexturesDirty(): void;
  62489. /**
  62490. * Marks the fresnel state as changed
  62491. */
  62492. markAsFresnelDirty(): void;
  62493. /**
  62494. * Marks the misc state as changed
  62495. */
  62496. markAsMiscDirty(): void;
  62497. /**
  62498. * Rebuilds the material defines
  62499. */
  62500. rebuild(): void;
  62501. /**
  62502. * Specifies if two material defines are equal
  62503. * @param other - A material define instance to compare to
  62504. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62505. */
  62506. isEqual(other: MaterialDefines): boolean;
  62507. /**
  62508. * Clones this instance's defines to another instance
  62509. * @param other - material defines to clone values to
  62510. */
  62511. cloneTo(other: MaterialDefines): void;
  62512. /**
  62513. * Resets the material define values
  62514. */
  62515. reset(): void;
  62516. /**
  62517. * Converts the material define values to a string
  62518. * @returns - String of material define information
  62519. */
  62520. toString(): string;
  62521. }
  62522. }
  62523. declare module BABYLON {
  62524. /**
  62525. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62526. */
  62527. export class PerformanceMonitor {
  62528. private _enabled;
  62529. private _rollingFrameTime;
  62530. private _lastFrameTimeMs;
  62531. /**
  62532. * constructor
  62533. * @param frameSampleSize The number of samples required to saturate the sliding window
  62534. */
  62535. constructor(frameSampleSize?: number);
  62536. /**
  62537. * Samples current frame
  62538. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62539. */
  62540. sampleFrame(timeMs?: number): void;
  62541. /**
  62542. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62543. */
  62544. readonly averageFrameTime: number;
  62545. /**
  62546. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62547. */
  62548. readonly averageFrameTimeVariance: number;
  62549. /**
  62550. * Returns the frame time of the most recent frame
  62551. */
  62552. readonly instantaneousFrameTime: number;
  62553. /**
  62554. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62555. */
  62556. readonly averageFPS: number;
  62557. /**
  62558. * Returns the average framerate in frames per second using the most recent frame time
  62559. */
  62560. readonly instantaneousFPS: number;
  62561. /**
  62562. * Returns true if enough samples have been taken to completely fill the sliding window
  62563. */
  62564. readonly isSaturated: boolean;
  62565. /**
  62566. * Enables contributions to the sliding window sample set
  62567. */
  62568. enable(): void;
  62569. /**
  62570. * Disables contributions to the sliding window sample set
  62571. * Samples will not be interpolated over the disabled period
  62572. */
  62573. disable(): void;
  62574. /**
  62575. * Returns true if sampling is enabled
  62576. */
  62577. readonly isEnabled: boolean;
  62578. /**
  62579. * Resets performance monitor
  62580. */
  62581. reset(): void;
  62582. }
  62583. /**
  62584. * RollingAverage
  62585. *
  62586. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62587. */
  62588. export class RollingAverage {
  62589. /**
  62590. * Current average
  62591. */
  62592. average: number;
  62593. /**
  62594. * Current variance
  62595. */
  62596. variance: number;
  62597. protected _samples: Array<number>;
  62598. protected _sampleCount: number;
  62599. protected _pos: number;
  62600. protected _m2: number;
  62601. /**
  62602. * constructor
  62603. * @param length The number of samples required to saturate the sliding window
  62604. */
  62605. constructor(length: number);
  62606. /**
  62607. * Adds a sample to the sample set
  62608. * @param v The sample value
  62609. */
  62610. add(v: number): void;
  62611. /**
  62612. * Returns previously added values or null if outside of history or outside the sliding window domain
  62613. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62614. * @return Value previously recorded with add() or null if outside of range
  62615. */
  62616. history(i: number): number;
  62617. /**
  62618. * Returns true if enough samples have been taken to completely fill the sliding window
  62619. * @return true if sample-set saturated
  62620. */
  62621. isSaturated(): boolean;
  62622. /**
  62623. * Resets the rolling average (equivalent to 0 samples taken so far)
  62624. */
  62625. reset(): void;
  62626. /**
  62627. * Wraps a value around the sample range boundaries
  62628. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62629. * @return Wrapped position in sample range
  62630. */
  62631. protected _wrapPosition(i: number): number;
  62632. }
  62633. }
  62634. declare module BABYLON {
  62635. /**
  62636. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62637. * The underlying implementation relies on an associative array to ensure the best performances.
  62638. * The value can be anything including 'null' but except 'undefined'
  62639. */
  62640. export class StringDictionary<T> {
  62641. /**
  62642. * This will clear this dictionary and copy the content from the 'source' one.
  62643. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62644. * @param source the dictionary to take the content from and copy to this dictionary
  62645. */
  62646. copyFrom(source: StringDictionary<T>): void;
  62647. /**
  62648. * Get a value based from its key
  62649. * @param key the given key to get the matching value from
  62650. * @return the value if found, otherwise undefined is returned
  62651. */
  62652. get(key: string): T | undefined;
  62653. /**
  62654. * Get a value from its key or add it if it doesn't exist.
  62655. * This method will ensure you that a given key/data will be present in the dictionary.
  62656. * @param key the given key to get the matching value from
  62657. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62658. * The factory will only be invoked if there's no data for the given key.
  62659. * @return the value corresponding to the key.
  62660. */
  62661. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62662. /**
  62663. * Get a value from its key if present in the dictionary otherwise add it
  62664. * @param key the key to get the value from
  62665. * @param val if there's no such key/value pair in the dictionary add it with this value
  62666. * @return the value corresponding to the key
  62667. */
  62668. getOrAdd(key: string, val: T): T;
  62669. /**
  62670. * Check if there's a given key in the dictionary
  62671. * @param key the key to check for
  62672. * @return true if the key is present, false otherwise
  62673. */
  62674. contains(key: string): boolean;
  62675. /**
  62676. * Add a new key and its corresponding value
  62677. * @param key the key to add
  62678. * @param value the value corresponding to the key
  62679. * @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
  62680. */
  62681. add(key: string, value: T): boolean;
  62682. /**
  62683. * Update a specific value associated to a key
  62684. * @param key defines the key to use
  62685. * @param value defines the value to store
  62686. * @returns true if the value was updated (or false if the key was not found)
  62687. */
  62688. set(key: string, value: T): boolean;
  62689. /**
  62690. * Get the element of the given key and remove it from the dictionary
  62691. * @param key defines the key to search
  62692. * @returns the value associated with the key or null if not found
  62693. */
  62694. getAndRemove(key: string): Nullable<T>;
  62695. /**
  62696. * Remove a key/value from the dictionary.
  62697. * @param key the key to remove
  62698. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62699. */
  62700. remove(key: string): boolean;
  62701. /**
  62702. * Clear the whole content of the dictionary
  62703. */
  62704. clear(): void;
  62705. /**
  62706. * Gets the current count
  62707. */
  62708. readonly count: number;
  62709. /**
  62710. * Execute a callback on each key/val of the dictionary.
  62711. * Note that you can remove any element in this dictionary in the callback implementation
  62712. * @param callback the callback to execute on a given key/value pair
  62713. */
  62714. forEach(callback: (key: string, val: T) => void): void;
  62715. /**
  62716. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62717. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62718. * Note that you can remove any element in this dictionary in the callback implementation
  62719. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62720. * @returns the first item
  62721. */
  62722. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62723. private _count;
  62724. private _data;
  62725. }
  62726. }
  62727. declare module BABYLON {
  62728. /**
  62729. * Helper class that provides a small promise polyfill
  62730. */
  62731. export class PromisePolyfill {
  62732. /**
  62733. * Static function used to check if the polyfill is required
  62734. * If this is the case then the function will inject the polyfill to window.Promise
  62735. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62736. */
  62737. static Apply(force?: boolean): void;
  62738. }
  62739. }
  62740. declare module BABYLON {
  62741. /**
  62742. * Class used to store data that will be store in GPU memory
  62743. */
  62744. export class Buffer {
  62745. private _engine;
  62746. private _buffer;
  62747. /** @hidden */
  62748. _data: Nullable<DataArray>;
  62749. private _updatable;
  62750. private _instanced;
  62751. /**
  62752. * Gets the byte stride.
  62753. */
  62754. readonly byteStride: number;
  62755. /**
  62756. * Constructor
  62757. * @param engine the engine
  62758. * @param data the data to use for this buffer
  62759. * @param updatable whether the data is updatable
  62760. * @param stride the stride (optional)
  62761. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62762. * @param instanced whether the buffer is instanced (optional)
  62763. * @param useBytes set to true if the stride in in bytes (optional)
  62764. */
  62765. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  62766. /**
  62767. * Create a new VertexBuffer based on the current buffer
  62768. * @param kind defines the vertex buffer kind (position, normal, etc.)
  62769. * @param offset defines offset in the buffer (0 by default)
  62770. * @param size defines the size in floats of attributes (position is 3 for instance)
  62771. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  62772. * @param instanced defines if the vertex buffer contains indexed data
  62773. * @param useBytes defines if the offset and stride are in bytes
  62774. * @returns the new vertex buffer
  62775. */
  62776. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  62777. /**
  62778. * Gets a boolean indicating if the Buffer is updatable?
  62779. * @returns true if the buffer is updatable
  62780. */
  62781. isUpdatable(): boolean;
  62782. /**
  62783. * Gets current buffer's data
  62784. * @returns a DataArray or null
  62785. */
  62786. getData(): Nullable<DataArray>;
  62787. /**
  62788. * Gets underlying native buffer
  62789. * @returns underlying native buffer
  62790. */
  62791. getBuffer(): Nullable<WebGLBuffer>;
  62792. /**
  62793. * Gets the stride in float32 units (i.e. byte stride / 4).
  62794. * May not be an integer if the byte stride is not divisible by 4.
  62795. * DEPRECATED. Use byteStride instead.
  62796. * @returns the stride in float32 units
  62797. */
  62798. getStrideSize(): number;
  62799. /**
  62800. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62801. * @param data defines the data to store
  62802. */
  62803. create(data?: Nullable<DataArray>): void;
  62804. /** @hidden */
  62805. _rebuild(): void;
  62806. /**
  62807. * Update current buffer data
  62808. * @param data defines the data to store
  62809. */
  62810. update(data: DataArray): void;
  62811. /**
  62812. * Updates the data directly.
  62813. * @param data the new data
  62814. * @param offset the new offset
  62815. * @param vertexCount the vertex count (optional)
  62816. * @param useBytes set to true if the offset is in bytes
  62817. */
  62818. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  62819. /**
  62820. * Release all resources
  62821. */
  62822. dispose(): void;
  62823. }
  62824. /**
  62825. * Specialized buffer used to store vertex data
  62826. */
  62827. export class VertexBuffer {
  62828. /** @hidden */
  62829. _buffer: Buffer;
  62830. private _kind;
  62831. private _size;
  62832. private _ownsBuffer;
  62833. private _instanced;
  62834. private _instanceDivisor;
  62835. /**
  62836. * The byte type.
  62837. */
  62838. static readonly BYTE: number;
  62839. /**
  62840. * The unsigned byte type.
  62841. */
  62842. static readonly UNSIGNED_BYTE: number;
  62843. /**
  62844. * The short type.
  62845. */
  62846. static readonly SHORT: number;
  62847. /**
  62848. * The unsigned short type.
  62849. */
  62850. static readonly UNSIGNED_SHORT: number;
  62851. /**
  62852. * The integer type.
  62853. */
  62854. static readonly INT: number;
  62855. /**
  62856. * The unsigned integer type.
  62857. */
  62858. static readonly UNSIGNED_INT: number;
  62859. /**
  62860. * The float type.
  62861. */
  62862. static readonly FLOAT: number;
  62863. /**
  62864. * Gets or sets the instance divisor when in instanced mode
  62865. */
  62866. instanceDivisor: number;
  62867. /**
  62868. * Gets the byte stride.
  62869. */
  62870. readonly byteStride: number;
  62871. /**
  62872. * Gets the byte offset.
  62873. */
  62874. readonly byteOffset: number;
  62875. /**
  62876. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  62877. */
  62878. readonly normalized: boolean;
  62879. /**
  62880. * Gets the data type of each component in the array.
  62881. */
  62882. readonly type: number;
  62883. /**
  62884. * Constructor
  62885. * @param engine the engine
  62886. * @param data the data to use for this vertex buffer
  62887. * @param kind the vertex buffer kind
  62888. * @param updatable whether the data is updatable
  62889. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62890. * @param stride the stride (optional)
  62891. * @param instanced whether the buffer is instanced (optional)
  62892. * @param offset the offset of the data (optional)
  62893. * @param size the number of components (optional)
  62894. * @param type the type of the component (optional)
  62895. * @param normalized whether the data contains normalized data (optional)
  62896. * @param useBytes set to true if stride and offset are in bytes (optional)
  62897. */
  62898. 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);
  62899. /** @hidden */
  62900. _rebuild(): void;
  62901. /**
  62902. * Returns the kind of the VertexBuffer (string)
  62903. * @returns a string
  62904. */
  62905. getKind(): string;
  62906. /**
  62907. * Gets a boolean indicating if the VertexBuffer is updatable?
  62908. * @returns true if the buffer is updatable
  62909. */
  62910. isUpdatable(): boolean;
  62911. /**
  62912. * Gets current buffer's data
  62913. * @returns a DataArray or null
  62914. */
  62915. getData(): Nullable<DataArray>;
  62916. /**
  62917. * Gets underlying native buffer
  62918. * @returns underlying native buffer
  62919. */
  62920. getBuffer(): Nullable<WebGLBuffer>;
  62921. /**
  62922. * Gets the stride in float32 units (i.e. byte stride / 4).
  62923. * May not be an integer if the byte stride is not divisible by 4.
  62924. * DEPRECATED. Use byteStride instead.
  62925. * @returns the stride in float32 units
  62926. */
  62927. getStrideSize(): number;
  62928. /**
  62929. * Returns the offset as a multiple of the type byte length.
  62930. * DEPRECATED. Use byteOffset instead.
  62931. * @returns the offset in bytes
  62932. */
  62933. getOffset(): number;
  62934. /**
  62935. * Returns the number of components per vertex attribute (integer)
  62936. * @returns the size in float
  62937. */
  62938. getSize(): number;
  62939. /**
  62940. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  62941. * @returns true if this buffer is instanced
  62942. */
  62943. getIsInstanced(): boolean;
  62944. /**
  62945. * Returns the instancing divisor, zero for non-instanced (integer).
  62946. * @returns a number
  62947. */
  62948. getInstanceDivisor(): number;
  62949. /**
  62950. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62951. * @param data defines the data to store
  62952. */
  62953. create(data?: DataArray): void;
  62954. /**
  62955. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  62956. * This function will create a new buffer if the current one is not updatable
  62957. * @param data defines the data to store
  62958. */
  62959. update(data: DataArray): void;
  62960. /**
  62961. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62962. * Returns the directly updated WebGLBuffer.
  62963. * @param data the new data
  62964. * @param offset the new offset
  62965. * @param useBytes set to true if the offset is in bytes
  62966. */
  62967. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62968. /**
  62969. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  62970. */
  62971. dispose(): void;
  62972. /**
  62973. * Enumerates each value of this vertex buffer as numbers.
  62974. * @param count the number of values to enumerate
  62975. * @param callback the callback function called for each value
  62976. */
  62977. forEach(count: number, callback: (value: number, index: number) => void): void;
  62978. /**
  62979. * Positions
  62980. */
  62981. static readonly PositionKind: string;
  62982. /**
  62983. * Normals
  62984. */
  62985. static readonly NormalKind: string;
  62986. /**
  62987. * Tangents
  62988. */
  62989. static readonly TangentKind: string;
  62990. /**
  62991. * Texture coordinates
  62992. */
  62993. static readonly UVKind: string;
  62994. /**
  62995. * Texture coordinates 2
  62996. */
  62997. static readonly UV2Kind: string;
  62998. /**
  62999. * Texture coordinates 3
  63000. */
  63001. static readonly UV3Kind: string;
  63002. /**
  63003. * Texture coordinates 4
  63004. */
  63005. static readonly UV4Kind: string;
  63006. /**
  63007. * Texture coordinates 5
  63008. */
  63009. static readonly UV5Kind: string;
  63010. /**
  63011. * Texture coordinates 6
  63012. */
  63013. static readonly UV6Kind: string;
  63014. /**
  63015. * Colors
  63016. */
  63017. static readonly ColorKind: string;
  63018. /**
  63019. * Matrix indices (for bones)
  63020. */
  63021. static readonly MatricesIndicesKind: string;
  63022. /**
  63023. * Matrix weights (for bones)
  63024. */
  63025. static readonly MatricesWeightsKind: string;
  63026. /**
  63027. * Additional matrix indices (for bones)
  63028. */
  63029. static readonly MatricesIndicesExtraKind: string;
  63030. /**
  63031. * Additional matrix weights (for bones)
  63032. */
  63033. static readonly MatricesWeightsExtraKind: string;
  63034. /**
  63035. * Deduces the stride given a kind.
  63036. * @param kind The kind string to deduce
  63037. * @returns The deduced stride
  63038. */
  63039. static DeduceStride(kind: string): number;
  63040. /**
  63041. * Gets the byte length of the given type.
  63042. * @param type the type
  63043. * @returns the number of bytes
  63044. */
  63045. static GetTypeByteLength(type: number): number;
  63046. /**
  63047. * Enumerates each value of the given parameters as numbers.
  63048. * @param data the data to enumerate
  63049. * @param byteOffset the byte offset of the data
  63050. * @param byteStride the byte stride of the data
  63051. * @param componentCount the number of components per element
  63052. * @param componentType the type of the component
  63053. * @param count the total number of components
  63054. * @param normalized whether the data is normalized
  63055. * @param callback the callback function called for each value
  63056. */
  63057. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63058. private static _GetFloatValue;
  63059. }
  63060. }
  63061. declare module BABYLON {
  63062. /**
  63063. * Class representing spherical polynomial coefficients to the 3rd degree
  63064. */
  63065. export class SphericalPolynomial {
  63066. /**
  63067. * The x coefficients of the spherical polynomial
  63068. */
  63069. x: Vector3;
  63070. /**
  63071. * The y coefficients of the spherical polynomial
  63072. */
  63073. y: Vector3;
  63074. /**
  63075. * The z coefficients of the spherical polynomial
  63076. */
  63077. z: Vector3;
  63078. /**
  63079. * The xx coefficients of the spherical polynomial
  63080. */
  63081. xx: Vector3;
  63082. /**
  63083. * The yy coefficients of the spherical polynomial
  63084. */
  63085. yy: Vector3;
  63086. /**
  63087. * The zz coefficients of the spherical polynomial
  63088. */
  63089. zz: Vector3;
  63090. /**
  63091. * The xy coefficients of the spherical polynomial
  63092. */
  63093. xy: Vector3;
  63094. /**
  63095. * The yz coefficients of the spherical polynomial
  63096. */
  63097. yz: Vector3;
  63098. /**
  63099. * The zx coefficients of the spherical polynomial
  63100. */
  63101. zx: Vector3;
  63102. /**
  63103. * Adds an ambient color to the spherical polynomial
  63104. * @param color the color to add
  63105. */
  63106. addAmbient(color: Color3): void;
  63107. /**
  63108. * Scales the spherical polynomial by the given amount
  63109. * @param scale the amount to scale
  63110. */
  63111. scale(scale: number): void;
  63112. /**
  63113. * Gets the spherical polynomial from harmonics
  63114. * @param harmonics the spherical harmonics
  63115. * @returns the spherical polynomial
  63116. */
  63117. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63118. /**
  63119. * Constructs a spherical polynomial from an array.
  63120. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63121. * @returns the spherical polynomial
  63122. */
  63123. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63124. }
  63125. /**
  63126. * Class representing spherical harmonics coefficients to the 3rd degree
  63127. */
  63128. export class SphericalHarmonics {
  63129. /**
  63130. * The l0,0 coefficients of the spherical harmonics
  63131. */
  63132. l00: Vector3;
  63133. /**
  63134. * The l1,-1 coefficients of the spherical harmonics
  63135. */
  63136. l1_1: Vector3;
  63137. /**
  63138. * The l1,0 coefficients of the spherical harmonics
  63139. */
  63140. l10: Vector3;
  63141. /**
  63142. * The l1,1 coefficients of the spherical harmonics
  63143. */
  63144. l11: Vector3;
  63145. /**
  63146. * The l2,-2 coefficients of the spherical harmonics
  63147. */
  63148. l2_2: Vector3;
  63149. /**
  63150. * The l2,-1 coefficients of the spherical harmonics
  63151. */
  63152. l2_1: Vector3;
  63153. /**
  63154. * The l2,0 coefficients of the spherical harmonics
  63155. */
  63156. l20: Vector3;
  63157. /**
  63158. * The l2,1 coefficients of the spherical harmonics
  63159. */
  63160. l21: Vector3;
  63161. /**
  63162. * The l2,2 coefficients of the spherical harmonics
  63163. */
  63164. lL22: Vector3;
  63165. /**
  63166. * Adds a light to the spherical harmonics
  63167. * @param direction the direction of the light
  63168. * @param color the color of the light
  63169. * @param deltaSolidAngle the delta solid angle of the light
  63170. */
  63171. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63172. /**
  63173. * Scales the spherical harmonics by the given amount
  63174. * @param scale the amount to scale
  63175. */
  63176. scale(scale: number): void;
  63177. /**
  63178. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63179. *
  63180. * ```
  63181. * E_lm = A_l * L_lm
  63182. * ```
  63183. *
  63184. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63185. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63186. * the scaling factors are given in equation 9.
  63187. */
  63188. convertIncidentRadianceToIrradiance(): void;
  63189. /**
  63190. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63191. *
  63192. * ```
  63193. * L = (1/pi) * E * rho
  63194. * ```
  63195. *
  63196. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63197. */
  63198. convertIrradianceToLambertianRadiance(): void;
  63199. /**
  63200. * Gets the spherical harmonics from polynomial
  63201. * @param polynomial the spherical polynomial
  63202. * @returns the spherical harmonics
  63203. */
  63204. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63205. /**
  63206. * Constructs a spherical harmonics from an array.
  63207. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63208. * @returns the spherical harmonics
  63209. */
  63210. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63211. }
  63212. }
  63213. declare module BABYLON {
  63214. /**
  63215. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63216. */
  63217. export interface CubeMapInfo {
  63218. /**
  63219. * The pixel array for the front face.
  63220. * This is stored in format, left to right, up to down format.
  63221. */
  63222. front: Nullable<ArrayBufferView>;
  63223. /**
  63224. * The pixel array for the back face.
  63225. * This is stored in format, left to right, up to down format.
  63226. */
  63227. back: Nullable<ArrayBufferView>;
  63228. /**
  63229. * The pixel array for the left face.
  63230. * This is stored in format, left to right, up to down format.
  63231. */
  63232. left: Nullable<ArrayBufferView>;
  63233. /**
  63234. * The pixel array for the right face.
  63235. * This is stored in format, left to right, up to down format.
  63236. */
  63237. right: Nullable<ArrayBufferView>;
  63238. /**
  63239. * The pixel array for the up face.
  63240. * This is stored in format, left to right, up to down format.
  63241. */
  63242. up: Nullable<ArrayBufferView>;
  63243. /**
  63244. * The pixel array for the down face.
  63245. * This is stored in format, left to right, up to down format.
  63246. */
  63247. down: Nullable<ArrayBufferView>;
  63248. /**
  63249. * The size of the cubemap stored.
  63250. *
  63251. * Each faces will be size * size pixels.
  63252. */
  63253. size: number;
  63254. /**
  63255. * The format of the texture.
  63256. *
  63257. * RGBA, RGB.
  63258. */
  63259. format: number;
  63260. /**
  63261. * The type of the texture data.
  63262. *
  63263. * UNSIGNED_INT, FLOAT.
  63264. */
  63265. type: number;
  63266. /**
  63267. * Specifies whether the texture is in gamma space.
  63268. */
  63269. gammaSpace: boolean;
  63270. }
  63271. /**
  63272. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63273. */
  63274. export class PanoramaToCubeMapTools {
  63275. private static FACE_FRONT;
  63276. private static FACE_BACK;
  63277. private static FACE_RIGHT;
  63278. private static FACE_LEFT;
  63279. private static FACE_DOWN;
  63280. private static FACE_UP;
  63281. /**
  63282. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63283. *
  63284. * @param float32Array The source data.
  63285. * @param inputWidth The width of the input panorama.
  63286. * @param inputHeight The height of the input panorama.
  63287. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63288. * @return The cubemap data
  63289. */
  63290. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63291. private static CreateCubemapTexture;
  63292. private static CalcProjectionSpherical;
  63293. }
  63294. }
  63295. declare module BABYLON {
  63296. /**
  63297. * Helper class dealing with the extraction of spherical polynomial dataArray
  63298. * from a cube map.
  63299. */
  63300. export class CubeMapToSphericalPolynomialTools {
  63301. private static FileFaces;
  63302. /**
  63303. * Converts a texture to the according Spherical Polynomial data.
  63304. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63305. *
  63306. * @param texture The texture to extract the information from.
  63307. * @return The Spherical Polynomial data.
  63308. */
  63309. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63310. /**
  63311. * Converts a cubemap to the according Spherical Polynomial data.
  63312. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63313. *
  63314. * @param cubeInfo The Cube map to extract the information from.
  63315. * @return The Spherical Polynomial data.
  63316. */
  63317. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63318. }
  63319. }
  63320. declare module BABYLON {
  63321. /**
  63322. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63323. * during the life time of the application.
  63324. */
  63325. export class EngineStore {
  63326. /** Gets the list of created engines */
  63327. static Instances: Engine[];
  63328. /**
  63329. * Gets the latest created engine
  63330. */
  63331. static readonly LastCreatedEngine: Nullable<Engine>;
  63332. /**
  63333. * Gets the latest created scene
  63334. */
  63335. static readonly LastCreatedScene: Nullable<Scene>;
  63336. }
  63337. }
  63338. declare module BABYLON {
  63339. /**
  63340. * Define options used to create a render target texture
  63341. */
  63342. export class RenderTargetCreationOptions {
  63343. /**
  63344. * Specifies is mipmaps must be generated
  63345. */
  63346. generateMipMaps?: boolean;
  63347. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63348. generateDepthBuffer?: boolean;
  63349. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63350. generateStencilBuffer?: boolean;
  63351. /** Defines texture type (int by default) */
  63352. type?: number;
  63353. /** Defines sampling mode (trilinear by default) */
  63354. samplingMode?: number;
  63355. /** Defines format (RGBA by default) */
  63356. format?: number;
  63357. }
  63358. }
  63359. declare module BABYLON {
  63360. /**
  63361. * @hidden
  63362. **/
  63363. export class _AlphaState {
  63364. private _isAlphaBlendDirty;
  63365. private _isBlendFunctionParametersDirty;
  63366. private _isBlendEquationParametersDirty;
  63367. private _isBlendConstantsDirty;
  63368. private _alphaBlend;
  63369. private _blendFunctionParameters;
  63370. private _blendEquationParameters;
  63371. private _blendConstants;
  63372. /**
  63373. * Initializes the state.
  63374. */
  63375. constructor();
  63376. readonly isDirty: boolean;
  63377. alphaBlend: boolean;
  63378. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63379. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63380. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63381. reset(): void;
  63382. apply(gl: WebGLRenderingContext): void;
  63383. }
  63384. }
  63385. declare module BABYLON {
  63386. /**
  63387. * @hidden
  63388. **/
  63389. export class _DepthCullingState {
  63390. private _isDepthTestDirty;
  63391. private _isDepthMaskDirty;
  63392. private _isDepthFuncDirty;
  63393. private _isCullFaceDirty;
  63394. private _isCullDirty;
  63395. private _isZOffsetDirty;
  63396. private _isFrontFaceDirty;
  63397. private _depthTest;
  63398. private _depthMask;
  63399. private _depthFunc;
  63400. private _cull;
  63401. private _cullFace;
  63402. private _zOffset;
  63403. private _frontFace;
  63404. /**
  63405. * Initializes the state.
  63406. */
  63407. constructor();
  63408. readonly isDirty: boolean;
  63409. zOffset: number;
  63410. cullFace: Nullable<number>;
  63411. cull: Nullable<boolean>;
  63412. depthFunc: Nullable<number>;
  63413. depthMask: boolean;
  63414. depthTest: boolean;
  63415. frontFace: Nullable<number>;
  63416. reset(): void;
  63417. apply(gl: WebGLRenderingContext): void;
  63418. }
  63419. }
  63420. declare module BABYLON {
  63421. /**
  63422. * @hidden
  63423. **/
  63424. export class _StencilState {
  63425. /** 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 */
  63426. static readonly ALWAYS: number;
  63427. /** Passed to stencilOperation to specify that stencil value must be kept */
  63428. static readonly KEEP: number;
  63429. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63430. static readonly REPLACE: number;
  63431. private _isStencilTestDirty;
  63432. private _isStencilMaskDirty;
  63433. private _isStencilFuncDirty;
  63434. private _isStencilOpDirty;
  63435. private _stencilTest;
  63436. private _stencilMask;
  63437. private _stencilFunc;
  63438. private _stencilFuncRef;
  63439. private _stencilFuncMask;
  63440. private _stencilOpStencilFail;
  63441. private _stencilOpDepthFail;
  63442. private _stencilOpStencilDepthPass;
  63443. readonly isDirty: boolean;
  63444. stencilFunc: number;
  63445. stencilFuncRef: number;
  63446. stencilFuncMask: number;
  63447. stencilOpStencilFail: number;
  63448. stencilOpDepthFail: number;
  63449. stencilOpStencilDepthPass: number;
  63450. stencilMask: number;
  63451. stencilTest: boolean;
  63452. constructor();
  63453. reset(): void;
  63454. apply(gl: WebGLRenderingContext): void;
  63455. }
  63456. }
  63457. declare module BABYLON {
  63458. /**
  63459. * @hidden
  63460. **/
  63461. export class _TimeToken {
  63462. _startTimeQuery: Nullable<WebGLQuery>;
  63463. _endTimeQuery: Nullable<WebGLQuery>;
  63464. _timeElapsedQuery: Nullable<WebGLQuery>;
  63465. _timeElapsedQueryEnded: boolean;
  63466. }
  63467. }
  63468. declare module BABYLON {
  63469. /**
  63470. * Internal interface used to track InternalTexture already bound to the GL context
  63471. */
  63472. export interface IInternalTextureTracker {
  63473. /**
  63474. * Gets or set the previous tracker in the list
  63475. */
  63476. previous: Nullable<IInternalTextureTracker>;
  63477. /**
  63478. * Gets or set the next tracker in the list
  63479. */
  63480. next: Nullable<IInternalTextureTracker>;
  63481. }
  63482. /**
  63483. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63484. */
  63485. export class DummyInternalTextureTracker {
  63486. /**
  63487. * Gets or set the previous tracker in the list
  63488. */
  63489. previous: Nullable<IInternalTextureTracker>;
  63490. /**
  63491. * Gets or set the next tracker in the list
  63492. */
  63493. next: Nullable<IInternalTextureTracker>;
  63494. }
  63495. }
  63496. declare module BABYLON {
  63497. /**
  63498. * Class used to store data associated with WebGL texture data for the engine
  63499. * This class should not be used directly
  63500. */
  63501. export class InternalTexture implements IInternalTextureTracker {
  63502. /** hidden */
  63503. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63504. /**
  63505. * The source of the texture data is unknown
  63506. */
  63507. static DATASOURCE_UNKNOWN: number;
  63508. /**
  63509. * Texture data comes from an URL
  63510. */
  63511. static DATASOURCE_URL: number;
  63512. /**
  63513. * Texture data is only used for temporary storage
  63514. */
  63515. static DATASOURCE_TEMP: number;
  63516. /**
  63517. * Texture data comes from raw data (ArrayBuffer)
  63518. */
  63519. static DATASOURCE_RAW: number;
  63520. /**
  63521. * Texture content is dynamic (video or dynamic texture)
  63522. */
  63523. static DATASOURCE_DYNAMIC: number;
  63524. /**
  63525. * Texture content is generated by rendering to it
  63526. */
  63527. static DATASOURCE_RENDERTARGET: number;
  63528. /**
  63529. * Texture content is part of a multi render target process
  63530. */
  63531. static DATASOURCE_MULTIRENDERTARGET: number;
  63532. /**
  63533. * Texture data comes from a cube data file
  63534. */
  63535. static DATASOURCE_CUBE: number;
  63536. /**
  63537. * Texture data comes from a raw cube data
  63538. */
  63539. static DATASOURCE_CUBERAW: number;
  63540. /**
  63541. * Texture data come from a prefiltered cube data file
  63542. */
  63543. static DATASOURCE_CUBEPREFILTERED: number;
  63544. /**
  63545. * Texture content is raw 3D data
  63546. */
  63547. static DATASOURCE_RAW3D: number;
  63548. /**
  63549. * Texture content is a depth texture
  63550. */
  63551. static DATASOURCE_DEPTHTEXTURE: number;
  63552. /**
  63553. * Texture data comes from a raw cube data encoded with RGBD
  63554. */
  63555. static DATASOURCE_CUBERAW_RGBD: number;
  63556. /**
  63557. * Defines if the texture is ready
  63558. */
  63559. isReady: boolean;
  63560. /**
  63561. * Defines if the texture is a cube texture
  63562. */
  63563. isCube: boolean;
  63564. /**
  63565. * Defines if the texture contains 3D data
  63566. */
  63567. is3D: boolean;
  63568. /**
  63569. * Gets the URL used to load this texture
  63570. */
  63571. url: string;
  63572. /**
  63573. * Gets the sampling mode of the texture
  63574. */
  63575. samplingMode: number;
  63576. /**
  63577. * Gets a boolean indicating if the texture needs mipmaps generation
  63578. */
  63579. generateMipMaps: boolean;
  63580. /**
  63581. * Gets the number of samples used by the texture (WebGL2+ only)
  63582. */
  63583. samples: number;
  63584. /**
  63585. * Gets the type of the texture (int, float...)
  63586. */
  63587. type: number;
  63588. /**
  63589. * Gets the format of the texture (RGB, RGBA...)
  63590. */
  63591. format: number;
  63592. /**
  63593. * Observable called when the texture is loaded
  63594. */
  63595. onLoadedObservable: Observable<InternalTexture>;
  63596. /**
  63597. * Gets the width of the texture
  63598. */
  63599. width: number;
  63600. /**
  63601. * Gets the height of the texture
  63602. */
  63603. height: number;
  63604. /**
  63605. * Gets the depth of the texture
  63606. */
  63607. depth: number;
  63608. /**
  63609. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63610. */
  63611. baseWidth: number;
  63612. /**
  63613. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63614. */
  63615. baseHeight: number;
  63616. /**
  63617. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63618. */
  63619. baseDepth: number;
  63620. /**
  63621. * Gets a boolean indicating if the texture is inverted on Y axis
  63622. */
  63623. invertY: boolean;
  63624. /**
  63625. * Gets or set the previous tracker in the list
  63626. */
  63627. previous: Nullable<IInternalTextureTracker>;
  63628. /**
  63629. * Gets or set the next tracker in the list
  63630. */
  63631. next: Nullable<IInternalTextureTracker>;
  63632. /** @hidden */
  63633. _invertVScale: boolean;
  63634. /** @hidden */
  63635. _initialSlot: number;
  63636. /** @hidden */
  63637. _designatedSlot: number;
  63638. /** @hidden */
  63639. _dataSource: number;
  63640. /** @hidden */
  63641. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63642. /** @hidden */
  63643. _bufferView: Nullable<ArrayBufferView>;
  63644. /** @hidden */
  63645. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63646. /** @hidden */
  63647. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63648. /** @hidden */
  63649. _size: number;
  63650. /** @hidden */
  63651. _extension: string;
  63652. /** @hidden */
  63653. _files: Nullable<string[]>;
  63654. /** @hidden */
  63655. _workingCanvas: HTMLCanvasElement;
  63656. /** @hidden */
  63657. _workingContext: CanvasRenderingContext2D;
  63658. /** @hidden */
  63659. _framebuffer: Nullable<WebGLFramebuffer>;
  63660. /** @hidden */
  63661. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63662. /** @hidden */
  63663. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63664. /** @hidden */
  63665. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63666. /** @hidden */
  63667. _attachments: Nullable<number[]>;
  63668. /** @hidden */
  63669. _cachedCoordinatesMode: Nullable<number>;
  63670. /** @hidden */
  63671. _cachedWrapU: Nullable<number>;
  63672. /** @hidden */
  63673. _cachedWrapV: Nullable<number>;
  63674. /** @hidden */
  63675. _cachedWrapR: Nullable<number>;
  63676. /** @hidden */
  63677. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63678. /** @hidden */
  63679. _isDisabled: boolean;
  63680. /** @hidden */
  63681. _compression: Nullable<string>;
  63682. /** @hidden */
  63683. _generateStencilBuffer: boolean;
  63684. /** @hidden */
  63685. _generateDepthBuffer: boolean;
  63686. /** @hidden */
  63687. _comparisonFunction: number;
  63688. /** @hidden */
  63689. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63690. /** @hidden */
  63691. _lodGenerationScale: number;
  63692. /** @hidden */
  63693. _lodGenerationOffset: number;
  63694. /** @hidden */
  63695. _lodTextureHigh: BaseTexture;
  63696. /** @hidden */
  63697. _lodTextureMid: BaseTexture;
  63698. /** @hidden */
  63699. _lodTextureLow: BaseTexture;
  63700. /** @hidden */
  63701. _isRGBD: boolean;
  63702. /** @hidden */
  63703. _webGLTexture: Nullable<WebGLTexture>;
  63704. /** @hidden */
  63705. _references: number;
  63706. private _engine;
  63707. /**
  63708. * Gets the Engine the texture belongs to.
  63709. * @returns The babylon engine
  63710. */
  63711. getEngine(): Engine;
  63712. /**
  63713. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63714. */
  63715. readonly dataSource: number;
  63716. /**
  63717. * Creates a new InternalTexture
  63718. * @param engine defines the engine to use
  63719. * @param dataSource defines the type of data that will be used
  63720. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63721. */
  63722. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63723. /**
  63724. * Increments the number of references (ie. the number of Texture that point to it)
  63725. */
  63726. incrementReferences(): void;
  63727. /**
  63728. * Change the size of the texture (not the size of the content)
  63729. * @param width defines the new width
  63730. * @param height defines the new height
  63731. * @param depth defines the new depth (1 by default)
  63732. */
  63733. updateSize(width: int, height: int, depth?: int): void;
  63734. /** @hidden */
  63735. _rebuild(): void;
  63736. /** @hidden */
  63737. _swapAndDie(target: InternalTexture): void;
  63738. /**
  63739. * Dispose the current allocated resources
  63740. */
  63741. dispose(): void;
  63742. }
  63743. }
  63744. declare module BABYLON {
  63745. /**
  63746. * This represents the main contract an easing function should follow.
  63747. * Easing functions are used throughout the animation system.
  63748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63749. */
  63750. export interface IEasingFunction {
  63751. /**
  63752. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63753. * of the easing function.
  63754. * The link below provides some of the most common examples of easing functions.
  63755. * @see https://easings.net/
  63756. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63757. * @returns the corresponding value on the curve defined by the easing function
  63758. */
  63759. ease(gradient: number): number;
  63760. }
  63761. /**
  63762. * Base class used for every default easing function.
  63763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63764. */
  63765. export class EasingFunction implements IEasingFunction {
  63766. /**
  63767. * Interpolation follows the mathematical formula associated with the easing function.
  63768. */
  63769. static readonly EASINGMODE_EASEIN: number;
  63770. /**
  63771. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  63772. */
  63773. static readonly EASINGMODE_EASEOUT: number;
  63774. /**
  63775. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  63776. */
  63777. static readonly EASINGMODE_EASEINOUT: number;
  63778. private _easingMode;
  63779. /**
  63780. * Sets the easing mode of the current function.
  63781. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  63782. */
  63783. setEasingMode(easingMode: number): void;
  63784. /**
  63785. * Gets the current easing mode.
  63786. * @returns the easing mode
  63787. */
  63788. getEasingMode(): number;
  63789. /**
  63790. * @hidden
  63791. */
  63792. easeInCore(gradient: number): number;
  63793. /**
  63794. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63795. * of the easing function.
  63796. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63797. * @returns the corresponding value on the curve defined by the easing function
  63798. */
  63799. ease(gradient: number): number;
  63800. }
  63801. /**
  63802. * Easing function with a circle shape (see link below).
  63803. * @see https://easings.net/#easeInCirc
  63804. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63805. */
  63806. export class CircleEase extends EasingFunction implements IEasingFunction {
  63807. /** @hidden */
  63808. easeInCore(gradient: number): number;
  63809. }
  63810. /**
  63811. * Easing function with a ease back shape (see link below).
  63812. * @see https://easings.net/#easeInBack
  63813. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63814. */
  63815. export class BackEase extends EasingFunction implements IEasingFunction {
  63816. /** Defines the amplitude of the function */
  63817. amplitude: number;
  63818. /**
  63819. * Instantiates a back ease easing
  63820. * @see https://easings.net/#easeInBack
  63821. * @param amplitude Defines the amplitude of the function
  63822. */
  63823. constructor(
  63824. /** Defines the amplitude of the function */
  63825. amplitude?: number);
  63826. /** @hidden */
  63827. easeInCore(gradient: number): number;
  63828. }
  63829. /**
  63830. * Easing function with a bouncing shape (see link below).
  63831. * @see https://easings.net/#easeInBounce
  63832. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63833. */
  63834. export class BounceEase extends EasingFunction implements IEasingFunction {
  63835. /** Defines the number of bounces */
  63836. bounces: number;
  63837. /** Defines the amplitude of the bounce */
  63838. bounciness: number;
  63839. /**
  63840. * Instantiates a bounce easing
  63841. * @see https://easings.net/#easeInBounce
  63842. * @param bounces Defines the number of bounces
  63843. * @param bounciness Defines the amplitude of the bounce
  63844. */
  63845. constructor(
  63846. /** Defines the number of bounces */
  63847. bounces?: number,
  63848. /** Defines the amplitude of the bounce */
  63849. bounciness?: number);
  63850. /** @hidden */
  63851. easeInCore(gradient: number): number;
  63852. }
  63853. /**
  63854. * Easing function with a power of 3 shape (see link below).
  63855. * @see https://easings.net/#easeInCubic
  63856. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63857. */
  63858. export class CubicEase extends EasingFunction implements IEasingFunction {
  63859. /** @hidden */
  63860. easeInCore(gradient: number): number;
  63861. }
  63862. /**
  63863. * Easing function with an elastic shape (see link below).
  63864. * @see https://easings.net/#easeInElastic
  63865. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63866. */
  63867. export class ElasticEase extends EasingFunction implements IEasingFunction {
  63868. /** Defines the number of oscillations*/
  63869. oscillations: number;
  63870. /** Defines the amplitude of the oscillations*/
  63871. springiness: number;
  63872. /**
  63873. * Instantiates an elastic easing function
  63874. * @see https://easings.net/#easeInElastic
  63875. * @param oscillations Defines the number of oscillations
  63876. * @param springiness Defines the amplitude of the oscillations
  63877. */
  63878. constructor(
  63879. /** Defines the number of oscillations*/
  63880. oscillations?: number,
  63881. /** Defines the amplitude of the oscillations*/
  63882. springiness?: number);
  63883. /** @hidden */
  63884. easeInCore(gradient: number): number;
  63885. }
  63886. /**
  63887. * Easing function with an exponential shape (see link below).
  63888. * @see https://easings.net/#easeInExpo
  63889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63890. */
  63891. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  63892. /** Defines the exponent of the function */
  63893. exponent: number;
  63894. /**
  63895. * Instantiates an exponential easing function
  63896. * @see https://easings.net/#easeInExpo
  63897. * @param exponent Defines the exponent of the function
  63898. */
  63899. constructor(
  63900. /** Defines the exponent of the function */
  63901. exponent?: number);
  63902. /** @hidden */
  63903. easeInCore(gradient: number): number;
  63904. }
  63905. /**
  63906. * Easing function with a power shape (see link below).
  63907. * @see https://easings.net/#easeInQuad
  63908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63909. */
  63910. export class PowerEase extends EasingFunction implements IEasingFunction {
  63911. /** Defines the power of the function */
  63912. power: number;
  63913. /**
  63914. * Instantiates an power base easing function
  63915. * @see https://easings.net/#easeInQuad
  63916. * @param power Defines the power of the function
  63917. */
  63918. constructor(
  63919. /** Defines the power of the function */
  63920. power?: number);
  63921. /** @hidden */
  63922. easeInCore(gradient: number): number;
  63923. }
  63924. /**
  63925. * Easing function with a power of 2 shape (see link below).
  63926. * @see https://easings.net/#easeInQuad
  63927. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63928. */
  63929. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  63930. /** @hidden */
  63931. easeInCore(gradient: number): number;
  63932. }
  63933. /**
  63934. * Easing function with a power of 4 shape (see link below).
  63935. * @see https://easings.net/#easeInQuart
  63936. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63937. */
  63938. export class QuarticEase extends EasingFunction implements IEasingFunction {
  63939. /** @hidden */
  63940. easeInCore(gradient: number): number;
  63941. }
  63942. /**
  63943. * Easing function with a power of 5 shape (see link below).
  63944. * @see https://easings.net/#easeInQuint
  63945. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63946. */
  63947. export class QuinticEase extends EasingFunction implements IEasingFunction {
  63948. /** @hidden */
  63949. easeInCore(gradient: number): number;
  63950. }
  63951. /**
  63952. * Easing function with a sin shape (see link below).
  63953. * @see https://easings.net/#easeInSine
  63954. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63955. */
  63956. export class SineEase extends EasingFunction implements IEasingFunction {
  63957. /** @hidden */
  63958. easeInCore(gradient: number): number;
  63959. }
  63960. /**
  63961. * Easing function with a bezier shape (see link below).
  63962. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63963. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63964. */
  63965. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63966. /** Defines the x component of the start tangent in the bezier curve */
  63967. x1: number;
  63968. /** Defines the y component of the start tangent in the bezier curve */
  63969. y1: number;
  63970. /** Defines the x component of the end tangent in the bezier curve */
  63971. x2: number;
  63972. /** Defines the y component of the end tangent in the bezier curve */
  63973. y2: number;
  63974. /**
  63975. * Instantiates a bezier function
  63976. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63977. * @param x1 Defines the x component of the start tangent in the bezier curve
  63978. * @param y1 Defines the y component of the start tangent in the bezier curve
  63979. * @param x2 Defines the x component of the end tangent in the bezier curve
  63980. * @param y2 Defines the y component of the end tangent in the bezier curve
  63981. */
  63982. constructor(
  63983. /** Defines the x component of the start tangent in the bezier curve */
  63984. x1?: number,
  63985. /** Defines the y component of the start tangent in the bezier curve */
  63986. y1?: number,
  63987. /** Defines the x component of the end tangent in the bezier curve */
  63988. x2?: number,
  63989. /** Defines the y component of the end tangent in the bezier curve */
  63990. y2?: number);
  63991. /** @hidden */
  63992. easeInCore(gradient: number): number;
  63993. }
  63994. }
  63995. declare module BABYLON {
  63996. /**
  63997. * Defines an interface which represents an animation key frame
  63998. */
  63999. export interface IAnimationKey {
  64000. /**
  64001. * Frame of the key frame
  64002. */
  64003. frame: number;
  64004. /**
  64005. * Value at the specifies key frame
  64006. */
  64007. value: any;
  64008. /**
  64009. * The input tangent for the cubic hermite spline
  64010. */
  64011. inTangent?: any;
  64012. /**
  64013. * The output tangent for the cubic hermite spline
  64014. */
  64015. outTangent?: any;
  64016. /**
  64017. * The animation interpolation type
  64018. */
  64019. interpolation?: AnimationKeyInterpolation;
  64020. }
  64021. /**
  64022. * Enum for the animation key frame interpolation type
  64023. */
  64024. export enum AnimationKeyInterpolation {
  64025. /**
  64026. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64027. */
  64028. STEP = 1
  64029. }
  64030. }
  64031. declare module BABYLON {
  64032. /**
  64033. * Represents the range of an animation
  64034. */
  64035. export class AnimationRange {
  64036. /**The name of the animation range**/
  64037. name: string;
  64038. /**The starting frame of the animation */
  64039. from: number;
  64040. /**The ending frame of the animation*/
  64041. to: number;
  64042. /**
  64043. * Initializes the range of an animation
  64044. * @param name The name of the animation range
  64045. * @param from The starting frame of the animation
  64046. * @param to The ending frame of the animation
  64047. */
  64048. constructor(
  64049. /**The name of the animation range**/
  64050. name: string,
  64051. /**The starting frame of the animation */
  64052. from: number,
  64053. /**The ending frame of the animation*/
  64054. to: number);
  64055. /**
  64056. * Makes a copy of the animation range
  64057. * @returns A copy of the animation range
  64058. */
  64059. clone(): AnimationRange;
  64060. }
  64061. }
  64062. declare module BABYLON {
  64063. /**
  64064. * Composed of a frame, and an action function
  64065. */
  64066. export class AnimationEvent {
  64067. /** The frame for which the event is triggered **/
  64068. frame: number;
  64069. /** The event to perform when triggered **/
  64070. action: (currentFrame: number) => void;
  64071. /** Specifies if the event should be triggered only once**/
  64072. onlyOnce?: boolean | undefined;
  64073. /**
  64074. * Specifies if the animation event is done
  64075. */
  64076. isDone: boolean;
  64077. /**
  64078. * Initializes the animation event
  64079. * @param frame The frame for which the event is triggered
  64080. * @param action The event to perform when triggered
  64081. * @param onlyOnce Specifies if the event should be triggered only once
  64082. */
  64083. constructor(
  64084. /** The frame for which the event is triggered **/
  64085. frame: number,
  64086. /** The event to perform when triggered **/
  64087. action: (currentFrame: number) => void,
  64088. /** Specifies if the event should be triggered only once**/
  64089. onlyOnce?: boolean | undefined);
  64090. /** @hidden */
  64091. _clone(): AnimationEvent;
  64092. }
  64093. }
  64094. declare module BABYLON {
  64095. /**
  64096. * Interface used to define a behavior
  64097. */
  64098. export interface Behavior<T> {
  64099. /** gets or sets behavior's name */
  64100. name: string;
  64101. /**
  64102. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64103. */
  64104. init(): void;
  64105. /**
  64106. * Called when the behavior is attached to a target
  64107. * @param target defines the target where the behavior is attached to
  64108. */
  64109. attach(target: T): void;
  64110. /**
  64111. * Called when the behavior is detached from its target
  64112. */
  64113. detach(): void;
  64114. }
  64115. /**
  64116. * Interface implemented by classes supporting behaviors
  64117. */
  64118. export interface IBehaviorAware<T> {
  64119. /**
  64120. * Attach a behavior
  64121. * @param behavior defines the behavior to attach
  64122. * @returns the current host
  64123. */
  64124. addBehavior(behavior: Behavior<T>): T;
  64125. /**
  64126. * Remove a behavior from the current object
  64127. * @param behavior defines the behavior to detach
  64128. * @returns the current host
  64129. */
  64130. removeBehavior(behavior: Behavior<T>): T;
  64131. /**
  64132. * Gets a behavior using its name to search
  64133. * @param name defines the name to search
  64134. * @returns the behavior or null if not found
  64135. */
  64136. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64137. }
  64138. }
  64139. declare module BABYLON {
  64140. /**
  64141. * @hidden
  64142. */
  64143. export class IntersectionInfo {
  64144. bu: Nullable<number>;
  64145. bv: Nullable<number>;
  64146. distance: number;
  64147. faceId: number;
  64148. subMeshId: number;
  64149. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64150. }
  64151. }
  64152. declare module BABYLON {
  64153. /**
  64154. * Class used to store bounding sphere information
  64155. */
  64156. export class BoundingSphere {
  64157. /**
  64158. * Gets the center of the bounding sphere in local space
  64159. */
  64160. readonly center: Vector3;
  64161. /**
  64162. * Radius of the bounding sphere in local space
  64163. */
  64164. radius: number;
  64165. /**
  64166. * Gets the center of the bounding sphere in world space
  64167. */
  64168. readonly centerWorld: Vector3;
  64169. /**
  64170. * Radius of the bounding sphere in world space
  64171. */
  64172. radiusWorld: number;
  64173. /**
  64174. * Gets the minimum vector in local space
  64175. */
  64176. readonly minimum: Vector3;
  64177. /**
  64178. * Gets the maximum vector in local space
  64179. */
  64180. readonly maximum: Vector3;
  64181. private _worldMatrix;
  64182. private static readonly TmpVector3;
  64183. /**
  64184. * Creates a new bounding sphere
  64185. * @param min defines the minimum vector (in local space)
  64186. * @param max defines the maximum vector (in local space)
  64187. * @param worldMatrix defines the new world matrix
  64188. */
  64189. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64190. /**
  64191. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64192. * @param min defines the new minimum vector (in local space)
  64193. * @param max defines the new maximum vector (in local space)
  64194. * @param worldMatrix defines the new world matrix
  64195. */
  64196. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64197. /**
  64198. * Scale the current bounding sphere by applying a scale factor
  64199. * @param factor defines the scale factor to apply
  64200. * @returns the current bounding box
  64201. */
  64202. scale(factor: number): BoundingSphere;
  64203. /**
  64204. * Gets the world matrix of the bounding box
  64205. * @returns a matrix
  64206. */
  64207. getWorldMatrix(): DeepImmutable<Matrix>;
  64208. /** @hidden */
  64209. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64210. /**
  64211. * Tests if the bounding sphere is intersecting the frustum planes
  64212. * @param frustumPlanes defines the frustum planes to test
  64213. * @returns true if there is an intersection
  64214. */
  64215. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64216. /**
  64217. * Tests if the bounding sphere center is in between the frustum planes.
  64218. * Used for optimistic fast inclusion.
  64219. * @param frustumPlanes defines the frustum planes to test
  64220. * @returns true if the sphere center is in between the frustum planes
  64221. */
  64222. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64223. /**
  64224. * Tests if a point is inside the bounding sphere
  64225. * @param point defines the point to test
  64226. * @returns true if the point is inside the bounding sphere
  64227. */
  64228. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64229. /**
  64230. * Checks if two sphere intersct
  64231. * @param sphere0 sphere 0
  64232. * @param sphere1 sphere 1
  64233. * @returns true if the speres intersect
  64234. */
  64235. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64236. }
  64237. }
  64238. declare module BABYLON {
  64239. /**
  64240. * Class used to store bounding box information
  64241. */
  64242. export class BoundingBox implements ICullable {
  64243. /**
  64244. * Gets the 8 vectors representing the bounding box in local space
  64245. */
  64246. readonly vectors: Vector3[];
  64247. /**
  64248. * Gets the center of the bounding box in local space
  64249. */
  64250. readonly center: Vector3;
  64251. /**
  64252. * Gets the center of the bounding box in world space
  64253. */
  64254. readonly centerWorld: Vector3;
  64255. /**
  64256. * Gets the extend size in local space
  64257. */
  64258. readonly extendSize: Vector3;
  64259. /**
  64260. * Gets the extend size in world space
  64261. */
  64262. readonly extendSizeWorld: Vector3;
  64263. /**
  64264. * Gets the OBB (object bounding box) directions
  64265. */
  64266. readonly directions: Vector3[];
  64267. /**
  64268. * Gets the 8 vectors representing the bounding box in world space
  64269. */
  64270. readonly vectorsWorld: Vector3[];
  64271. /**
  64272. * Gets the minimum vector in world space
  64273. */
  64274. readonly minimumWorld: Vector3;
  64275. /**
  64276. * Gets the maximum vector in world space
  64277. */
  64278. readonly maximumWorld: Vector3;
  64279. /**
  64280. * Gets the minimum vector in local space
  64281. */
  64282. readonly minimum: Vector3;
  64283. /**
  64284. * Gets the maximum vector in local space
  64285. */
  64286. readonly maximum: Vector3;
  64287. private _worldMatrix;
  64288. private static readonly TmpVector3;
  64289. /**
  64290. * @hidden
  64291. */
  64292. _tag: number;
  64293. /**
  64294. * Creates a new bounding box
  64295. * @param min defines the minimum vector (in local space)
  64296. * @param max defines the maximum vector (in local space)
  64297. * @param worldMatrix defines the new world matrix
  64298. */
  64299. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64300. /**
  64301. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64302. * @param min defines the new minimum vector (in local space)
  64303. * @param max defines the new maximum vector (in local space)
  64304. * @param worldMatrix defines the new world matrix
  64305. */
  64306. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64307. /**
  64308. * Scale the current bounding box by applying a scale factor
  64309. * @param factor defines the scale factor to apply
  64310. * @returns the current bounding box
  64311. */
  64312. scale(factor: number): BoundingBox;
  64313. /**
  64314. * Gets the world matrix of the bounding box
  64315. * @returns a matrix
  64316. */
  64317. getWorldMatrix(): DeepImmutable<Matrix>;
  64318. /** @hidden */
  64319. _update(world: DeepImmutable<Matrix>): void;
  64320. /**
  64321. * Tests if the bounding box is intersecting the frustum planes
  64322. * @param frustumPlanes defines the frustum planes to test
  64323. * @returns true if there is an intersection
  64324. */
  64325. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64326. /**
  64327. * Tests if the bounding box is entirely inside the frustum planes
  64328. * @param frustumPlanes defines the frustum planes to test
  64329. * @returns true if there is an inclusion
  64330. */
  64331. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64332. /**
  64333. * Tests if a point is inside the bounding box
  64334. * @param point defines the point to test
  64335. * @returns true if the point is inside the bounding box
  64336. */
  64337. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64338. /**
  64339. * Tests if the bounding box intersects with a bounding sphere
  64340. * @param sphere defines the sphere to test
  64341. * @returns true if there is an intersection
  64342. */
  64343. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64344. /**
  64345. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64346. * @param min defines the min vector to use
  64347. * @param max defines the max vector to use
  64348. * @returns true if there is an intersection
  64349. */
  64350. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64351. /**
  64352. * Tests if two bounding boxes are intersections
  64353. * @param box0 defines the first box to test
  64354. * @param box1 defines the second box to test
  64355. * @returns true if there is an intersection
  64356. */
  64357. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64358. /**
  64359. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64360. * @param minPoint defines the minimum vector of the bounding box
  64361. * @param maxPoint defines the maximum vector of the bounding box
  64362. * @param sphereCenter defines the sphere center
  64363. * @param sphereRadius defines the sphere radius
  64364. * @returns true if there is an intersection
  64365. */
  64366. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64367. /**
  64368. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64369. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64370. * @param frustumPlanes defines the frustum planes to test
  64371. * @return true if there is an inclusion
  64372. */
  64373. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64374. /**
  64375. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64376. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64377. * @param frustumPlanes defines the frustum planes to test
  64378. * @return true if there is an intersection
  64379. */
  64380. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64381. }
  64382. }
  64383. declare module BABYLON {
  64384. /** @hidden */
  64385. export class Collider {
  64386. /** Define if a collision was found */
  64387. collisionFound: boolean;
  64388. /**
  64389. * Define last intersection point in local space
  64390. */
  64391. intersectionPoint: Vector3;
  64392. /**
  64393. * Define last collided mesh
  64394. */
  64395. collidedMesh: Nullable<AbstractMesh>;
  64396. private _collisionPoint;
  64397. private _planeIntersectionPoint;
  64398. private _tempVector;
  64399. private _tempVector2;
  64400. private _tempVector3;
  64401. private _tempVector4;
  64402. private _edge;
  64403. private _baseToVertex;
  64404. private _destinationPoint;
  64405. private _slidePlaneNormal;
  64406. private _displacementVector;
  64407. /** @hidden */
  64408. _radius: Vector3;
  64409. /** @hidden */
  64410. _retry: number;
  64411. private _velocity;
  64412. private _basePoint;
  64413. private _epsilon;
  64414. /** @hidden */
  64415. _velocityWorldLength: number;
  64416. /** @hidden */
  64417. _basePointWorld: Vector3;
  64418. private _velocityWorld;
  64419. private _normalizedVelocity;
  64420. /** @hidden */
  64421. _initialVelocity: Vector3;
  64422. /** @hidden */
  64423. _initialPosition: Vector3;
  64424. private _nearestDistance;
  64425. private _collisionMask;
  64426. collisionMask: number;
  64427. /**
  64428. * Gets the plane normal used to compute the sliding response (in local space)
  64429. */
  64430. readonly slidePlaneNormal: Vector3;
  64431. /** @hidden */
  64432. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64433. /** @hidden */
  64434. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64435. /** @hidden */
  64436. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64437. /** @hidden */
  64438. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64439. /** @hidden */
  64440. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64441. /** @hidden */
  64442. _getResponse(pos: Vector3, vel: Vector3): void;
  64443. }
  64444. }
  64445. declare module BABYLON {
  64446. /**
  64447. * Interface for cullable objects
  64448. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64449. */
  64450. export interface ICullable {
  64451. /**
  64452. * Checks if the object or part of the object is in the frustum
  64453. * @param frustumPlanes Camera near/planes
  64454. * @returns true if the object is in frustum otherwise false
  64455. */
  64456. isInFrustum(frustumPlanes: Plane[]): boolean;
  64457. /**
  64458. * Checks if a cullable object (mesh...) is in the camera frustum
  64459. * Unlike isInFrustum this cheks the full bounding box
  64460. * @param frustumPlanes Camera near/planes
  64461. * @returns true if the object is in frustum otherwise false
  64462. */
  64463. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64464. }
  64465. /**
  64466. * Info for a bounding data of a mesh
  64467. */
  64468. export class BoundingInfo implements ICullable {
  64469. /**
  64470. * Bounding box for the mesh
  64471. */
  64472. readonly boundingBox: BoundingBox;
  64473. /**
  64474. * Bounding sphere for the mesh
  64475. */
  64476. readonly boundingSphere: BoundingSphere;
  64477. private _isLocked;
  64478. private static readonly TmpVector3;
  64479. /**
  64480. * Constructs bounding info
  64481. * @param minimum min vector of the bounding box/sphere
  64482. * @param maximum max vector of the bounding box/sphere
  64483. * @param worldMatrix defines the new world matrix
  64484. */
  64485. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64486. /**
  64487. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64488. * @param min defines the new minimum vector (in local space)
  64489. * @param max defines the new maximum vector (in local space)
  64490. * @param worldMatrix defines the new world matrix
  64491. */
  64492. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64493. /**
  64494. * min vector of the bounding box/sphere
  64495. */
  64496. readonly minimum: Vector3;
  64497. /**
  64498. * max vector of the bounding box/sphere
  64499. */
  64500. readonly maximum: Vector3;
  64501. /**
  64502. * If the info is locked and won't be updated to avoid perf overhead
  64503. */
  64504. isLocked: boolean;
  64505. /**
  64506. * Updates the bounding sphere and box
  64507. * @param world world matrix to be used to update
  64508. */
  64509. update(world: DeepImmutable<Matrix>): void;
  64510. /**
  64511. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64512. * @param center New center of the bounding info
  64513. * @param extend New extend of the bounding info
  64514. * @returns the current bounding info
  64515. */
  64516. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64517. /**
  64518. * Scale the current bounding info by applying a scale factor
  64519. * @param factor defines the scale factor to apply
  64520. * @returns the current bounding info
  64521. */
  64522. scale(factor: number): BoundingInfo;
  64523. /**
  64524. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64525. * @param frustumPlanes defines the frustum to test
  64526. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64527. * @returns true if the bounding info is in the frustum planes
  64528. */
  64529. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64530. /**
  64531. * Gets the world distance between the min and max points of the bounding box
  64532. */
  64533. readonly diagonalLength: number;
  64534. /**
  64535. * Checks if a cullable object (mesh...) is in the camera frustum
  64536. * Unlike isInFrustum this cheks the full bounding box
  64537. * @param frustumPlanes Camera near/planes
  64538. * @returns true if the object is in frustum otherwise false
  64539. */
  64540. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64541. /** @hidden */
  64542. _checkCollision(collider: Collider): boolean;
  64543. /**
  64544. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64545. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64546. * @param point the point to check intersection with
  64547. * @returns if the point intersects
  64548. */
  64549. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64550. /**
  64551. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64552. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64553. * @param boundingInfo the bounding info to check intersection with
  64554. * @param precise if the intersection should be done using OBB
  64555. * @returns if the bounding info intersects
  64556. */
  64557. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64558. }
  64559. }
  64560. declare module BABYLON {
  64561. /**
  64562. * Defines an array and its length.
  64563. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64564. */
  64565. export interface ISmartArrayLike<T> {
  64566. /**
  64567. * The data of the array.
  64568. */
  64569. data: Array<T>;
  64570. /**
  64571. * The active length of the array.
  64572. */
  64573. length: number;
  64574. }
  64575. /**
  64576. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64577. */
  64578. export class SmartArray<T> implements ISmartArrayLike<T> {
  64579. /**
  64580. * The full set of data from the array.
  64581. */
  64582. data: Array<T>;
  64583. /**
  64584. * The active length of the array.
  64585. */
  64586. length: number;
  64587. protected _id: number;
  64588. /**
  64589. * Instantiates a Smart Array.
  64590. * @param capacity defines the default capacity of the array.
  64591. */
  64592. constructor(capacity: number);
  64593. /**
  64594. * Pushes a value at the end of the active data.
  64595. * @param value defines the object to push in the array.
  64596. */
  64597. push(value: T): void;
  64598. /**
  64599. * Iterates over the active data and apply the lambda to them.
  64600. * @param func defines the action to apply on each value.
  64601. */
  64602. forEach(func: (content: T) => void): void;
  64603. /**
  64604. * Sorts the full sets of data.
  64605. * @param compareFn defines the comparison function to apply.
  64606. */
  64607. sort(compareFn: (a: T, b: T) => number): void;
  64608. /**
  64609. * Resets the active data to an empty array.
  64610. */
  64611. reset(): void;
  64612. /**
  64613. * Releases all the data from the array as well as the array.
  64614. */
  64615. dispose(): void;
  64616. /**
  64617. * Concats the active data with a given array.
  64618. * @param array defines the data to concatenate with.
  64619. */
  64620. concat(array: any): void;
  64621. /**
  64622. * Returns the position of a value in the active data.
  64623. * @param value defines the value to find the index for
  64624. * @returns the index if found in the active data otherwise -1
  64625. */
  64626. indexOf(value: T): number;
  64627. /**
  64628. * Returns whether an element is part of the active data.
  64629. * @param value defines the value to look for
  64630. * @returns true if found in the active data otherwise false
  64631. */
  64632. contains(value: T): boolean;
  64633. private static _GlobalId;
  64634. }
  64635. /**
  64636. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64637. * The data in this array can only be present once
  64638. */
  64639. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64640. private _duplicateId;
  64641. /**
  64642. * Pushes a value at the end of the active data.
  64643. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64644. * @param value defines the object to push in the array.
  64645. */
  64646. push(value: T): void;
  64647. /**
  64648. * Pushes a value at the end of the active data.
  64649. * If the data is already present, it won t be added again
  64650. * @param value defines the object to push in the array.
  64651. * @returns true if added false if it was already present
  64652. */
  64653. pushNoDuplicate(value: T): boolean;
  64654. /**
  64655. * Resets the active data to an empty array.
  64656. */
  64657. reset(): void;
  64658. /**
  64659. * Concats the active data with a given array.
  64660. * This ensures no dupplicate will be present in the result.
  64661. * @param array defines the data to concatenate with.
  64662. */
  64663. concatWithNoDuplicate(array: any): void;
  64664. }
  64665. }
  64666. declare module BABYLON {
  64667. /**
  64668. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64669. * separate meshes. This can be use to improve performances.
  64670. * @see http://doc.babylonjs.com/how_to/multi_materials
  64671. */
  64672. export class MultiMaterial extends Material {
  64673. private _subMaterials;
  64674. /**
  64675. * Gets or Sets the list of Materials used within the multi material.
  64676. * They need to be ordered according to the submeshes order in the associated mesh
  64677. */
  64678. subMaterials: Nullable<Material>[];
  64679. /**
  64680. * Function used to align with Node.getChildren()
  64681. * @returns the list of Materials used within the multi material
  64682. */
  64683. getChildren(): Nullable<Material>[];
  64684. /**
  64685. * Instantiates a new Multi Material
  64686. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64687. * separate meshes. This can be use to improve performances.
  64688. * @see http://doc.babylonjs.com/how_to/multi_materials
  64689. * @param name Define the name in the scene
  64690. * @param scene Define the scene the material belongs to
  64691. */
  64692. constructor(name: string, scene: Scene);
  64693. private _hookArray;
  64694. /**
  64695. * Get one of the submaterial by its index in the submaterials array
  64696. * @param index The index to look the sub material at
  64697. * @returns The Material if the index has been defined
  64698. */
  64699. getSubMaterial(index: number): Nullable<Material>;
  64700. /**
  64701. * Get the list of active textures for the whole sub materials list.
  64702. * @returns All the textures that will be used during the rendering
  64703. */
  64704. getActiveTextures(): BaseTexture[];
  64705. /**
  64706. * Gets the current class name of the material e.g. "MultiMaterial"
  64707. * Mainly use in serialization.
  64708. * @returns the class name
  64709. */
  64710. getClassName(): string;
  64711. /**
  64712. * Checks if the material is ready to render the requested sub mesh
  64713. * @param mesh Define the mesh the submesh belongs to
  64714. * @param subMesh Define the sub mesh to look readyness for
  64715. * @param useInstances Define whether or not the material is used with instances
  64716. * @returns true if ready, otherwise false
  64717. */
  64718. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64719. /**
  64720. * Clones the current material and its related sub materials
  64721. * @param name Define the name of the newly cloned material
  64722. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64723. * @returns the cloned material
  64724. */
  64725. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64726. /**
  64727. * Serializes the materials into a JSON representation.
  64728. * @returns the JSON representation
  64729. */
  64730. serialize(): any;
  64731. /**
  64732. * Dispose the material and release its associated resources
  64733. * @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)
  64734. * @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)
  64735. * @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)
  64736. */
  64737. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64738. /**
  64739. * Creates a MultiMaterial from parsed MultiMaterial data.
  64740. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64741. * @param scene defines the hosting scene
  64742. * @returns a new MultiMaterial
  64743. */
  64744. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64745. }
  64746. }
  64747. declare module BABYLON {
  64748. /**
  64749. * Class used to represent data loading progression
  64750. */
  64751. export class SceneLoaderFlags {
  64752. private static _ForceFullSceneLoadingForIncremental;
  64753. private static _ShowLoadingScreen;
  64754. private static _CleanBoneMatrixWeights;
  64755. private static _loggingLevel;
  64756. /**
  64757. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64758. */
  64759. static ForceFullSceneLoadingForIncremental: boolean;
  64760. /**
  64761. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  64762. */
  64763. static ShowLoadingScreen: boolean;
  64764. /**
  64765. * Defines the current logging level (while loading the scene)
  64766. * @ignorenaming
  64767. */
  64768. static loggingLevel: number;
  64769. /**
  64770. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  64771. */
  64772. static CleanBoneMatrixWeights: boolean;
  64773. }
  64774. }
  64775. declare module BABYLON {
  64776. /**
  64777. * 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.
  64778. * @see https://doc.babylonjs.com/how_to/transformnode
  64779. */
  64780. export class TransformNode extends Node {
  64781. /**
  64782. * Object will not rotate to face the camera
  64783. */
  64784. static BILLBOARDMODE_NONE: number;
  64785. /**
  64786. * Object will rotate to face the camera but only on the x axis
  64787. */
  64788. static BILLBOARDMODE_X: number;
  64789. /**
  64790. * Object will rotate to face the camera but only on the y axis
  64791. */
  64792. static BILLBOARDMODE_Y: number;
  64793. /**
  64794. * Object will rotate to face the camera but only on the z axis
  64795. */
  64796. static BILLBOARDMODE_Z: number;
  64797. /**
  64798. * Object will rotate to face the camera
  64799. */
  64800. static BILLBOARDMODE_ALL: number;
  64801. private _forward;
  64802. private _forwardInverted;
  64803. private _up;
  64804. private _right;
  64805. private _rightInverted;
  64806. private _position;
  64807. private _rotation;
  64808. private _rotationQuaternion;
  64809. protected _scaling: Vector3;
  64810. protected _isDirty: boolean;
  64811. private _transformToBoneReferal;
  64812. /**
  64813. * Set the billboard mode. Default is 0.
  64814. *
  64815. * | Value | Type | Description |
  64816. * | --- | --- | --- |
  64817. * | 0 | BILLBOARDMODE_NONE | |
  64818. * | 1 | BILLBOARDMODE_X | |
  64819. * | 2 | BILLBOARDMODE_Y | |
  64820. * | 4 | BILLBOARDMODE_Z | |
  64821. * | 7 | BILLBOARDMODE_ALL | |
  64822. *
  64823. */
  64824. billboardMode: number;
  64825. /**
  64826. * 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
  64827. */
  64828. scalingDeterminant: number;
  64829. /**
  64830. * Sets the distance of the object to max, often used by skybox
  64831. */
  64832. infiniteDistance: boolean;
  64833. /**
  64834. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  64835. * By default the system will update normals to compensate
  64836. */
  64837. ignoreNonUniformScaling: boolean;
  64838. /** @hidden */
  64839. _poseMatrix: Matrix;
  64840. /** @hidden */
  64841. _localMatrix: Matrix;
  64842. private _absolutePosition;
  64843. private _pivotMatrix;
  64844. private _pivotMatrixInverse;
  64845. protected _postMultiplyPivotMatrix: boolean;
  64846. protected _isWorldMatrixFrozen: boolean;
  64847. /** @hidden */
  64848. _indexInSceneTransformNodesArray: number;
  64849. /**
  64850. * An event triggered after the world matrix is updated
  64851. */
  64852. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  64853. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  64854. /**
  64855. * Gets a string identifying the name of the class
  64856. * @returns "TransformNode" string
  64857. */
  64858. getClassName(): string;
  64859. /**
  64860. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  64861. */
  64862. position: Vector3;
  64863. /**
  64864. * 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)).
  64865. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  64866. */
  64867. rotation: Vector3;
  64868. /**
  64869. * 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)).
  64870. */
  64871. scaling: Vector3;
  64872. /**
  64873. * 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).
  64874. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  64875. */
  64876. rotationQuaternion: Nullable<Quaternion>;
  64877. /**
  64878. * The forward direction of that transform in world space.
  64879. */
  64880. readonly forward: Vector3;
  64881. /**
  64882. * The up direction of that transform in world space.
  64883. */
  64884. readonly up: Vector3;
  64885. /**
  64886. * The right direction of that transform in world space.
  64887. */
  64888. readonly right: Vector3;
  64889. /**
  64890. * Copies the parameter passed Matrix into the mesh Pose matrix.
  64891. * @param matrix the matrix to copy the pose from
  64892. * @returns this TransformNode.
  64893. */
  64894. updatePoseMatrix(matrix: Matrix): TransformNode;
  64895. /**
  64896. * Returns the mesh Pose matrix.
  64897. * @returns the pose matrix
  64898. */
  64899. getPoseMatrix(): Matrix;
  64900. /** @hidden */
  64901. _isSynchronized(): boolean;
  64902. /** @hidden */
  64903. _initCache(): void;
  64904. /**
  64905. * Flag the transform node as dirty (Forcing it to update everything)
  64906. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  64907. * @returns this transform node
  64908. */
  64909. markAsDirty(property: string): TransformNode;
  64910. /**
  64911. * Returns the current mesh absolute position.
  64912. * Returns a Vector3.
  64913. */
  64914. readonly absolutePosition: Vector3;
  64915. /**
  64916. * Sets a new matrix to apply before all other transformation
  64917. * @param matrix defines the transform matrix
  64918. * @returns the current TransformNode
  64919. */
  64920. setPreTransformMatrix(matrix: Matrix): TransformNode;
  64921. /**
  64922. * Sets a new pivot matrix to the current node
  64923. * @param matrix defines the new pivot matrix to use
  64924. * @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
  64925. * @returns the current TransformNode
  64926. */
  64927. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  64928. /**
  64929. * Returns the mesh pivot matrix.
  64930. * Default : Identity.
  64931. * @returns the matrix
  64932. */
  64933. getPivotMatrix(): Matrix;
  64934. /**
  64935. * Prevents the World matrix to be computed any longer.
  64936. * @returns the TransformNode.
  64937. */
  64938. freezeWorldMatrix(): TransformNode;
  64939. /**
  64940. * Allows back the World matrix computation.
  64941. * @returns the TransformNode.
  64942. */
  64943. unfreezeWorldMatrix(): this;
  64944. /**
  64945. * True if the World matrix has been frozen.
  64946. */
  64947. readonly isWorldMatrixFrozen: boolean;
  64948. /**
  64949. * Retuns the mesh absolute position in the World.
  64950. * @returns a Vector3.
  64951. */
  64952. getAbsolutePosition(): Vector3;
  64953. /**
  64954. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  64955. * @param absolutePosition the absolute position to set
  64956. * @returns the TransformNode.
  64957. */
  64958. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  64959. /**
  64960. * Sets the mesh position in its local space.
  64961. * @param vector3 the position to set in localspace
  64962. * @returns the TransformNode.
  64963. */
  64964. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  64965. /**
  64966. * Returns the mesh position in the local space from the current World matrix values.
  64967. * @returns a new Vector3.
  64968. */
  64969. getPositionExpressedInLocalSpace(): Vector3;
  64970. /**
  64971. * Translates the mesh along the passed Vector3 in its local space.
  64972. * @param vector3 the distance to translate in localspace
  64973. * @returns the TransformNode.
  64974. */
  64975. locallyTranslate(vector3: Vector3): TransformNode;
  64976. private static _lookAtVectorCache;
  64977. /**
  64978. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  64979. * @param targetPoint the position (must be in same space as current mesh) to look at
  64980. * @param yawCor optional yaw (y-axis) correction in radians
  64981. * @param pitchCor optional pitch (x-axis) correction in radians
  64982. * @param rollCor optional roll (z-axis) correction in radians
  64983. * @param space the choosen space of the target
  64984. * @returns the TransformNode.
  64985. */
  64986. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  64987. /**
  64988. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  64989. * This Vector3 is expressed in the World space.
  64990. * @param localAxis axis to rotate
  64991. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  64992. */
  64993. getDirection(localAxis: Vector3): Vector3;
  64994. /**
  64995. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  64996. * localAxis is expressed in the mesh local space.
  64997. * result is computed in the Wordl space from the mesh World matrix.
  64998. * @param localAxis axis to rotate
  64999. * @param result the resulting transformnode
  65000. * @returns this TransformNode.
  65001. */
  65002. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65003. /**
  65004. * Sets this transform node rotation to the given local axis.
  65005. * @param localAxis the axis in local space
  65006. * @param yawCor optional yaw (y-axis) correction in radians
  65007. * @param pitchCor optional pitch (x-axis) correction in radians
  65008. * @param rollCor optional roll (z-axis) correction in radians
  65009. * @returns this TransformNode
  65010. */
  65011. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65012. /**
  65013. * Sets a new pivot point to the current node
  65014. * @param point defines the new pivot point to use
  65015. * @param space defines if the point is in world or local space (local by default)
  65016. * @returns the current TransformNode
  65017. */
  65018. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65019. /**
  65020. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65021. * @returns the pivot point
  65022. */
  65023. getPivotPoint(): Vector3;
  65024. /**
  65025. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65026. * @param result the vector3 to store the result
  65027. * @returns this TransformNode.
  65028. */
  65029. getPivotPointToRef(result: Vector3): TransformNode;
  65030. /**
  65031. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65032. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65033. */
  65034. getAbsolutePivotPoint(): Vector3;
  65035. /**
  65036. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65037. * @param result vector3 to store the result
  65038. * @returns this TransformNode.
  65039. */
  65040. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65041. /**
  65042. * Defines the passed node as the parent of the current node.
  65043. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65044. * @param node the node ot set as the parent
  65045. * @returns this TransformNode.
  65046. */
  65047. setParent(node: Nullable<Node>): TransformNode;
  65048. private _nonUniformScaling;
  65049. /**
  65050. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65051. */
  65052. readonly nonUniformScaling: boolean;
  65053. /** @hidden */
  65054. _updateNonUniformScalingState(value: boolean): boolean;
  65055. /**
  65056. * Attach the current TransformNode to another TransformNode associated with a bone
  65057. * @param bone Bone affecting the TransformNode
  65058. * @param affectedTransformNode TransformNode associated with the bone
  65059. * @returns this object
  65060. */
  65061. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65062. /**
  65063. * Detach the transform node if its associated with a bone
  65064. * @returns this object
  65065. */
  65066. detachFromBone(): TransformNode;
  65067. private static _rotationAxisCache;
  65068. /**
  65069. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65070. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65071. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65072. * The passed axis is also normalized.
  65073. * @param axis the axis to rotate around
  65074. * @param amount the amount to rotate in radians
  65075. * @param space Space to rotate in (Default: local)
  65076. * @returns the TransformNode.
  65077. */
  65078. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65079. /**
  65080. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65081. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65082. * The passed axis is also normalized. .
  65083. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65084. * @param point the point to rotate around
  65085. * @param axis the axis to rotate around
  65086. * @param amount the amount to rotate in radians
  65087. * @returns the TransformNode
  65088. */
  65089. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65090. /**
  65091. * Translates the mesh along the axis vector for the passed distance in the given space.
  65092. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65093. * @param axis the axis to translate in
  65094. * @param distance the distance to translate
  65095. * @param space Space to rotate in (Default: local)
  65096. * @returns the TransformNode.
  65097. */
  65098. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65099. /**
  65100. * Adds a rotation step to the mesh current rotation.
  65101. * x, y, z are Euler angles expressed in radians.
  65102. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65103. * This means this rotation is made in the mesh local space only.
  65104. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65105. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65106. * ```javascript
  65107. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65108. * ```
  65109. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65110. * 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.
  65111. * @param x Rotation to add
  65112. * @param y Rotation to add
  65113. * @param z Rotation to add
  65114. * @returns the TransformNode.
  65115. */
  65116. addRotation(x: number, y: number, z: number): TransformNode;
  65117. /**
  65118. * Computes the world matrix of the node
  65119. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65120. * @returns the world matrix
  65121. */
  65122. computeWorldMatrix(force?: boolean): Matrix;
  65123. protected _afterComputeWorldMatrix(): void;
  65124. /**
  65125. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65126. * @param func callback function to add
  65127. *
  65128. * @returns the TransformNode.
  65129. */
  65130. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65131. /**
  65132. * Removes a registered callback function.
  65133. * @param func callback function to remove
  65134. * @returns the TransformNode.
  65135. */
  65136. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65137. /**
  65138. * Gets the position of the current mesh in camera space
  65139. * @param camera defines the camera to use
  65140. * @returns a position
  65141. */
  65142. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65143. /**
  65144. * Returns the distance from the mesh to the active camera
  65145. * @param camera defines the camera to use
  65146. * @returns the distance
  65147. */
  65148. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65149. /**
  65150. * Clone the current transform node
  65151. * @param name Name of the new clone
  65152. * @param newParent New parent for the clone
  65153. * @param doNotCloneChildren Do not clone children hierarchy
  65154. * @returns the new transform node
  65155. */
  65156. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65157. /**
  65158. * Serializes the objects information.
  65159. * @param currentSerializationObject defines the object to serialize in
  65160. * @returns the serialized object
  65161. */
  65162. serialize(currentSerializationObject?: any): any;
  65163. /**
  65164. * Returns a new TransformNode object parsed from the source provided.
  65165. * @param parsedTransformNode is the source.
  65166. * @param scene the scne the object belongs to
  65167. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65168. * @returns a new TransformNode object parsed from the source provided.
  65169. */
  65170. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65171. /**
  65172. * Get all child-transformNodes of this node
  65173. * @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
  65174. * @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
  65175. * @returns an array of TransformNode
  65176. */
  65177. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65178. /**
  65179. * Releases resources associated with this transform node.
  65180. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65181. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65182. */
  65183. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65184. }
  65185. }
  65186. declare module BABYLON {
  65187. /**
  65188. * Class used to override all child animations of a given target
  65189. */
  65190. export class AnimationPropertiesOverride {
  65191. /**
  65192. * Gets or sets a value indicating if animation blending must be used
  65193. */
  65194. enableBlending: boolean;
  65195. /**
  65196. * Gets or sets the blending speed to use when enableBlending is true
  65197. */
  65198. blendingSpeed: number;
  65199. /**
  65200. * Gets or sets the default loop mode to use
  65201. */
  65202. loopMode: number;
  65203. }
  65204. }
  65205. declare module BABYLON {
  65206. /**
  65207. * Class used to store bone information
  65208. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65209. */
  65210. export class Bone extends Node {
  65211. /**
  65212. * defines the bone name
  65213. */
  65214. name: string;
  65215. private static _tmpVecs;
  65216. private static _tmpQuat;
  65217. private static _tmpMats;
  65218. /**
  65219. * Gets the list of child bones
  65220. */
  65221. children: Bone[];
  65222. /** Gets the animations associated with this bone */
  65223. animations: Animation[];
  65224. /**
  65225. * Gets or sets bone length
  65226. */
  65227. length: number;
  65228. /**
  65229. * @hidden Internal only
  65230. * Set this value to map this bone to a different index in the transform matrices
  65231. * Set this value to -1 to exclude the bone from the transform matrices
  65232. */
  65233. _index: Nullable<number>;
  65234. private _skeleton;
  65235. private _localMatrix;
  65236. private _restPose;
  65237. private _baseMatrix;
  65238. private _absoluteTransform;
  65239. private _invertedAbsoluteTransform;
  65240. private _parent;
  65241. private _scalingDeterminant;
  65242. private _worldTransform;
  65243. private _localScaling;
  65244. private _localRotation;
  65245. private _localPosition;
  65246. private _needToDecompose;
  65247. private _needToCompose;
  65248. /** @hidden */
  65249. _linkedTransformNode: Nullable<TransformNode>;
  65250. /** @hidden */
  65251. /** @hidden */
  65252. _matrix: Matrix;
  65253. /**
  65254. * Create a new bone
  65255. * @param name defines the bone name
  65256. * @param skeleton defines the parent skeleton
  65257. * @param parentBone defines the parent (can be null if the bone is the root)
  65258. * @param localMatrix defines the local matrix
  65259. * @param restPose defines the rest pose matrix
  65260. * @param baseMatrix defines the base matrix
  65261. * @param index defines index of the bone in the hiearchy
  65262. */
  65263. constructor(
  65264. /**
  65265. * defines the bone name
  65266. */
  65267. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65268. /**
  65269. * Gets the current object class name.
  65270. * @return the class name
  65271. */
  65272. getClassName(): string;
  65273. /**
  65274. * Gets the parent skeleton
  65275. * @returns a skeleton
  65276. */
  65277. getSkeleton(): Skeleton;
  65278. /**
  65279. * Gets parent bone
  65280. * @returns a bone or null if the bone is the root of the bone hierarchy
  65281. */
  65282. getParent(): Nullable<Bone>;
  65283. /**
  65284. * Returns an array containing the root bones
  65285. * @returns an array containing the root bones
  65286. */
  65287. getChildren(): Array<Bone>;
  65288. /**
  65289. * Sets the parent bone
  65290. * @param parent defines the parent (can be null if the bone is the root)
  65291. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65292. */
  65293. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65294. /**
  65295. * Gets the local matrix
  65296. * @returns a matrix
  65297. */
  65298. getLocalMatrix(): Matrix;
  65299. /**
  65300. * Gets the base matrix (initial matrix which remains unchanged)
  65301. * @returns a matrix
  65302. */
  65303. getBaseMatrix(): Matrix;
  65304. /**
  65305. * Gets the rest pose matrix
  65306. * @returns a matrix
  65307. */
  65308. getRestPose(): Matrix;
  65309. /**
  65310. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65311. */
  65312. getWorldMatrix(): Matrix;
  65313. /**
  65314. * Sets the local matrix to rest pose matrix
  65315. */
  65316. returnToRest(): void;
  65317. /**
  65318. * Gets the inverse of the absolute transform matrix.
  65319. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65320. * @returns a matrix
  65321. */
  65322. getInvertedAbsoluteTransform(): Matrix;
  65323. /**
  65324. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65325. * @returns a matrix
  65326. */
  65327. getAbsoluteTransform(): Matrix;
  65328. /**
  65329. * Links with the given transform node.
  65330. * The local matrix of this bone is copied from the transform node every frame.
  65331. * @param transformNode defines the transform node to link to
  65332. */
  65333. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65334. /** Gets or sets current position (in local space) */
  65335. position: Vector3;
  65336. /** Gets or sets current rotation (in local space) */
  65337. rotation: Vector3;
  65338. /** Gets or sets current rotation quaternion (in local space) */
  65339. rotationQuaternion: Quaternion;
  65340. /** Gets or sets current scaling (in local space) */
  65341. scaling: Vector3;
  65342. /**
  65343. * Gets the animation properties override
  65344. */
  65345. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65346. private _decompose;
  65347. private _compose;
  65348. /**
  65349. * Update the base and local matrices
  65350. * @param matrix defines the new base or local matrix
  65351. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65352. * @param updateLocalMatrix defines if the local matrix should be updated
  65353. */
  65354. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65355. /** @hidden */
  65356. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65357. /**
  65358. * Flag the bone as dirty (Forcing it to update everything)
  65359. */
  65360. markAsDirty(): void;
  65361. private _markAsDirtyAndCompose;
  65362. private _markAsDirtyAndDecompose;
  65363. /**
  65364. * Translate the bone in local or world space
  65365. * @param vec The amount to translate the bone
  65366. * @param space The space that the translation is in
  65367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65368. */
  65369. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65370. /**
  65371. * Set the postion of the bone in local or world space
  65372. * @param position The position to set the bone
  65373. * @param space The space that the position is in
  65374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65375. */
  65376. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65377. /**
  65378. * Set the absolute position of the bone (world space)
  65379. * @param position The position to set the bone
  65380. * @param mesh The mesh that this bone is attached to
  65381. */
  65382. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65383. /**
  65384. * Scale the bone on the x, y and z axes (in local space)
  65385. * @param x The amount to scale the bone on the x axis
  65386. * @param y The amount to scale the bone on the y axis
  65387. * @param z The amount to scale the bone on the z axis
  65388. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65389. */
  65390. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65391. /**
  65392. * Set the bone scaling in local space
  65393. * @param scale defines the scaling vector
  65394. */
  65395. setScale(scale: Vector3): void;
  65396. /**
  65397. * Gets the current scaling in local space
  65398. * @returns the current scaling vector
  65399. */
  65400. getScale(): Vector3;
  65401. /**
  65402. * Gets the current scaling in local space and stores it in a target vector
  65403. * @param result defines the target vector
  65404. */
  65405. getScaleToRef(result: Vector3): void;
  65406. /**
  65407. * Set the yaw, pitch, and roll of the bone in local or world space
  65408. * @param yaw The rotation of the bone on the y axis
  65409. * @param pitch The rotation of the bone on the x axis
  65410. * @param roll The rotation of the bone on the z axis
  65411. * @param space The space that the axes of rotation are in
  65412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65413. */
  65414. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65415. /**
  65416. * Add a rotation to the bone on an axis in local or world space
  65417. * @param axis The axis to rotate the bone on
  65418. * @param amount The amount to rotate the bone
  65419. * @param space The space that the axis is in
  65420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65421. */
  65422. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65423. /**
  65424. * Set the rotation of the bone to a particular axis angle in local or world space
  65425. * @param axis The axis to rotate the bone on
  65426. * @param angle The angle that the bone should be rotated to
  65427. * @param space The space that the axis is in
  65428. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65429. */
  65430. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65431. /**
  65432. * Set the euler rotation of the bone in local of world space
  65433. * @param rotation The euler rotation that the bone should be set to
  65434. * @param space The space that the rotation is in
  65435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65436. */
  65437. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65438. /**
  65439. * Set the quaternion rotation of the bone in local of world space
  65440. * @param quat The quaternion rotation that the bone should be set to
  65441. * @param space The space that the rotation is in
  65442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65443. */
  65444. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65445. /**
  65446. * Set the rotation matrix of the bone in local of world space
  65447. * @param rotMat The rotation matrix that the bone should be set to
  65448. * @param space The space that the rotation is in
  65449. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65450. */
  65451. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65452. private _rotateWithMatrix;
  65453. private _getNegativeRotationToRef;
  65454. /**
  65455. * Get the position of the bone in local or world space
  65456. * @param space The space that the returned position is in
  65457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65458. * @returns The position of the bone
  65459. */
  65460. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65461. /**
  65462. * Copy the position of the bone to a vector3 in local or world space
  65463. * @param space The space that the returned position is in
  65464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65465. * @param result The vector3 to copy the position to
  65466. */
  65467. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65468. /**
  65469. * Get the absolute position of the bone (world space)
  65470. * @param mesh The mesh that this bone is attached to
  65471. * @returns The absolute position of the bone
  65472. */
  65473. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65474. /**
  65475. * Copy the absolute position of the bone (world space) to the result param
  65476. * @param mesh The mesh that this bone is attached to
  65477. * @param result The vector3 to copy the absolute position to
  65478. */
  65479. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65480. /**
  65481. * Compute the absolute transforms of this bone and its children
  65482. */
  65483. computeAbsoluteTransforms(): void;
  65484. /**
  65485. * Get the world direction from an axis that is in the local space of the bone
  65486. * @param localAxis The local direction that is used to compute the world direction
  65487. * @param mesh The mesh that this bone is attached to
  65488. * @returns The world direction
  65489. */
  65490. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65491. /**
  65492. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65493. * @param localAxis The local direction that is used to compute the world direction
  65494. * @param mesh The mesh that this bone is attached to
  65495. * @param result The vector3 that the world direction will be copied to
  65496. */
  65497. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65498. /**
  65499. * Get the euler rotation of the bone in local or world space
  65500. * @param space The space that the rotation should be in
  65501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65502. * @returns The euler rotation
  65503. */
  65504. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65505. /**
  65506. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65507. * @param space The space that the rotation should be in
  65508. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65509. * @param result The vector3 that the rotation should be copied to
  65510. */
  65511. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65512. /**
  65513. * Get the quaternion rotation of the bone in either local or world space
  65514. * @param space The space that the rotation should be in
  65515. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65516. * @returns The quaternion rotation
  65517. */
  65518. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65519. /**
  65520. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65521. * @param space The space that the rotation should be in
  65522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65523. * @param result The quaternion that the rotation should be copied to
  65524. */
  65525. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65526. /**
  65527. * Get the rotation matrix of the bone in local or world space
  65528. * @param space The space that the rotation should be in
  65529. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65530. * @returns The rotation matrix
  65531. */
  65532. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65533. /**
  65534. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65535. * @param space The space that the rotation should be in
  65536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65537. * @param result The quaternion that the rotation should be copied to
  65538. */
  65539. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65540. /**
  65541. * Get the world position of a point that is in the local space of the bone
  65542. * @param position The local position
  65543. * @param mesh The mesh that this bone is attached to
  65544. * @returns The world position
  65545. */
  65546. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65547. /**
  65548. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65549. * @param position The local position
  65550. * @param mesh The mesh that this bone is attached to
  65551. * @param result The vector3 that the world position should be copied to
  65552. */
  65553. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65554. /**
  65555. * Get the local position of a point that is in world space
  65556. * @param position The world position
  65557. * @param mesh The mesh that this bone is attached to
  65558. * @returns The local position
  65559. */
  65560. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65561. /**
  65562. * Get the local position of a point that is in world space and copy it to the result param
  65563. * @param position The world position
  65564. * @param mesh The mesh that this bone is attached to
  65565. * @param result The vector3 that the local position should be copied to
  65566. */
  65567. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65568. }
  65569. }
  65570. declare module BABYLON {
  65571. /**
  65572. * Class for creating a cube texture
  65573. */
  65574. export class CubeTexture extends BaseTexture {
  65575. private _delayedOnLoad;
  65576. /**
  65577. * The url of the texture
  65578. */
  65579. url: string;
  65580. /**
  65581. * Gets or sets the center of the bounding box associated with the cube texture.
  65582. * It must define where the camera used to render the texture was set
  65583. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65584. */
  65585. boundingBoxPosition: Vector3;
  65586. private _boundingBoxSize;
  65587. /**
  65588. * Gets or sets the size of the bounding box associated with the cube texture
  65589. * When defined, the cubemap will switch to local mode
  65590. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65591. * @example https://www.babylonjs-playground.com/#RNASML
  65592. */
  65593. /**
  65594. * Returns the bounding box size
  65595. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65596. */
  65597. boundingBoxSize: Vector3;
  65598. protected _rotationY: number;
  65599. /**
  65600. * Sets texture matrix rotation angle around Y axis in radians.
  65601. */
  65602. /**
  65603. * Gets texture matrix rotation angle around Y axis radians.
  65604. */
  65605. rotationY: number;
  65606. /**
  65607. * Are mip maps generated for this texture or not.
  65608. */
  65609. readonly noMipmap: boolean;
  65610. private _noMipmap;
  65611. private _files;
  65612. private _extensions;
  65613. private _textureMatrix;
  65614. private _format;
  65615. private _createPolynomials;
  65616. /** @hidden */
  65617. _prefiltered: boolean;
  65618. /**
  65619. * Creates a cube texture from an array of image urls
  65620. * @param files defines an array of image urls
  65621. * @param scene defines the hosting scene
  65622. * @param noMipmap specifies if mip maps are not used
  65623. * @returns a cube texture
  65624. */
  65625. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65626. /**
  65627. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65628. * @param url defines the url of the prefiltered texture
  65629. * @param scene defines the scene the texture is attached to
  65630. * @param forcedExtension defines the extension of the file if different from the url
  65631. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65632. * @return the prefiltered texture
  65633. */
  65634. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65635. /**
  65636. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65637. * as prefiltered data.
  65638. * @param rootUrl defines the url of the texture or the root name of the six images
  65639. * @param scene defines the scene the texture is attached to
  65640. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65641. * @param noMipmap defines if mipmaps should be created or not
  65642. * @param files defines the six files to load for the different faces
  65643. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65644. * @param onError defines a callback triggered in case of error during load
  65645. * @param format defines the internal format to use for the texture once loaded
  65646. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65647. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65648. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65649. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65650. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65651. * @return the cube texture
  65652. */
  65653. 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);
  65654. /**
  65655. * Get the current class name of the texture useful for serialization or dynamic coding.
  65656. * @returns "CubeTexture"
  65657. */
  65658. getClassName(): string;
  65659. /**
  65660. * Update the url (and optional buffer) of this texture if url was null during construction.
  65661. * @param url the url of the texture
  65662. * @param forcedExtension defines the extension to use
  65663. * @param onLoad callback called when the texture is loaded (defaults to null)
  65664. */
  65665. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65666. /**
  65667. * Delays loading of the cube texture
  65668. * @param forcedExtension defines the extension to use
  65669. */
  65670. delayLoad(forcedExtension?: string): void;
  65671. /**
  65672. * Returns the reflection texture matrix
  65673. * @returns the reflection texture matrix
  65674. */
  65675. getReflectionTextureMatrix(): Matrix;
  65676. /**
  65677. * Sets the reflection texture matrix
  65678. * @param value Reflection texture matrix
  65679. */
  65680. setReflectionTextureMatrix(value: Matrix): void;
  65681. /**
  65682. * Parses text to create a cube texture
  65683. * @param parsedTexture define the serialized text to read from
  65684. * @param scene defines the hosting scene
  65685. * @param rootUrl defines the root url of the cube texture
  65686. * @returns a cube texture
  65687. */
  65688. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65689. /**
  65690. * Makes a clone, or deep copy, of the cube texture
  65691. * @returns a new cube texture
  65692. */
  65693. clone(): CubeTexture;
  65694. }
  65695. }
  65696. declare module BABYLON {
  65697. /** @hidden */
  65698. export var postprocessVertexShader: {
  65699. name: string;
  65700. shader: string;
  65701. };
  65702. }
  65703. declare module BABYLON {
  65704. /**
  65705. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  65706. * This is the base of the follow, arc rotate cameras and Free camera
  65707. * @see http://doc.babylonjs.com/features/cameras
  65708. */
  65709. export class TargetCamera extends Camera {
  65710. private static _RigCamTransformMatrix;
  65711. private static _TargetTransformMatrix;
  65712. private static _TargetFocalPoint;
  65713. /**
  65714. * Define the current direction the camera is moving to
  65715. */
  65716. cameraDirection: Vector3;
  65717. /**
  65718. * Define the current rotation the camera is rotating to
  65719. */
  65720. cameraRotation: Vector2;
  65721. /**
  65722. * When set, the up vector of the camera will be updated by the rotation of the camera
  65723. */
  65724. updateUpVectorFromRotation: boolean;
  65725. private _tmpQuaternion;
  65726. /**
  65727. * Define the current rotation of the camera
  65728. */
  65729. rotation: Vector3;
  65730. /**
  65731. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  65732. */
  65733. rotationQuaternion: Quaternion;
  65734. /**
  65735. * Define the current speed of the camera
  65736. */
  65737. speed: number;
  65738. /**
  65739. * Add cconstraint to the camera to prevent it to move freely in all directions and
  65740. * around all axis.
  65741. */
  65742. noRotationConstraint: boolean;
  65743. /**
  65744. * Define the current target of the camera as an object or a position.
  65745. */
  65746. lockedTarget: any;
  65747. /** @hidden */
  65748. _currentTarget: Vector3;
  65749. /** @hidden */
  65750. _initialFocalDistance: number;
  65751. /** @hidden */
  65752. _viewMatrix: Matrix;
  65753. /** @hidden */
  65754. _camMatrix: Matrix;
  65755. /** @hidden */
  65756. _cameraTransformMatrix: Matrix;
  65757. /** @hidden */
  65758. _cameraRotationMatrix: Matrix;
  65759. /** @hidden */
  65760. _referencePoint: Vector3;
  65761. /** @hidden */
  65762. _transformedReferencePoint: Vector3;
  65763. protected _globalCurrentTarget: Vector3;
  65764. protected _globalCurrentUpVector: Vector3;
  65765. /** @hidden */
  65766. _reset: () => void;
  65767. private _defaultUp;
  65768. /**
  65769. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  65770. * This is the base of the follow, arc rotate cameras and Free camera
  65771. * @see http://doc.babylonjs.com/features/cameras
  65772. * @param name Defines the name of the camera in the scene
  65773. * @param position Defines the start position of the camera in the scene
  65774. * @param scene Defines the scene the camera belongs to
  65775. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  65776. */
  65777. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  65778. /**
  65779. * Gets the position in front of the camera at a given distance.
  65780. * @param distance The distance from the camera we want the position to be
  65781. * @returns the position
  65782. */
  65783. getFrontPosition(distance: number): Vector3;
  65784. /** @hidden */
  65785. _getLockedTargetPosition(): Nullable<Vector3>;
  65786. private _storedPosition;
  65787. private _storedRotation;
  65788. private _storedRotationQuaternion;
  65789. /**
  65790. * Store current camera state of the camera (fov, position, rotation, etc..)
  65791. * @returns the camera
  65792. */
  65793. storeState(): Camera;
  65794. /**
  65795. * Restored camera state. You must call storeState() first
  65796. * @returns whether it was successful or not
  65797. * @hidden
  65798. */
  65799. _restoreStateValues(): boolean;
  65800. /** @hidden */
  65801. _initCache(): void;
  65802. /** @hidden */
  65803. _updateCache(ignoreParentClass?: boolean): void;
  65804. /** @hidden */
  65805. _isSynchronizedViewMatrix(): boolean;
  65806. /** @hidden */
  65807. _computeLocalCameraSpeed(): number;
  65808. /**
  65809. * Defines the target the camera should look at.
  65810. * This will automatically adapt alpha beta and radius to fit within the new target.
  65811. * @param target Defines the new target as a Vector or a mesh
  65812. */
  65813. setTarget(target: Vector3): void;
  65814. /**
  65815. * Return the current target position of the camera. This value is expressed in local space.
  65816. * @returns the target position
  65817. */
  65818. getTarget(): Vector3;
  65819. /** @hidden */
  65820. _decideIfNeedsToMove(): boolean;
  65821. /** @hidden */
  65822. _updatePosition(): void;
  65823. /** @hidden */
  65824. _checkInputs(): void;
  65825. protected _updateCameraRotationMatrix(): void;
  65826. /**
  65827. * 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)
  65828. * @returns the current camera
  65829. */
  65830. private _rotateUpVectorWithCameraRotationMatrix;
  65831. private _cachedRotationZ;
  65832. private _cachedQuaternionRotationZ;
  65833. /** @hidden */
  65834. _getViewMatrix(): Matrix;
  65835. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  65836. /**
  65837. * @hidden
  65838. */
  65839. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  65840. /**
  65841. * @hidden
  65842. */
  65843. _updateRigCameras(): void;
  65844. private _getRigCamPositionAndTarget;
  65845. /**
  65846. * Gets the current object class name.
  65847. * @return the class name
  65848. */
  65849. getClassName(): string;
  65850. }
  65851. }
  65852. declare module BABYLON {
  65853. /**
  65854. * @ignore
  65855. * This is a list of all the different input types that are available in the application.
  65856. * Fo instance: ArcRotateCameraGamepadInput...
  65857. */
  65858. export var CameraInputTypes: {};
  65859. /**
  65860. * This is the contract to implement in order to create a new input class.
  65861. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  65862. */
  65863. export interface ICameraInput<TCamera extends Camera> {
  65864. /**
  65865. * Defines the camera the input is attached to.
  65866. */
  65867. camera: Nullable<TCamera>;
  65868. /**
  65869. * Gets the class name of the current intput.
  65870. * @returns the class name
  65871. */
  65872. getClassName(): string;
  65873. /**
  65874. * Get the friendly name associated with the input class.
  65875. * @returns the input friendly name
  65876. */
  65877. getSimpleName(): string;
  65878. /**
  65879. * Attach the input controls to a specific dom element to get the input from.
  65880. * @param element Defines the element the controls should be listened from
  65881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65882. */
  65883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  65884. /**
  65885. * Detach the current controls from the specified dom element.
  65886. * @param element Defines the element to stop listening the inputs from
  65887. */
  65888. detachControl(element: Nullable<HTMLElement>): void;
  65889. /**
  65890. * Update the current camera state depending on the inputs that have been used this frame.
  65891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65892. */
  65893. checkInputs?: () => void;
  65894. }
  65895. /**
  65896. * Represents a map of input types to input instance or input index to input instance.
  65897. */
  65898. export interface CameraInputsMap<TCamera extends Camera> {
  65899. /**
  65900. * Accessor to the input by input type.
  65901. */
  65902. [name: string]: ICameraInput<TCamera>;
  65903. /**
  65904. * Accessor to the input by input index.
  65905. */
  65906. [idx: number]: ICameraInput<TCamera>;
  65907. }
  65908. /**
  65909. * This represents the input manager used within a camera.
  65910. * It helps dealing with all the different kind of input attached to a camera.
  65911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65912. */
  65913. export class CameraInputsManager<TCamera extends Camera> {
  65914. /**
  65915. * Defines the list of inputs attahed to the camera.
  65916. */
  65917. attached: CameraInputsMap<TCamera>;
  65918. /**
  65919. * Defines the dom element the camera is collecting inputs from.
  65920. * This is null if the controls have not been attached.
  65921. */
  65922. attachedElement: Nullable<HTMLElement>;
  65923. /**
  65924. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65925. */
  65926. noPreventDefault: boolean;
  65927. /**
  65928. * Defined the camera the input manager belongs to.
  65929. */
  65930. camera: TCamera;
  65931. /**
  65932. * Update the current camera state depending on the inputs that have been used this frame.
  65933. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65934. */
  65935. checkInputs: () => void;
  65936. /**
  65937. * Instantiate a new Camera Input Manager.
  65938. * @param camera Defines the camera the input manager blongs to
  65939. */
  65940. constructor(camera: TCamera);
  65941. /**
  65942. * Add an input method to a camera
  65943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65944. * @param input camera input method
  65945. */
  65946. add(input: ICameraInput<TCamera>): void;
  65947. /**
  65948. * Remove a specific input method from a camera
  65949. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  65950. * @param inputToRemove camera input method
  65951. */
  65952. remove(inputToRemove: ICameraInput<TCamera>): void;
  65953. /**
  65954. * Remove a specific input type from a camera
  65955. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  65956. * @param inputType the type of the input to remove
  65957. */
  65958. removeByType(inputType: string): void;
  65959. private _addCheckInputs;
  65960. /**
  65961. * Attach the input controls to the currently attached dom element to listen the events from.
  65962. * @param input Defines the input to attach
  65963. */
  65964. attachInput(input: ICameraInput<TCamera>): void;
  65965. /**
  65966. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  65967. * @param element Defines the dom element to collect the events from
  65968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65969. */
  65970. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  65971. /**
  65972. * Detach the current manager inputs controls from a specific dom element.
  65973. * @param element Defines the dom element to collect the events from
  65974. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  65975. */
  65976. detachElement(element: HTMLElement, disconnect?: boolean): void;
  65977. /**
  65978. * Rebuild the dynamic inputCheck function from the current list of
  65979. * defined inputs in the manager.
  65980. */
  65981. rebuildInputCheck(): void;
  65982. /**
  65983. * Remove all attached input methods from a camera
  65984. */
  65985. clear(): void;
  65986. /**
  65987. * Serialize the current input manager attached to a camera.
  65988. * This ensures than once parsed,
  65989. * the input associated to the camera will be identical to the current ones
  65990. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  65991. */
  65992. serialize(serializedCamera: any): void;
  65993. /**
  65994. * Parses an input manager serialized JSON to restore the previous list of inputs
  65995. * and states associated to a camera.
  65996. * @param parsedCamera Defines the JSON to parse
  65997. */
  65998. parse(parsedCamera: any): void;
  65999. }
  66000. }
  66001. declare module BABYLON {
  66002. /**
  66003. * Gather the list of keyboard event types as constants.
  66004. */
  66005. export class KeyboardEventTypes {
  66006. /**
  66007. * The keydown event is fired when a key becomes active (pressed).
  66008. */
  66009. static readonly KEYDOWN: number;
  66010. /**
  66011. * The keyup event is fired when a key has been released.
  66012. */
  66013. static readonly KEYUP: number;
  66014. }
  66015. /**
  66016. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66017. */
  66018. export class KeyboardInfo {
  66019. /**
  66020. * Defines the type of event (KeyboardEventTypes)
  66021. */
  66022. type: number;
  66023. /**
  66024. * Defines the related dom event
  66025. */
  66026. event: KeyboardEvent;
  66027. /**
  66028. * Instantiates a new keyboard info.
  66029. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66030. * @param type Defines the type of event (KeyboardEventTypes)
  66031. * @param event Defines the related dom event
  66032. */
  66033. constructor(
  66034. /**
  66035. * Defines the type of event (KeyboardEventTypes)
  66036. */
  66037. type: number,
  66038. /**
  66039. * Defines the related dom event
  66040. */
  66041. event: KeyboardEvent);
  66042. }
  66043. /**
  66044. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66045. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66046. */
  66047. export class KeyboardInfoPre extends KeyboardInfo {
  66048. /**
  66049. * Defines the type of event (KeyboardEventTypes)
  66050. */
  66051. type: number;
  66052. /**
  66053. * Defines the related dom event
  66054. */
  66055. event: KeyboardEvent;
  66056. /**
  66057. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66058. */
  66059. skipOnPointerObservable: boolean;
  66060. /**
  66061. * Instantiates a new keyboard pre info.
  66062. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66063. * @param type Defines the type of event (KeyboardEventTypes)
  66064. * @param event Defines the related dom event
  66065. */
  66066. constructor(
  66067. /**
  66068. * Defines the type of event (KeyboardEventTypes)
  66069. */
  66070. type: number,
  66071. /**
  66072. * Defines the related dom event
  66073. */
  66074. event: KeyboardEvent);
  66075. }
  66076. }
  66077. declare module BABYLON {
  66078. /**
  66079. * Manage the keyboard inputs to control the movement of a free camera.
  66080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66081. */
  66082. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66083. /**
  66084. * Defines the camera the input is attached to.
  66085. */
  66086. camera: FreeCamera;
  66087. /**
  66088. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66089. */
  66090. keysUp: number[];
  66091. /**
  66092. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66093. */
  66094. keysDown: number[];
  66095. /**
  66096. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66097. */
  66098. keysLeft: number[];
  66099. /**
  66100. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66101. */
  66102. keysRight: number[];
  66103. private _keys;
  66104. private _onCanvasBlurObserver;
  66105. private _onKeyboardObserver;
  66106. private _engine;
  66107. private _scene;
  66108. /**
  66109. * Attach the input controls to a specific dom element to get the input from.
  66110. * @param element Defines the element the controls should be listened from
  66111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66112. */
  66113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66114. /**
  66115. * Detach the current controls from the specified dom element.
  66116. * @param element Defines the element to stop listening the inputs from
  66117. */
  66118. detachControl(element: Nullable<HTMLElement>): void;
  66119. /**
  66120. * Update the current camera state depending on the inputs that have been used this frame.
  66121. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66122. */
  66123. checkInputs(): void;
  66124. /**
  66125. * Gets the class name of the current intput.
  66126. * @returns the class name
  66127. */
  66128. getClassName(): string;
  66129. /** @hidden */
  66130. _onLostFocus(): void;
  66131. /**
  66132. * Get the friendly name associated with the input class.
  66133. * @returns the input friendly name
  66134. */
  66135. getSimpleName(): string;
  66136. }
  66137. }
  66138. declare module BABYLON {
  66139. /**
  66140. * Interface describing all the common properties and methods a shadow light needs to implement.
  66141. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66142. * as well as binding the different shadow properties to the effects.
  66143. */
  66144. export interface IShadowLight extends Light {
  66145. /**
  66146. * The light id in the scene (used in scene.findLighById for instance)
  66147. */
  66148. id: string;
  66149. /**
  66150. * The position the shdow will be casted from.
  66151. */
  66152. position: Vector3;
  66153. /**
  66154. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66155. */
  66156. direction: Vector3;
  66157. /**
  66158. * The transformed position. Position of the light in world space taking parenting in account.
  66159. */
  66160. transformedPosition: Vector3;
  66161. /**
  66162. * The transformed direction. Direction of the light in world space taking parenting in account.
  66163. */
  66164. transformedDirection: Vector3;
  66165. /**
  66166. * The friendly name of the light in the scene.
  66167. */
  66168. name: string;
  66169. /**
  66170. * Defines the shadow projection clipping minimum z value.
  66171. */
  66172. shadowMinZ: number;
  66173. /**
  66174. * Defines the shadow projection clipping maximum z value.
  66175. */
  66176. shadowMaxZ: number;
  66177. /**
  66178. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66179. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66180. */
  66181. computeTransformedInformation(): boolean;
  66182. /**
  66183. * Gets the scene the light belongs to.
  66184. * @returns The scene
  66185. */
  66186. getScene(): Scene;
  66187. /**
  66188. * Callback defining a custom Projection Matrix Builder.
  66189. * This can be used to override the default projection matrix computation.
  66190. */
  66191. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66192. /**
  66193. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66194. * @param matrix The materix to updated with the projection information
  66195. * @param viewMatrix The transform matrix of the light
  66196. * @param renderList The list of mesh to render in the map
  66197. * @returns The current light
  66198. */
  66199. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66200. /**
  66201. * Gets the current depth scale used in ESM.
  66202. * @returns The scale
  66203. */
  66204. getDepthScale(): number;
  66205. /**
  66206. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66207. * @returns true if a cube texture needs to be use
  66208. */
  66209. needCube(): boolean;
  66210. /**
  66211. * Detects if the projection matrix requires to be recomputed this frame.
  66212. * @returns true if it requires to be recomputed otherwise, false.
  66213. */
  66214. needProjectionMatrixCompute(): boolean;
  66215. /**
  66216. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66217. */
  66218. forceProjectionMatrixCompute(): void;
  66219. /**
  66220. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66221. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66222. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66223. */
  66224. getShadowDirection(faceIndex?: number): Vector3;
  66225. /**
  66226. * Gets the minZ used for shadow according to both the scene and the light.
  66227. * @param activeCamera The camera we are returning the min for
  66228. * @returns the depth min z
  66229. */
  66230. getDepthMinZ(activeCamera: Camera): number;
  66231. /**
  66232. * Gets the maxZ used for shadow according to both the scene and the light.
  66233. * @param activeCamera The camera we are returning the max for
  66234. * @returns the depth max z
  66235. */
  66236. getDepthMaxZ(activeCamera: Camera): number;
  66237. }
  66238. /**
  66239. * Base implementation IShadowLight
  66240. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66241. */
  66242. export abstract class ShadowLight extends Light implements IShadowLight {
  66243. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66244. protected _position: Vector3;
  66245. protected _setPosition(value: Vector3): void;
  66246. /**
  66247. * Sets the position the shadow will be casted from. Also use as the light position for both
  66248. * point and spot lights.
  66249. */
  66250. /**
  66251. * Sets the position the shadow will be casted from. Also use as the light position for both
  66252. * point and spot lights.
  66253. */
  66254. position: Vector3;
  66255. protected _direction: Vector3;
  66256. protected _setDirection(value: Vector3): void;
  66257. /**
  66258. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66259. * Also use as the light direction on spot and directional lights.
  66260. */
  66261. /**
  66262. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66263. * Also use as the light direction on spot and directional lights.
  66264. */
  66265. direction: Vector3;
  66266. private _shadowMinZ;
  66267. /**
  66268. * Gets the shadow projection clipping minimum z value.
  66269. */
  66270. /**
  66271. * Sets the shadow projection clipping minimum z value.
  66272. */
  66273. shadowMinZ: number;
  66274. private _shadowMaxZ;
  66275. /**
  66276. * Sets the shadow projection clipping maximum z value.
  66277. */
  66278. /**
  66279. * Gets the shadow projection clipping maximum z value.
  66280. */
  66281. shadowMaxZ: number;
  66282. /**
  66283. * Callback defining a custom Projection Matrix Builder.
  66284. * This can be used to override the default projection matrix computation.
  66285. */
  66286. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66287. /**
  66288. * The transformed position. Position of the light in world space taking parenting in account.
  66289. */
  66290. transformedPosition: Vector3;
  66291. /**
  66292. * The transformed direction. Direction of the light in world space taking parenting in account.
  66293. */
  66294. transformedDirection: Vector3;
  66295. private _needProjectionMatrixCompute;
  66296. /**
  66297. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66298. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66299. */
  66300. computeTransformedInformation(): boolean;
  66301. /**
  66302. * Return the depth scale used for the shadow map.
  66303. * @returns the depth scale.
  66304. */
  66305. getDepthScale(): number;
  66306. /**
  66307. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66308. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66309. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66310. */
  66311. getShadowDirection(faceIndex?: number): Vector3;
  66312. /**
  66313. * Returns the ShadowLight absolute position in the World.
  66314. * @returns the position vector in world space
  66315. */
  66316. getAbsolutePosition(): Vector3;
  66317. /**
  66318. * Sets the ShadowLight direction toward the passed target.
  66319. * @param target The point to target in local space
  66320. * @returns the updated ShadowLight direction
  66321. */
  66322. setDirectionToTarget(target: Vector3): Vector3;
  66323. /**
  66324. * Returns the light rotation in euler definition.
  66325. * @returns the x y z rotation in local space.
  66326. */
  66327. getRotation(): Vector3;
  66328. /**
  66329. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66330. * @returns true if a cube texture needs to be use
  66331. */
  66332. needCube(): boolean;
  66333. /**
  66334. * Detects if the projection matrix requires to be recomputed this frame.
  66335. * @returns true if it requires to be recomputed otherwise, false.
  66336. */
  66337. needProjectionMatrixCompute(): boolean;
  66338. /**
  66339. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66340. */
  66341. forceProjectionMatrixCompute(): void;
  66342. /** @hidden */
  66343. _initCache(): void;
  66344. /** @hidden */
  66345. _isSynchronized(): boolean;
  66346. /**
  66347. * Computes the world matrix of the node
  66348. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66349. * @returns the world matrix
  66350. */
  66351. computeWorldMatrix(force?: boolean): Matrix;
  66352. /**
  66353. * Gets the minZ used for shadow according to both the scene and the light.
  66354. * @param activeCamera The camera we are returning the min for
  66355. * @returns the depth min z
  66356. */
  66357. getDepthMinZ(activeCamera: Camera): number;
  66358. /**
  66359. * Gets the maxZ used for shadow according to both the scene and the light.
  66360. * @param activeCamera The camera we are returning the max for
  66361. * @returns the depth max z
  66362. */
  66363. getDepthMaxZ(activeCamera: Camera): number;
  66364. /**
  66365. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66366. * @param matrix The materix to updated with the projection information
  66367. * @param viewMatrix The transform matrix of the light
  66368. * @param renderList The list of mesh to render in the map
  66369. * @returns The current light
  66370. */
  66371. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66372. }
  66373. }
  66374. declare module BABYLON {
  66375. /**
  66376. * "Static Class" containing the most commonly used helper while dealing with material for
  66377. * rendering purpose.
  66378. *
  66379. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66380. *
  66381. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66382. */
  66383. export class MaterialHelper {
  66384. /**
  66385. * Bind the current view position to an effect.
  66386. * @param effect The effect to be bound
  66387. * @param scene The scene the eyes position is used from
  66388. */
  66389. static BindEyePosition(effect: Effect, scene: Scene): void;
  66390. /**
  66391. * Helps preparing the defines values about the UVs in used in the effect.
  66392. * UVs are shared as much as we can accross channels in the shaders.
  66393. * @param texture The texture we are preparing the UVs for
  66394. * @param defines The defines to update
  66395. * @param key The channel key "diffuse", "specular"... used in the shader
  66396. */
  66397. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66398. /**
  66399. * Binds a texture matrix value to its corrsponding uniform
  66400. * @param texture The texture to bind the matrix for
  66401. * @param uniformBuffer The uniform buffer receivin the data
  66402. * @param key The channel key "diffuse", "specular"... used in the shader
  66403. */
  66404. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66405. /**
  66406. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66407. * @param mesh defines the current mesh
  66408. * @param scene defines the current scene
  66409. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66410. * @param pointsCloud defines if point cloud rendering has to be turned on
  66411. * @param fogEnabled defines if fog has to be turned on
  66412. * @param alphaTest defines if alpha testing has to be turned on
  66413. * @param defines defines the current list of defines
  66414. */
  66415. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66416. /**
  66417. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66418. * @param scene defines the current scene
  66419. * @param engine defines the current engine
  66420. * @param defines specifies the list of active defines
  66421. * @param useInstances defines if instances have to be turned on
  66422. * @param useClipPlane defines if clip plane have to be turned on
  66423. */
  66424. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66425. /**
  66426. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66427. * @param mesh The mesh containing the geometry data we will draw
  66428. * @param defines The defines to update
  66429. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66430. * @param useBones Precise whether bones should be used or not (override mesh info)
  66431. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66432. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66433. * @returns false if defines are considered not dirty and have not been checked
  66434. */
  66435. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66436. /**
  66437. * Prepares the defines related to the light information passed in parameter
  66438. * @param scene The scene we are intending to draw
  66439. * @param mesh The mesh the effect is compiling for
  66440. * @param defines The defines to update
  66441. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66442. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66443. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66444. * @returns true if normals will be required for the rest of the effect
  66445. */
  66446. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66447. /**
  66448. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66449. * that won t be acctive due to defines being turned off.
  66450. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66451. * @param samplersList The samplers list
  66452. * @param defines The defines helping in the list generation
  66453. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66454. */
  66455. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66456. /**
  66457. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66458. * @param defines The defines to update while falling back
  66459. * @param fallbacks The authorized effect fallbacks
  66460. * @param maxSimultaneousLights The maximum number of lights allowed
  66461. * @param rank the current rank of the Effect
  66462. * @returns The newly affected rank
  66463. */
  66464. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66465. /**
  66466. * Prepares the list of attributes required for morph targets according to the effect defines.
  66467. * @param attribs The current list of supported attribs
  66468. * @param mesh The mesh to prepare the morph targets attributes for
  66469. * @param defines The current Defines of the effect
  66470. */
  66471. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66472. /**
  66473. * Prepares the list of attributes required for bones according to the effect defines.
  66474. * @param attribs The current list of supported attribs
  66475. * @param mesh The mesh to prepare the bones attributes for
  66476. * @param defines The current Defines of the effect
  66477. * @param fallbacks The current efffect fallback strategy
  66478. */
  66479. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66480. /**
  66481. * Prepares the list of attributes required for instances according to the effect defines.
  66482. * @param attribs The current list of supported attribs
  66483. * @param defines The current Defines of the effect
  66484. */
  66485. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66486. /**
  66487. * Binds the light shadow information to the effect for the given mesh.
  66488. * @param light The light containing the generator
  66489. * @param scene The scene the lights belongs to
  66490. * @param mesh The mesh we are binding the information to render
  66491. * @param lightIndex The light index in the effect used to render the mesh
  66492. * @param effect The effect we are binding the data to
  66493. */
  66494. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66495. /**
  66496. * Binds the light information to the effect.
  66497. * @param light The light containing the generator
  66498. * @param effect The effect we are binding the data to
  66499. * @param lightIndex The light index in the effect used to render
  66500. */
  66501. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66502. /**
  66503. * Binds the lights information from the scene to the effect for the given mesh.
  66504. * @param scene The scene the lights belongs to
  66505. * @param mesh The mesh we are binding the information to render
  66506. * @param effect The effect we are binding the data to
  66507. * @param defines The generated defines for the effect
  66508. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66509. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66510. */
  66511. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66512. private static _tempFogColor;
  66513. /**
  66514. * Binds the fog information from the scene to the effect for the given mesh.
  66515. * @param scene The scene the lights belongs to
  66516. * @param mesh The mesh we are binding the information to render
  66517. * @param effect The effect we are binding the data to
  66518. * @param linearSpace Defines if the fog effect is applied in linear space
  66519. */
  66520. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66521. /**
  66522. * Binds the bones information from the mesh to the effect.
  66523. * @param mesh The mesh we are binding the information to render
  66524. * @param effect The effect we are binding the data to
  66525. */
  66526. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66527. /**
  66528. * Binds the morph targets information from the mesh to the effect.
  66529. * @param abstractMesh The mesh we are binding the information to render
  66530. * @param effect The effect we are binding the data to
  66531. */
  66532. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66533. /**
  66534. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66535. * @param defines The generated defines used in the effect
  66536. * @param effect The effect we are binding the data to
  66537. * @param scene The scene we are willing to render with logarithmic scale for
  66538. */
  66539. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66540. /**
  66541. * Binds the clip plane information from the scene to the effect.
  66542. * @param scene The scene the clip plane information are extracted from
  66543. * @param effect The effect we are binding the data to
  66544. */
  66545. static BindClipPlane(effect: Effect, scene: Scene): void;
  66546. }
  66547. }
  66548. declare module BABYLON {
  66549. /** @hidden */
  66550. export var kernelBlurVaryingDeclaration: {
  66551. name: string;
  66552. shader: string;
  66553. };
  66554. }
  66555. declare module BABYLON {
  66556. /** @hidden */
  66557. export var kernelBlurFragment: {
  66558. name: string;
  66559. shader: string;
  66560. };
  66561. }
  66562. declare module BABYLON {
  66563. /** @hidden */
  66564. export var kernelBlurFragment2: {
  66565. name: string;
  66566. shader: string;
  66567. };
  66568. }
  66569. declare module BABYLON {
  66570. /** @hidden */
  66571. export var kernelBlurPixelShader: {
  66572. name: string;
  66573. shader: string;
  66574. };
  66575. }
  66576. declare module BABYLON {
  66577. /** @hidden */
  66578. export var kernelBlurVertex: {
  66579. name: string;
  66580. shader: string;
  66581. };
  66582. }
  66583. declare module BABYLON {
  66584. /** @hidden */
  66585. export var kernelBlurVertexShader: {
  66586. name: string;
  66587. shader: string;
  66588. };
  66589. }
  66590. declare module BABYLON {
  66591. /**
  66592. * The Blur Post Process which blurs an image based on a kernel and direction.
  66593. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  66594. */
  66595. export class BlurPostProcess extends PostProcess {
  66596. /** The direction in which to blur the image. */
  66597. direction: Vector2;
  66598. private blockCompilation;
  66599. protected _kernel: number;
  66600. protected _idealKernel: number;
  66601. protected _packedFloat: boolean;
  66602. private _staticDefines;
  66603. /**
  66604. * Sets the length in pixels of the blur sample region
  66605. */
  66606. /**
  66607. * Gets the length in pixels of the blur sample region
  66608. */
  66609. kernel: number;
  66610. /**
  66611. * Sets wether or not the blur needs to unpack/repack floats
  66612. */
  66613. /**
  66614. * Gets wether or not the blur is unpacking/repacking floats
  66615. */
  66616. packedFloat: boolean;
  66617. /**
  66618. * Creates a new instance BlurPostProcess
  66619. * @param name The name of the effect.
  66620. * @param direction The direction in which to blur the image.
  66621. * @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.
  66622. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66623. * @param camera The camera to apply the render pass to.
  66624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66625. * @param engine The engine which the post process will be applied. (default: current engine)
  66626. * @param reusable If the post process can be reused on the same frame. (default: false)
  66627. * @param textureType Type of textures used when performing the post process. (default: 0)
  66628. * @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)
  66629. */
  66630. constructor(name: string,
  66631. /** The direction in which to blur the image. */
  66632. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66633. /**
  66634. * Updates the effect with the current post process compile time values and recompiles the shader.
  66635. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66636. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66637. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66638. * @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
  66639. * @param onCompiled Called when the shader has been compiled.
  66640. * @param onError Called if there is an error when compiling a shader.
  66641. */
  66642. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66643. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66644. /**
  66645. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66646. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66647. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66648. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66649. * The gaps between physical kernels are compensated for in the weighting of the samples
  66650. * @param idealKernel Ideal blur kernel.
  66651. * @return Nearest best kernel.
  66652. */
  66653. protected _nearestBestKernel(idealKernel: number): number;
  66654. /**
  66655. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66656. * @param x The point on the Gaussian distribution to sample.
  66657. * @return the value of the Gaussian function at x.
  66658. */
  66659. protected _gaussianWeight(x: number): number;
  66660. /**
  66661. * Generates a string that can be used as a floating point number in GLSL.
  66662. * @param x Value to print.
  66663. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66664. * @return GLSL float string.
  66665. */
  66666. protected _glslFloat(x: number, decimalFigures?: number): string;
  66667. }
  66668. }
  66669. declare module BABYLON {
  66670. /** @hidden */
  66671. export var shadowMapPixelShader: {
  66672. name: string;
  66673. shader: string;
  66674. };
  66675. }
  66676. declare module BABYLON {
  66677. /** @hidden */
  66678. export var bonesDeclaration: {
  66679. name: string;
  66680. shader: string;
  66681. };
  66682. }
  66683. declare module BABYLON {
  66684. /** @hidden */
  66685. export var morphTargetsVertexGlobalDeclaration: {
  66686. name: string;
  66687. shader: string;
  66688. };
  66689. }
  66690. declare module BABYLON {
  66691. /** @hidden */
  66692. export var morphTargetsVertexDeclaration: {
  66693. name: string;
  66694. shader: string;
  66695. };
  66696. }
  66697. declare module BABYLON {
  66698. /** @hidden */
  66699. export var instancesDeclaration: {
  66700. name: string;
  66701. shader: string;
  66702. };
  66703. }
  66704. declare module BABYLON {
  66705. /** @hidden */
  66706. export var helperFunctions: {
  66707. name: string;
  66708. shader: string;
  66709. };
  66710. }
  66711. declare module BABYLON {
  66712. /** @hidden */
  66713. export var morphTargetsVertex: {
  66714. name: string;
  66715. shader: string;
  66716. };
  66717. }
  66718. declare module BABYLON {
  66719. /** @hidden */
  66720. export var instancesVertex: {
  66721. name: string;
  66722. shader: string;
  66723. };
  66724. }
  66725. declare module BABYLON {
  66726. /** @hidden */
  66727. export var bonesVertex: {
  66728. name: string;
  66729. shader: string;
  66730. };
  66731. }
  66732. declare module BABYLON {
  66733. /** @hidden */
  66734. export var shadowMapVertexShader: {
  66735. name: string;
  66736. shader: string;
  66737. };
  66738. }
  66739. declare module BABYLON {
  66740. /** @hidden */
  66741. export var depthBoxBlurPixelShader: {
  66742. name: string;
  66743. shader: string;
  66744. };
  66745. }
  66746. declare module BABYLON {
  66747. /**
  66748. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66749. */
  66750. export interface ICustomShaderOptions {
  66751. /**
  66752. * Gets or sets the custom shader name to use
  66753. */
  66754. shaderName: string;
  66755. /**
  66756. * The list of attribute names used in the shader
  66757. */
  66758. attributes?: string[];
  66759. /**
  66760. * The list of unifrom names used in the shader
  66761. */
  66762. uniforms?: string[];
  66763. /**
  66764. * The list of sampler names used in the shader
  66765. */
  66766. samplers?: string[];
  66767. /**
  66768. * The list of defines used in the shader
  66769. */
  66770. defines?: string[];
  66771. }
  66772. /**
  66773. * Interface to implement to create a shadow generator compatible with BJS.
  66774. */
  66775. export interface IShadowGenerator {
  66776. /**
  66777. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66778. * @returns The render target texture if present otherwise, null
  66779. */
  66780. getShadowMap(): Nullable<RenderTargetTexture>;
  66781. /**
  66782. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66783. * @returns The render target texture if the shadow map is present otherwise, null
  66784. */
  66785. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66786. /**
  66787. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66788. * @param subMesh The submesh we want to render in the shadow map
  66789. * @param useInstances Defines wether will draw in the map using instances
  66790. * @returns true if ready otherwise, false
  66791. */
  66792. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66793. /**
  66794. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66795. * @param defines Defines of the material we want to update
  66796. * @param lightIndex Index of the light in the enabled light list of the material
  66797. */
  66798. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  66799. /**
  66800. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66801. * defined in the generator but impacting the effect).
  66802. * It implies the unifroms available on the materials are the standard BJS ones.
  66803. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66804. * @param effect The effect we are binfing the information for
  66805. */
  66806. bindShadowLight(lightIndex: string, effect: Effect): void;
  66807. /**
  66808. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66809. * (eq to shadow prjection matrix * light transform matrix)
  66810. * @returns The transform matrix used to create the shadow map
  66811. */
  66812. getTransformMatrix(): Matrix;
  66813. /**
  66814. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66815. * Cube and 2D textures for instance.
  66816. */
  66817. recreateShadowMap(): void;
  66818. /**
  66819. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66820. * @param onCompiled Callback triggered at the and of the effects compilation
  66821. * @param options Sets of optional options forcing the compilation with different modes
  66822. */
  66823. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66824. useInstances: boolean;
  66825. }>): void;
  66826. /**
  66827. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66828. * @param options Sets of optional options forcing the compilation with different modes
  66829. * @returns A promise that resolves when the compilation completes
  66830. */
  66831. forceCompilationAsync(options?: Partial<{
  66832. useInstances: boolean;
  66833. }>): Promise<void>;
  66834. /**
  66835. * Serializes the shadow generator setup to a json object.
  66836. * @returns The serialized JSON object
  66837. */
  66838. serialize(): any;
  66839. /**
  66840. * Disposes the Shadow map and related Textures and effects.
  66841. */
  66842. dispose(): void;
  66843. }
  66844. /**
  66845. * Default implementation IShadowGenerator.
  66846. * This is the main object responsible of generating shadows in the framework.
  66847. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  66848. */
  66849. export class ShadowGenerator implements IShadowGenerator {
  66850. /**
  66851. * Shadow generator mode None: no filtering applied.
  66852. */
  66853. static readonly FILTER_NONE: number;
  66854. /**
  66855. * Shadow generator mode ESM: Exponential Shadow Mapping.
  66856. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66857. */
  66858. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  66859. /**
  66860. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  66861. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  66862. */
  66863. static readonly FILTER_POISSONSAMPLING: number;
  66864. /**
  66865. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  66866. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66867. */
  66868. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  66869. /**
  66870. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  66871. * edge artifacts on steep falloff.
  66872. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66873. */
  66874. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  66875. /**
  66876. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  66877. * edge artifacts on steep falloff.
  66878. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66879. */
  66880. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  66881. /**
  66882. * Shadow generator mode PCF: Percentage Closer Filtering
  66883. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66884. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  66885. */
  66886. static readonly FILTER_PCF: number;
  66887. /**
  66888. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  66889. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66890. * Contact Hardening
  66891. */
  66892. static readonly FILTER_PCSS: number;
  66893. /**
  66894. * Reserved for PCF and PCSS
  66895. * Highest Quality.
  66896. *
  66897. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  66898. *
  66899. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  66900. */
  66901. static readonly QUALITY_HIGH: number;
  66902. /**
  66903. * Reserved for PCF and PCSS
  66904. * Good tradeoff for quality/perf cross devices
  66905. *
  66906. * Execute PCF on a 3*3 kernel.
  66907. *
  66908. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  66909. */
  66910. static readonly QUALITY_MEDIUM: number;
  66911. /**
  66912. * Reserved for PCF and PCSS
  66913. * The lowest quality but the fastest.
  66914. *
  66915. * Execute PCF on a 1*1 kernel.
  66916. *
  66917. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  66918. */
  66919. static readonly QUALITY_LOW: number;
  66920. /** Gets or sets the custom shader name to use */
  66921. customShaderOptions: ICustomShaderOptions;
  66922. /**
  66923. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  66924. */
  66925. onBeforeShadowMapRenderObservable: Observable<Effect>;
  66926. private _bias;
  66927. /**
  66928. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  66929. */
  66930. /**
  66931. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  66932. */
  66933. bias: number;
  66934. private _normalBias;
  66935. /**
  66936. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66937. */
  66938. /**
  66939. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66940. */
  66941. normalBias: number;
  66942. private _blurBoxOffset;
  66943. /**
  66944. * Gets the blur box offset: offset applied during the blur pass.
  66945. * Only useful if useKernelBlur = false
  66946. */
  66947. /**
  66948. * Sets the blur box offset: offset applied during the blur pass.
  66949. * Only useful if useKernelBlur = false
  66950. */
  66951. blurBoxOffset: number;
  66952. private _blurScale;
  66953. /**
  66954. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  66955. * 2 means half of the size.
  66956. */
  66957. /**
  66958. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  66959. * 2 means half of the size.
  66960. */
  66961. blurScale: number;
  66962. private _blurKernel;
  66963. /**
  66964. * Gets the blur kernel: kernel size of the blur pass.
  66965. * Only useful if useKernelBlur = true
  66966. */
  66967. /**
  66968. * Sets the blur kernel: kernel size of the blur pass.
  66969. * Only useful if useKernelBlur = true
  66970. */
  66971. blurKernel: number;
  66972. private _useKernelBlur;
  66973. /**
  66974. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  66975. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66976. */
  66977. /**
  66978. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  66979. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66980. */
  66981. useKernelBlur: boolean;
  66982. private _depthScale;
  66983. /**
  66984. * Gets the depth scale used in ESM mode.
  66985. */
  66986. /**
  66987. * Sets the depth scale used in ESM mode.
  66988. * This can override the scale stored on the light.
  66989. */
  66990. depthScale: number;
  66991. private _filter;
  66992. /**
  66993. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  66994. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66995. */
  66996. /**
  66997. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  66998. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66999. */
  67000. filter: number;
  67001. /**
  67002. * Gets if the current filter is set to Poisson Sampling.
  67003. */
  67004. /**
  67005. * Sets the current filter to Poisson Sampling.
  67006. */
  67007. usePoissonSampling: boolean;
  67008. /**
  67009. * Gets if the current filter is set to ESM.
  67010. */
  67011. /**
  67012. * Sets the current filter is to ESM.
  67013. */
  67014. useExponentialShadowMap: boolean;
  67015. /**
  67016. * Gets if the current filter is set to filtered ESM.
  67017. */
  67018. /**
  67019. * Gets if the current filter is set to filtered ESM.
  67020. */
  67021. useBlurExponentialShadowMap: boolean;
  67022. /**
  67023. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67024. * exponential to prevent steep falloff artifacts).
  67025. */
  67026. /**
  67027. * Sets the current filter to "close ESM" (using the inverse of the
  67028. * exponential to prevent steep falloff artifacts).
  67029. */
  67030. useCloseExponentialShadowMap: boolean;
  67031. /**
  67032. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67033. * exponential to prevent steep falloff artifacts).
  67034. */
  67035. /**
  67036. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67037. * exponential to prevent steep falloff artifacts).
  67038. */
  67039. useBlurCloseExponentialShadowMap: boolean;
  67040. /**
  67041. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67042. */
  67043. /**
  67044. * Sets the current filter to "PCF" (percentage closer filtering).
  67045. */
  67046. usePercentageCloserFiltering: boolean;
  67047. private _filteringQuality;
  67048. /**
  67049. * Gets the PCF or PCSS Quality.
  67050. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67051. */
  67052. /**
  67053. * Sets the PCF or PCSS Quality.
  67054. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67055. */
  67056. filteringQuality: number;
  67057. /**
  67058. * Gets if the current filter is set to "PCSS" (contact hardening).
  67059. */
  67060. /**
  67061. * Sets the current filter to "PCSS" (contact hardening).
  67062. */
  67063. useContactHardeningShadow: boolean;
  67064. private _contactHardeningLightSizeUVRatio;
  67065. /**
  67066. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67067. * Using a ratio helps keeping shape stability independently of the map size.
  67068. *
  67069. * It does not account for the light projection as it was having too much
  67070. * instability during the light setup or during light position changes.
  67071. *
  67072. * Only valid if useContactHardeningShadow is true.
  67073. */
  67074. /**
  67075. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67076. * Using a ratio helps keeping shape stability independently of the map size.
  67077. *
  67078. * It does not account for the light projection as it was having too much
  67079. * instability during the light setup or during light position changes.
  67080. *
  67081. * Only valid if useContactHardeningShadow is true.
  67082. */
  67083. contactHardeningLightSizeUVRatio: number;
  67084. private _darkness;
  67085. /**
  67086. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67087. * 0 means strongest and 1 would means no shadow.
  67088. * @returns the darkness.
  67089. */
  67090. getDarkness(): number;
  67091. /**
  67092. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67093. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67094. * @returns the shadow generator allowing fluent coding.
  67095. */
  67096. setDarkness(darkness: number): ShadowGenerator;
  67097. private _transparencyShadow;
  67098. /**
  67099. * Sets the ability to have transparent shadow (boolean).
  67100. * @param transparent True if transparent else False
  67101. * @returns the shadow generator allowing fluent coding
  67102. */
  67103. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67104. private _shadowMap;
  67105. private _shadowMap2;
  67106. /**
  67107. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67108. * @returns The render target texture if present otherwise, null
  67109. */
  67110. getShadowMap(): Nullable<RenderTargetTexture>;
  67111. /**
  67112. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67113. * @returns The render target texture if the shadow map is present otherwise, null
  67114. */
  67115. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67116. /**
  67117. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67118. * @param mesh Mesh to add
  67119. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67120. * @returns the Shadow Generator itself
  67121. */
  67122. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67123. /**
  67124. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67125. * @param mesh Mesh to remove
  67126. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67127. * @returns the Shadow Generator itself
  67128. */
  67129. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67130. /**
  67131. * Controls the extent to which the shadows fade out at the edge of the frustum
  67132. * Used only by directionals and spots
  67133. */
  67134. frustumEdgeFalloff: number;
  67135. private _light;
  67136. /**
  67137. * Returns the associated light object.
  67138. * @returns the light generating the shadow
  67139. */
  67140. getLight(): IShadowLight;
  67141. /**
  67142. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67143. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67144. * It might on the other hand introduce peter panning.
  67145. */
  67146. forceBackFacesOnly: boolean;
  67147. private _scene;
  67148. private _lightDirection;
  67149. private _effect;
  67150. private _viewMatrix;
  67151. private _projectionMatrix;
  67152. private _transformMatrix;
  67153. private _cachedPosition;
  67154. private _cachedDirection;
  67155. private _cachedDefines;
  67156. private _currentRenderID;
  67157. private _boxBlurPostprocess;
  67158. private _kernelBlurXPostprocess;
  67159. private _kernelBlurYPostprocess;
  67160. private _blurPostProcesses;
  67161. private _mapSize;
  67162. private _currentFaceIndex;
  67163. private _currentFaceIndexCache;
  67164. private _textureType;
  67165. private _defaultTextureMatrix;
  67166. /** @hidden */
  67167. static _SceneComponentInitialization: (scene: Scene) => void;
  67168. /**
  67169. * Creates a ShadowGenerator object.
  67170. * A ShadowGenerator is the required tool to use the shadows.
  67171. * Each light casting shadows needs to use its own ShadowGenerator.
  67172. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67173. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67174. * @param light The light object generating the shadows.
  67175. * @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.
  67176. */
  67177. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67178. private _initializeGenerator;
  67179. private _initializeShadowMap;
  67180. private _initializeBlurRTTAndPostProcesses;
  67181. private _renderForShadowMap;
  67182. private _renderSubMeshForShadowMap;
  67183. private _applyFilterValues;
  67184. /**
  67185. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67186. * @param onCompiled Callback triggered at the and of the effects compilation
  67187. * @param options Sets of optional options forcing the compilation with different modes
  67188. */
  67189. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67190. useInstances: boolean;
  67191. }>): void;
  67192. /**
  67193. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67194. * @param options Sets of optional options forcing the compilation with different modes
  67195. * @returns A promise that resolves when the compilation completes
  67196. */
  67197. forceCompilationAsync(options?: Partial<{
  67198. useInstances: boolean;
  67199. }>): Promise<void>;
  67200. /**
  67201. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67202. * @param subMesh The submesh we want to render in the shadow map
  67203. * @param useInstances Defines wether will draw in the map using instances
  67204. * @returns true if ready otherwise, false
  67205. */
  67206. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67207. /**
  67208. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67209. * @param defines Defines of the material we want to update
  67210. * @param lightIndex Index of the light in the enabled light list of the material
  67211. */
  67212. prepareDefines(defines: any, lightIndex: number): void;
  67213. /**
  67214. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67215. * defined in the generator but impacting the effect).
  67216. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67217. * @param effect The effect we are binfing the information for
  67218. */
  67219. bindShadowLight(lightIndex: string, effect: Effect): void;
  67220. /**
  67221. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67222. * (eq to shadow prjection matrix * light transform matrix)
  67223. * @returns The transform matrix used to create the shadow map
  67224. */
  67225. getTransformMatrix(): Matrix;
  67226. /**
  67227. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67228. * Cube and 2D textures for instance.
  67229. */
  67230. recreateShadowMap(): void;
  67231. private _disposeBlurPostProcesses;
  67232. private _disposeRTTandPostProcesses;
  67233. /**
  67234. * Disposes the ShadowGenerator.
  67235. * Returns nothing.
  67236. */
  67237. dispose(): void;
  67238. /**
  67239. * Serializes the shadow generator setup to a json object.
  67240. * @returns The serialized JSON object
  67241. */
  67242. serialize(): any;
  67243. /**
  67244. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67245. * @param parsedShadowGenerator The JSON object to parse
  67246. * @param scene The scene to create the shadow map for
  67247. * @returns The parsed shadow generator
  67248. */
  67249. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67250. }
  67251. }
  67252. declare module BABYLON {
  67253. /**
  67254. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67255. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67256. * 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.
  67257. */
  67258. export abstract class Light extends Node {
  67259. /**
  67260. * Falloff Default: light is falling off following the material specification:
  67261. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67262. */
  67263. static readonly FALLOFF_DEFAULT: number;
  67264. /**
  67265. * Falloff Physical: light is falling off following the inverse squared distance law.
  67266. */
  67267. static readonly FALLOFF_PHYSICAL: number;
  67268. /**
  67269. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67270. * to enhance interoperability with other engines.
  67271. */
  67272. static readonly FALLOFF_GLTF: number;
  67273. /**
  67274. * Falloff Standard: light is falling off like in the standard material
  67275. * to enhance interoperability with other materials.
  67276. */
  67277. static readonly FALLOFF_STANDARD: number;
  67278. /**
  67279. * If every light affecting the material is in this lightmapMode,
  67280. * material.lightmapTexture adds or multiplies
  67281. * (depends on material.useLightmapAsShadowmap)
  67282. * after every other light calculations.
  67283. */
  67284. static readonly LIGHTMAP_DEFAULT: number;
  67285. /**
  67286. * material.lightmapTexture as only diffuse lighting from this light
  67287. * adds only specular lighting from this light
  67288. * adds dynamic shadows
  67289. */
  67290. static readonly LIGHTMAP_SPECULAR: number;
  67291. /**
  67292. * material.lightmapTexture as only lighting
  67293. * no light calculation from this light
  67294. * only adds dynamic shadows from this light
  67295. */
  67296. static readonly LIGHTMAP_SHADOWSONLY: number;
  67297. /**
  67298. * Each light type uses the default quantity according to its type:
  67299. * point/spot lights use luminous intensity
  67300. * directional lights use illuminance
  67301. */
  67302. static readonly INTENSITYMODE_AUTOMATIC: number;
  67303. /**
  67304. * lumen (lm)
  67305. */
  67306. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67307. /**
  67308. * candela (lm/sr)
  67309. */
  67310. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67311. /**
  67312. * lux (lm/m^2)
  67313. */
  67314. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67315. /**
  67316. * nit (cd/m^2)
  67317. */
  67318. static readonly INTENSITYMODE_LUMINANCE: number;
  67319. /**
  67320. * Light type const id of the point light.
  67321. */
  67322. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67323. /**
  67324. * Light type const id of the directional light.
  67325. */
  67326. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67327. /**
  67328. * Light type const id of the spot light.
  67329. */
  67330. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67331. /**
  67332. * Light type const id of the hemispheric light.
  67333. */
  67334. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67335. /**
  67336. * Diffuse gives the basic color to an object.
  67337. */
  67338. diffuse: Color3;
  67339. /**
  67340. * Specular produces a highlight color on an object.
  67341. * Note: This is note affecting PBR materials.
  67342. */
  67343. specular: Color3;
  67344. /**
  67345. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67346. * falling off base on range or angle.
  67347. * This can be set to any values in Light.FALLOFF_x.
  67348. *
  67349. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67350. * other types of materials.
  67351. */
  67352. falloffType: number;
  67353. /**
  67354. * Strength of the light.
  67355. * Note: By default it is define in the framework own unit.
  67356. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67357. */
  67358. intensity: number;
  67359. private _range;
  67360. protected _inverseSquaredRange: number;
  67361. /**
  67362. * Defines how far from the source the light is impacting in scene units.
  67363. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67364. */
  67365. /**
  67366. * Defines how far from the source the light is impacting in scene units.
  67367. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67368. */
  67369. range: number;
  67370. /**
  67371. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67372. * of light.
  67373. */
  67374. private _photometricScale;
  67375. private _intensityMode;
  67376. /**
  67377. * Gets the photometric scale used to interpret the intensity.
  67378. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67379. */
  67380. /**
  67381. * Sets the photometric scale used to interpret the intensity.
  67382. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67383. */
  67384. intensityMode: number;
  67385. private _radius;
  67386. /**
  67387. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67388. */
  67389. /**
  67390. * sets the light radius used by PBR Materials to simulate soft area lights.
  67391. */
  67392. radius: number;
  67393. private _renderPriority;
  67394. /**
  67395. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67396. * exceeding the number allowed of the materials.
  67397. */
  67398. renderPriority: number;
  67399. private _shadowEnabled;
  67400. /**
  67401. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67402. * the current shadow generator.
  67403. */
  67404. /**
  67405. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67406. * the current shadow generator.
  67407. */
  67408. shadowEnabled: boolean;
  67409. private _includedOnlyMeshes;
  67410. /**
  67411. * Gets the only meshes impacted by this light.
  67412. */
  67413. /**
  67414. * Sets the only meshes impacted by this light.
  67415. */
  67416. includedOnlyMeshes: AbstractMesh[];
  67417. private _excludedMeshes;
  67418. /**
  67419. * Gets the meshes not impacted by this light.
  67420. */
  67421. /**
  67422. * Sets the meshes not impacted by this light.
  67423. */
  67424. excludedMeshes: AbstractMesh[];
  67425. private _excludeWithLayerMask;
  67426. /**
  67427. * Gets the layer id use to find what meshes are not impacted by the light.
  67428. * Inactive if 0
  67429. */
  67430. /**
  67431. * Sets the layer id use to find what meshes are not impacted by the light.
  67432. * Inactive if 0
  67433. */
  67434. excludeWithLayerMask: number;
  67435. private _includeOnlyWithLayerMask;
  67436. /**
  67437. * Gets the layer id use to find what meshes are impacted by the light.
  67438. * Inactive if 0
  67439. */
  67440. /**
  67441. * Sets the layer id use to find what meshes are impacted by the light.
  67442. * Inactive if 0
  67443. */
  67444. includeOnlyWithLayerMask: number;
  67445. private _lightmapMode;
  67446. /**
  67447. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67448. */
  67449. /**
  67450. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67451. */
  67452. lightmapMode: number;
  67453. /**
  67454. * Shadow generator associted to the light.
  67455. * @hidden Internal use only.
  67456. */
  67457. _shadowGenerator: Nullable<IShadowGenerator>;
  67458. /**
  67459. * @hidden Internal use only.
  67460. */
  67461. _excludedMeshesIds: string[];
  67462. /**
  67463. * @hidden Internal use only.
  67464. */
  67465. _includedOnlyMeshesIds: string[];
  67466. /**
  67467. * The current light unifom buffer.
  67468. * @hidden Internal use only.
  67469. */
  67470. _uniformBuffer: UniformBuffer;
  67471. /**
  67472. * Creates a Light object in the scene.
  67473. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67474. * @param name The firendly name of the light
  67475. * @param scene The scene the light belongs too
  67476. */
  67477. constructor(name: string, scene: Scene);
  67478. protected abstract _buildUniformLayout(): void;
  67479. /**
  67480. * Sets the passed Effect "effect" with the Light information.
  67481. * @param effect The effect to update
  67482. * @param lightIndex The index of the light in the effect to update
  67483. * @returns The light
  67484. */
  67485. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67486. /**
  67487. * Returns the string "Light".
  67488. * @returns the class name
  67489. */
  67490. getClassName(): string;
  67491. /** @hidden */
  67492. readonly _isLight: boolean;
  67493. /**
  67494. * Converts the light information to a readable string for debug purpose.
  67495. * @param fullDetails Supports for multiple levels of logging within scene loading
  67496. * @returns the human readable light info
  67497. */
  67498. toString(fullDetails?: boolean): string;
  67499. /** @hidden */
  67500. protected _syncParentEnabledState(): void;
  67501. /**
  67502. * Set the enabled state of this node.
  67503. * @param value - the new enabled state
  67504. */
  67505. setEnabled(value: boolean): void;
  67506. /**
  67507. * Returns the Light associated shadow generator if any.
  67508. * @return the associated shadow generator.
  67509. */
  67510. getShadowGenerator(): Nullable<IShadowGenerator>;
  67511. /**
  67512. * Returns a Vector3, the absolute light position in the World.
  67513. * @returns the world space position of the light
  67514. */
  67515. getAbsolutePosition(): Vector3;
  67516. /**
  67517. * Specifies if the light will affect the passed mesh.
  67518. * @param mesh The mesh to test against the light
  67519. * @return true the mesh is affected otherwise, false.
  67520. */
  67521. canAffectMesh(mesh: AbstractMesh): boolean;
  67522. /**
  67523. * Sort function to order lights for rendering.
  67524. * @param a First Light object to compare to second.
  67525. * @param b Second Light object to compare first.
  67526. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67527. */
  67528. static CompareLightsPriority(a: Light, b: Light): number;
  67529. /**
  67530. * Releases resources associated with this node.
  67531. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67532. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67533. */
  67534. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67535. /**
  67536. * Returns the light type ID (integer).
  67537. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67538. */
  67539. getTypeID(): number;
  67540. /**
  67541. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67542. * @returns the scaled intensity in intensity mode unit
  67543. */
  67544. getScaledIntensity(): number;
  67545. /**
  67546. * Returns a new Light object, named "name", from the current one.
  67547. * @param name The name of the cloned light
  67548. * @returns the new created light
  67549. */
  67550. clone(name: string): Nullable<Light>;
  67551. /**
  67552. * Serializes the current light into a Serialization object.
  67553. * @returns the serialized object.
  67554. */
  67555. serialize(): any;
  67556. /**
  67557. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67558. * This new light is named "name" and added to the passed scene.
  67559. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67560. * @param name The friendly name of the light
  67561. * @param scene The scene the new light will belong to
  67562. * @returns the constructor function
  67563. */
  67564. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67565. /**
  67566. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67567. * @param parsedLight The JSON representation of the light
  67568. * @param scene The scene to create the parsed light in
  67569. * @returns the created light after parsing
  67570. */
  67571. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67572. private _hookArrayForExcluded;
  67573. private _hookArrayForIncludedOnly;
  67574. private _resyncMeshes;
  67575. /**
  67576. * Forces the meshes to update their light related information in their rendering used effects
  67577. * @hidden Internal Use Only
  67578. */
  67579. _markMeshesAsLightDirty(): void;
  67580. /**
  67581. * Recomputes the cached photometric scale if needed.
  67582. */
  67583. private _computePhotometricScale;
  67584. /**
  67585. * Returns the Photometric Scale according to the light type and intensity mode.
  67586. */
  67587. private _getPhotometricScale;
  67588. /**
  67589. * Reorder the light in the scene according to their defined priority.
  67590. * @hidden Internal Use Only
  67591. */
  67592. _reorderLightsInScene(): void;
  67593. /**
  67594. * Prepares the list of defines specific to the light type.
  67595. * @param defines the list of defines
  67596. * @param lightIndex defines the index of the light for the effect
  67597. */
  67598. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67599. }
  67600. }
  67601. declare module BABYLON {
  67602. /**
  67603. * Interface used to define Action
  67604. */
  67605. export interface IAction {
  67606. /**
  67607. * Trigger for the action
  67608. */
  67609. trigger: number;
  67610. /** Options of the trigger */
  67611. triggerOptions: any;
  67612. /**
  67613. * Gets the trigger parameters
  67614. * @returns the trigger parameters
  67615. */
  67616. getTriggerParameter(): any;
  67617. /**
  67618. * Internal only - executes current action event
  67619. * @hidden
  67620. */
  67621. _executeCurrent(evt?: ActionEvent): void;
  67622. /**
  67623. * Serialize placeholder for child classes
  67624. * @param parent of child
  67625. * @returns the serialized object
  67626. */
  67627. serialize(parent: any): any;
  67628. }
  67629. /**
  67630. * The action to be carried out following a trigger
  67631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67632. */
  67633. export class Action implements IAction {
  67634. /** the trigger, with or without parameters, for the action */
  67635. triggerOptions: any;
  67636. /**
  67637. * Trigger for the action
  67638. */
  67639. trigger: number;
  67640. /**
  67641. * Internal only - manager for action
  67642. * @hidden
  67643. */
  67644. _actionManager: ActionManager;
  67645. private _nextActiveAction;
  67646. private _child;
  67647. private _condition?;
  67648. private _triggerParameter;
  67649. /**
  67650. * An event triggered prior to action being executed.
  67651. */
  67652. onBeforeExecuteObservable: Observable<Action>;
  67653. /**
  67654. * Creates a new Action
  67655. * @param triggerOptions the trigger, with or without parameters, for the action
  67656. * @param condition an optional determinant of action
  67657. */
  67658. constructor(
  67659. /** the trigger, with or without parameters, for the action */
  67660. triggerOptions: any, condition?: Condition);
  67661. /**
  67662. * Internal only
  67663. * @hidden
  67664. */
  67665. _prepare(): void;
  67666. /**
  67667. * Gets the trigger parameters
  67668. * @returns the trigger parameters
  67669. */
  67670. getTriggerParameter(): any;
  67671. /**
  67672. * Internal only - executes current action event
  67673. * @hidden
  67674. */
  67675. _executeCurrent(evt?: ActionEvent): void;
  67676. /**
  67677. * Execute placeholder for child classes
  67678. * @param evt optional action event
  67679. */
  67680. execute(evt?: ActionEvent): void;
  67681. /**
  67682. * Skips to next active action
  67683. */
  67684. skipToNextActiveAction(): void;
  67685. /**
  67686. * Adds action to chain of actions, may be a DoNothingAction
  67687. * @param action defines the next action to execute
  67688. * @returns The action passed in
  67689. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67690. */
  67691. then(action: Action): Action;
  67692. /**
  67693. * Internal only
  67694. * @hidden
  67695. */
  67696. _getProperty(propertyPath: string): string;
  67697. /**
  67698. * Internal only
  67699. * @hidden
  67700. */
  67701. _getEffectiveTarget(target: any, propertyPath: string): any;
  67702. /**
  67703. * Serialize placeholder for child classes
  67704. * @param parent of child
  67705. * @returns the serialized object
  67706. */
  67707. serialize(parent: any): any;
  67708. /**
  67709. * Internal only called by serialize
  67710. * @hidden
  67711. */
  67712. protected _serialize(serializedAction: any, parent?: any): any;
  67713. /**
  67714. * Internal only
  67715. * @hidden
  67716. */
  67717. static _SerializeValueAsString: (value: any) => string;
  67718. /**
  67719. * Internal only
  67720. * @hidden
  67721. */
  67722. static _GetTargetProperty: (target: Scene | Node) => {
  67723. name: string;
  67724. targetType: string;
  67725. value: string;
  67726. };
  67727. }
  67728. }
  67729. declare module BABYLON {
  67730. /**
  67731. * A Condition applied to an Action
  67732. */
  67733. export class Condition {
  67734. /**
  67735. * Internal only - manager for action
  67736. * @hidden
  67737. */
  67738. _actionManager: ActionManager;
  67739. /**
  67740. * Internal only
  67741. * @hidden
  67742. */
  67743. _evaluationId: number;
  67744. /**
  67745. * Internal only
  67746. * @hidden
  67747. */
  67748. _currentResult: boolean;
  67749. /**
  67750. * Creates a new Condition
  67751. * @param actionManager the manager of the action the condition is applied to
  67752. */
  67753. constructor(actionManager: ActionManager);
  67754. /**
  67755. * Check if the current condition is valid
  67756. * @returns a boolean
  67757. */
  67758. isValid(): boolean;
  67759. /**
  67760. * Internal only
  67761. * @hidden
  67762. */
  67763. _getProperty(propertyPath: string): string;
  67764. /**
  67765. * Internal only
  67766. * @hidden
  67767. */
  67768. _getEffectiveTarget(target: any, propertyPath: string): any;
  67769. /**
  67770. * Serialize placeholder for child classes
  67771. * @returns the serialized object
  67772. */
  67773. serialize(): any;
  67774. /**
  67775. * Internal only
  67776. * @hidden
  67777. */
  67778. protected _serialize(serializedCondition: any): any;
  67779. }
  67780. /**
  67781. * Defines specific conditional operators as extensions of Condition
  67782. */
  67783. export class ValueCondition extends Condition {
  67784. /** path to specify the property of the target the conditional operator uses */
  67785. propertyPath: string;
  67786. /** the value compared by the conditional operator against the current value of the property */
  67787. value: any;
  67788. /** the conditional operator, default ValueCondition.IsEqual */
  67789. operator: number;
  67790. /**
  67791. * Internal only
  67792. * @hidden
  67793. */
  67794. private static _IsEqual;
  67795. /**
  67796. * Internal only
  67797. * @hidden
  67798. */
  67799. private static _IsDifferent;
  67800. /**
  67801. * Internal only
  67802. * @hidden
  67803. */
  67804. private static _IsGreater;
  67805. /**
  67806. * Internal only
  67807. * @hidden
  67808. */
  67809. private static _IsLesser;
  67810. /**
  67811. * returns the number for IsEqual
  67812. */
  67813. static readonly IsEqual: number;
  67814. /**
  67815. * Returns the number for IsDifferent
  67816. */
  67817. static readonly IsDifferent: number;
  67818. /**
  67819. * Returns the number for IsGreater
  67820. */
  67821. static readonly IsGreater: number;
  67822. /**
  67823. * Returns the number for IsLesser
  67824. */
  67825. static readonly IsLesser: number;
  67826. /**
  67827. * Internal only The action manager for the condition
  67828. * @hidden
  67829. */
  67830. _actionManager: ActionManager;
  67831. /**
  67832. * Internal only
  67833. * @hidden
  67834. */
  67835. private _target;
  67836. /**
  67837. * Internal only
  67838. * @hidden
  67839. */
  67840. private _effectiveTarget;
  67841. /**
  67842. * Internal only
  67843. * @hidden
  67844. */
  67845. private _property;
  67846. /**
  67847. * Creates a new ValueCondition
  67848. * @param actionManager manager for the action the condition applies to
  67849. * @param target for the action
  67850. * @param propertyPath path to specify the property of the target the conditional operator uses
  67851. * @param value the value compared by the conditional operator against the current value of the property
  67852. * @param operator the conditional operator, default ValueCondition.IsEqual
  67853. */
  67854. constructor(actionManager: ActionManager, target: any,
  67855. /** path to specify the property of the target the conditional operator uses */
  67856. propertyPath: string,
  67857. /** the value compared by the conditional operator against the current value of the property */
  67858. value: any,
  67859. /** the conditional operator, default ValueCondition.IsEqual */
  67860. operator?: number);
  67861. /**
  67862. * Compares the given value with the property value for the specified conditional operator
  67863. * @returns the result of the comparison
  67864. */
  67865. isValid(): boolean;
  67866. /**
  67867. * Serialize the ValueCondition into a JSON compatible object
  67868. * @returns serialization object
  67869. */
  67870. serialize(): any;
  67871. /**
  67872. * Gets the name of the conditional operator for the ValueCondition
  67873. * @param operator the conditional operator
  67874. * @returns the name
  67875. */
  67876. static GetOperatorName(operator: number): string;
  67877. }
  67878. /**
  67879. * Defines a predicate condition as an extension of Condition
  67880. */
  67881. export class PredicateCondition extends Condition {
  67882. /** defines the predicate function used to validate the condition */
  67883. predicate: () => boolean;
  67884. /**
  67885. * Internal only - manager for action
  67886. * @hidden
  67887. */
  67888. _actionManager: ActionManager;
  67889. /**
  67890. * Creates a new PredicateCondition
  67891. * @param actionManager manager for the action the condition applies to
  67892. * @param predicate defines the predicate function used to validate the condition
  67893. */
  67894. constructor(actionManager: ActionManager,
  67895. /** defines the predicate function used to validate the condition */
  67896. predicate: () => boolean);
  67897. /**
  67898. * @returns the validity of the predicate condition
  67899. */
  67900. isValid(): boolean;
  67901. }
  67902. /**
  67903. * Defines a state condition as an extension of Condition
  67904. */
  67905. export class StateCondition extends Condition {
  67906. /** Value to compare with target state */
  67907. value: string;
  67908. /**
  67909. * Internal only - manager for action
  67910. * @hidden
  67911. */
  67912. _actionManager: ActionManager;
  67913. /**
  67914. * Internal only
  67915. * @hidden
  67916. */
  67917. private _target;
  67918. /**
  67919. * Creates a new StateCondition
  67920. * @param actionManager manager for the action the condition applies to
  67921. * @param target of the condition
  67922. * @param value to compare with target state
  67923. */
  67924. constructor(actionManager: ActionManager, target: any,
  67925. /** Value to compare with target state */
  67926. value: string);
  67927. /**
  67928. * Gets a boolean indicating if the current condition is met
  67929. * @returns the validity of the state
  67930. */
  67931. isValid(): boolean;
  67932. /**
  67933. * Serialize the StateCondition into a JSON compatible object
  67934. * @returns serialization object
  67935. */
  67936. serialize(): any;
  67937. }
  67938. }
  67939. declare module BABYLON {
  67940. /**
  67941. * This defines an action responsible to toggle a boolean once triggered.
  67942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67943. */
  67944. export class SwitchBooleanAction extends Action {
  67945. /**
  67946. * The path to the boolean property in the target object
  67947. */
  67948. propertyPath: string;
  67949. private _target;
  67950. private _effectiveTarget;
  67951. private _property;
  67952. /**
  67953. * Instantiate the action
  67954. * @param triggerOptions defines the trigger options
  67955. * @param target defines the object containing the boolean
  67956. * @param propertyPath defines the path to the boolean property in the target object
  67957. * @param condition defines the trigger related conditions
  67958. */
  67959. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  67960. /** @hidden */
  67961. _prepare(): void;
  67962. /**
  67963. * Execute the action toggle the boolean value.
  67964. */
  67965. execute(): void;
  67966. /**
  67967. * Serializes the actions and its related information.
  67968. * @param parent defines the object to serialize in
  67969. * @returns the serialized object
  67970. */
  67971. serialize(parent: any): any;
  67972. }
  67973. /**
  67974. * This defines an action responsible to set a the state field of the target
  67975. * to a desired value once triggered.
  67976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67977. */
  67978. export class SetStateAction extends Action {
  67979. /**
  67980. * The value to store in the state field.
  67981. */
  67982. value: string;
  67983. private _target;
  67984. /**
  67985. * Instantiate the action
  67986. * @param triggerOptions defines the trigger options
  67987. * @param target defines the object containing the state property
  67988. * @param value defines the value to store in the state field
  67989. * @param condition defines the trigger related conditions
  67990. */
  67991. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  67992. /**
  67993. * Execute the action and store the value on the target state property.
  67994. */
  67995. execute(): void;
  67996. /**
  67997. * Serializes the actions and its related information.
  67998. * @param parent defines the object to serialize in
  67999. * @returns the serialized object
  68000. */
  68001. serialize(parent: any): any;
  68002. }
  68003. /**
  68004. * This defines an action responsible to set a property of the target
  68005. * to a desired value once triggered.
  68006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68007. */
  68008. export class SetValueAction extends Action {
  68009. /**
  68010. * The path of the property to set in the target.
  68011. */
  68012. propertyPath: string;
  68013. /**
  68014. * The value to set in the property
  68015. */
  68016. value: any;
  68017. private _target;
  68018. private _effectiveTarget;
  68019. private _property;
  68020. /**
  68021. * Instantiate the action
  68022. * @param triggerOptions defines the trigger options
  68023. * @param target defines the object containing the property
  68024. * @param propertyPath defines the path of the property to set in the target
  68025. * @param value defines the value to set in the property
  68026. * @param condition defines the trigger related conditions
  68027. */
  68028. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68029. /** @hidden */
  68030. _prepare(): void;
  68031. /**
  68032. * Execute the action and set the targetted property to the desired value.
  68033. */
  68034. execute(): void;
  68035. /**
  68036. * Serializes the actions and its related information.
  68037. * @param parent defines the object to serialize in
  68038. * @returns the serialized object
  68039. */
  68040. serialize(parent: any): any;
  68041. }
  68042. /**
  68043. * This defines an action responsible to increment the target value
  68044. * to a desired value once triggered.
  68045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68046. */
  68047. export class IncrementValueAction extends Action {
  68048. /**
  68049. * The path of the property to increment in the target.
  68050. */
  68051. propertyPath: string;
  68052. /**
  68053. * The value we should increment the property by.
  68054. */
  68055. value: any;
  68056. private _target;
  68057. private _effectiveTarget;
  68058. private _property;
  68059. /**
  68060. * Instantiate the action
  68061. * @param triggerOptions defines the trigger options
  68062. * @param target defines the object containing the property
  68063. * @param propertyPath defines the path of the property to increment in the target
  68064. * @param value defines the value value we should increment the property by
  68065. * @param condition defines the trigger related conditions
  68066. */
  68067. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68068. /** @hidden */
  68069. _prepare(): void;
  68070. /**
  68071. * Execute the action and increment the target of the value amount.
  68072. */
  68073. execute(): void;
  68074. /**
  68075. * Serializes the actions and its related information.
  68076. * @param parent defines the object to serialize in
  68077. * @returns the serialized object
  68078. */
  68079. serialize(parent: any): any;
  68080. }
  68081. /**
  68082. * This defines an action responsible to start an animation once triggered.
  68083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68084. */
  68085. export class PlayAnimationAction extends Action {
  68086. /**
  68087. * Where the animation should start (animation frame)
  68088. */
  68089. from: number;
  68090. /**
  68091. * Where the animation should stop (animation frame)
  68092. */
  68093. to: number;
  68094. /**
  68095. * Define if the animation should loop or stop after the first play.
  68096. */
  68097. loop?: boolean;
  68098. private _target;
  68099. /**
  68100. * Instantiate the action
  68101. * @param triggerOptions defines the trigger options
  68102. * @param target defines the target animation or animation name
  68103. * @param from defines from where the animation should start (animation frame)
  68104. * @param end defines where the animation should stop (animation frame)
  68105. * @param loop defines if the animation should loop or stop after the first play
  68106. * @param condition defines the trigger related conditions
  68107. */
  68108. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68109. /** @hidden */
  68110. _prepare(): void;
  68111. /**
  68112. * Execute the action and play the animation.
  68113. */
  68114. execute(): void;
  68115. /**
  68116. * Serializes the actions and its related information.
  68117. * @param parent defines the object to serialize in
  68118. * @returns the serialized object
  68119. */
  68120. serialize(parent: any): any;
  68121. }
  68122. /**
  68123. * This defines an action responsible to stop an animation once triggered.
  68124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68125. */
  68126. export class StopAnimationAction extends Action {
  68127. private _target;
  68128. /**
  68129. * Instantiate the action
  68130. * @param triggerOptions defines the trigger options
  68131. * @param target defines the target animation or animation name
  68132. * @param condition defines the trigger related conditions
  68133. */
  68134. constructor(triggerOptions: any, target: any, condition?: Condition);
  68135. /** @hidden */
  68136. _prepare(): void;
  68137. /**
  68138. * Execute the action and stop the animation.
  68139. */
  68140. execute(): void;
  68141. /**
  68142. * Serializes the actions and its related information.
  68143. * @param parent defines the object to serialize in
  68144. * @returns the serialized object
  68145. */
  68146. serialize(parent: any): any;
  68147. }
  68148. /**
  68149. * This defines an action responsible that does nothing once triggered.
  68150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68151. */
  68152. export class DoNothingAction extends Action {
  68153. /**
  68154. * Instantiate the action
  68155. * @param triggerOptions defines the trigger options
  68156. * @param condition defines the trigger related conditions
  68157. */
  68158. constructor(triggerOptions?: any, condition?: Condition);
  68159. /**
  68160. * Execute the action and do nothing.
  68161. */
  68162. execute(): void;
  68163. /**
  68164. * Serializes the actions and its related information.
  68165. * @param parent defines the object to serialize in
  68166. * @returns the serialized object
  68167. */
  68168. serialize(parent: any): any;
  68169. }
  68170. /**
  68171. * This defines an action responsible to trigger several actions once triggered.
  68172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68173. */
  68174. export class CombineAction extends Action {
  68175. /**
  68176. * The list of aggregated animations to run.
  68177. */
  68178. children: Action[];
  68179. /**
  68180. * Instantiate the action
  68181. * @param triggerOptions defines the trigger options
  68182. * @param children defines the list of aggregated animations to run
  68183. * @param condition defines the trigger related conditions
  68184. */
  68185. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68186. /** @hidden */
  68187. _prepare(): void;
  68188. /**
  68189. * Execute the action and executes all the aggregated actions.
  68190. */
  68191. execute(evt: ActionEvent): void;
  68192. /**
  68193. * Serializes the actions and its related information.
  68194. * @param parent defines the object to serialize in
  68195. * @returns the serialized object
  68196. */
  68197. serialize(parent: any): any;
  68198. }
  68199. /**
  68200. * This defines an action responsible to run code (external event) once triggered.
  68201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68202. */
  68203. export class ExecuteCodeAction extends Action {
  68204. /**
  68205. * The callback function to run.
  68206. */
  68207. func: (evt: ActionEvent) => void;
  68208. /**
  68209. * Instantiate the action
  68210. * @param triggerOptions defines the trigger options
  68211. * @param func defines the callback function to run
  68212. * @param condition defines the trigger related conditions
  68213. */
  68214. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68215. /**
  68216. * Execute the action and run the attached code.
  68217. */
  68218. execute(evt: ActionEvent): void;
  68219. }
  68220. /**
  68221. * This defines an action responsible to set the parent property of the target once triggered.
  68222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68223. */
  68224. export class SetParentAction extends Action {
  68225. private _parent;
  68226. private _target;
  68227. /**
  68228. * Instantiate the action
  68229. * @param triggerOptions defines the trigger options
  68230. * @param target defines the target containing the parent property
  68231. * @param parent defines from where the animation should start (animation frame)
  68232. * @param condition defines the trigger related conditions
  68233. */
  68234. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68235. /** @hidden */
  68236. _prepare(): void;
  68237. /**
  68238. * Execute the action and set the parent property.
  68239. */
  68240. execute(): void;
  68241. /**
  68242. * Serializes the actions and its related information.
  68243. * @param parent defines the object to serialize in
  68244. * @returns the serialized object
  68245. */
  68246. serialize(parent: any): any;
  68247. }
  68248. }
  68249. declare module BABYLON {
  68250. /**
  68251. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68252. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68254. */
  68255. export class ActionManager extends AbstractActionManager {
  68256. /**
  68257. * Nothing
  68258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68259. */
  68260. static readonly NothingTrigger: number;
  68261. /**
  68262. * On pick
  68263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68264. */
  68265. static readonly OnPickTrigger: number;
  68266. /**
  68267. * On left pick
  68268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68269. */
  68270. static readonly OnLeftPickTrigger: number;
  68271. /**
  68272. * On right pick
  68273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68274. */
  68275. static readonly OnRightPickTrigger: number;
  68276. /**
  68277. * On center pick
  68278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68279. */
  68280. static readonly OnCenterPickTrigger: number;
  68281. /**
  68282. * On pick down
  68283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68284. */
  68285. static readonly OnPickDownTrigger: number;
  68286. /**
  68287. * On double pick
  68288. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68289. */
  68290. static readonly OnDoublePickTrigger: number;
  68291. /**
  68292. * On pick up
  68293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68294. */
  68295. static readonly OnPickUpTrigger: number;
  68296. /**
  68297. * On pick out.
  68298. * This trigger will only be raised if you also declared a OnPickDown
  68299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68300. */
  68301. static readonly OnPickOutTrigger: number;
  68302. /**
  68303. * On long press
  68304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68305. */
  68306. static readonly OnLongPressTrigger: number;
  68307. /**
  68308. * On pointer over
  68309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68310. */
  68311. static readonly OnPointerOverTrigger: number;
  68312. /**
  68313. * On pointer out
  68314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68315. */
  68316. static readonly OnPointerOutTrigger: number;
  68317. /**
  68318. * On every frame
  68319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68320. */
  68321. static readonly OnEveryFrameTrigger: number;
  68322. /**
  68323. * On intersection enter
  68324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68325. */
  68326. static readonly OnIntersectionEnterTrigger: number;
  68327. /**
  68328. * On intersection exit
  68329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68330. */
  68331. static readonly OnIntersectionExitTrigger: number;
  68332. /**
  68333. * On key down
  68334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68335. */
  68336. static readonly OnKeyDownTrigger: number;
  68337. /**
  68338. * On key up
  68339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68340. */
  68341. static readonly OnKeyUpTrigger: number;
  68342. private _scene;
  68343. /**
  68344. * Creates a new action manager
  68345. * @param scene defines the hosting scene
  68346. */
  68347. constructor(scene: Scene);
  68348. /**
  68349. * Releases all associated resources
  68350. */
  68351. dispose(): void;
  68352. /**
  68353. * Gets hosting scene
  68354. * @returns the hosting scene
  68355. */
  68356. getScene(): Scene;
  68357. /**
  68358. * Does this action manager handles actions of any of the given triggers
  68359. * @param triggers defines the triggers to be tested
  68360. * @return a boolean indicating whether one (or more) of the triggers is handled
  68361. */
  68362. hasSpecificTriggers(triggers: number[]): boolean;
  68363. /**
  68364. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68365. * speed.
  68366. * @param triggerA defines the trigger to be tested
  68367. * @param triggerB defines the trigger to be tested
  68368. * @return a boolean indicating whether one (or more) of the triggers is handled
  68369. */
  68370. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68371. /**
  68372. * Does this action manager handles actions of a given trigger
  68373. * @param trigger defines the trigger to be tested
  68374. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68375. * @return whether the trigger is handled
  68376. */
  68377. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68378. /**
  68379. * Does this action manager has pointer triggers
  68380. */
  68381. readonly hasPointerTriggers: boolean;
  68382. /**
  68383. * Does this action manager has pick triggers
  68384. */
  68385. readonly hasPickTriggers: boolean;
  68386. /**
  68387. * Registers an action to this action manager
  68388. * @param action defines the action to be registered
  68389. * @return the action amended (prepared) after registration
  68390. */
  68391. registerAction(action: Action): Nullable<Action>;
  68392. /**
  68393. * Unregisters an action to this action manager
  68394. * @param action defines the action to be unregistered
  68395. * @return a boolean indicating whether the action has been unregistered
  68396. */
  68397. unregisterAction(action: Action): Boolean;
  68398. /**
  68399. * Process a specific trigger
  68400. * @param trigger defines the trigger to process
  68401. * @param evt defines the event details to be processed
  68402. */
  68403. processTrigger(trigger: number, evt?: IActionEvent): void;
  68404. /** @hidden */
  68405. _getEffectiveTarget(target: any, propertyPath: string): any;
  68406. /** @hidden */
  68407. _getProperty(propertyPath: string): string;
  68408. /**
  68409. * Serialize this manager to a JSON object
  68410. * @param name defines the property name to store this manager
  68411. * @returns a JSON representation of this manager
  68412. */
  68413. serialize(name: string): any;
  68414. /**
  68415. * Creates a new ActionManager from a JSON data
  68416. * @param parsedActions defines the JSON data to read from
  68417. * @param object defines the hosting mesh
  68418. * @param scene defines the hosting scene
  68419. */
  68420. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  68421. /**
  68422. * Get a trigger name by index
  68423. * @param trigger defines the trigger index
  68424. * @returns a trigger name
  68425. */
  68426. static GetTriggerName(trigger: number): string;
  68427. }
  68428. }
  68429. declare module BABYLON {
  68430. /**
  68431. * Class representing a ray with position and direction
  68432. */
  68433. export class Ray {
  68434. /** origin point */
  68435. origin: Vector3;
  68436. /** direction */
  68437. direction: Vector3;
  68438. /** length of the ray */
  68439. length: number;
  68440. private static readonly TmpVector3;
  68441. private _tmpRay;
  68442. /**
  68443. * Creates a new ray
  68444. * @param origin origin point
  68445. * @param direction direction
  68446. * @param length length of the ray
  68447. */
  68448. constructor(
  68449. /** origin point */
  68450. origin: Vector3,
  68451. /** direction */
  68452. direction: Vector3,
  68453. /** length of the ray */
  68454. length?: number);
  68455. /**
  68456. * Checks if the ray intersects a box
  68457. * @param minimum bound of the box
  68458. * @param maximum bound of the box
  68459. * @param intersectionTreshold extra extend to be added to the box in all direction
  68460. * @returns if the box was hit
  68461. */
  68462. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68463. /**
  68464. * Checks if the ray intersects a box
  68465. * @param box the bounding box to check
  68466. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68467. * @returns if the box was hit
  68468. */
  68469. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68470. /**
  68471. * If the ray hits a sphere
  68472. * @param sphere the bounding sphere to check
  68473. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68474. * @returns true if it hits the sphere
  68475. */
  68476. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68477. /**
  68478. * If the ray hits a triange
  68479. * @param vertex0 triangle vertex
  68480. * @param vertex1 triangle vertex
  68481. * @param vertex2 triangle vertex
  68482. * @returns intersection information if hit
  68483. */
  68484. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68485. /**
  68486. * Checks if ray intersects a plane
  68487. * @param plane the plane to check
  68488. * @returns the distance away it was hit
  68489. */
  68490. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68491. /**
  68492. * Checks if ray intersects a mesh
  68493. * @param mesh the mesh to check
  68494. * @param fastCheck if only the bounding box should checked
  68495. * @returns picking info of the intersecton
  68496. */
  68497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68498. /**
  68499. * Checks if ray intersects a mesh
  68500. * @param meshes the meshes to check
  68501. * @param fastCheck if only the bounding box should checked
  68502. * @param results array to store result in
  68503. * @returns Array of picking infos
  68504. */
  68505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68506. private _comparePickingInfo;
  68507. private static smallnum;
  68508. private static rayl;
  68509. /**
  68510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68511. * @param sega the first point of the segment to test the intersection against
  68512. * @param segb the second point of the segment to test the intersection against
  68513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68515. */
  68516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68517. /**
  68518. * Update the ray from viewport position
  68519. * @param x position
  68520. * @param y y position
  68521. * @param viewportWidth viewport width
  68522. * @param viewportHeight viewport height
  68523. * @param world world matrix
  68524. * @param view view matrix
  68525. * @param projection projection matrix
  68526. * @returns this ray updated
  68527. */
  68528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68529. /**
  68530. * Creates a ray with origin and direction of 0,0,0
  68531. * @returns the new ray
  68532. */
  68533. static Zero(): Ray;
  68534. /**
  68535. * Creates a new ray from screen space and viewport
  68536. * @param x position
  68537. * @param y y position
  68538. * @param viewportWidth viewport width
  68539. * @param viewportHeight viewport height
  68540. * @param world world matrix
  68541. * @param view view matrix
  68542. * @param projection projection matrix
  68543. * @returns new ray
  68544. */
  68545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68546. /**
  68547. * 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
  68548. * transformed to the given world matrix.
  68549. * @param origin The origin point
  68550. * @param end The end point
  68551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  68552. * @returns the new ray
  68553. */
  68554. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  68555. /**
  68556. * Transforms a ray by a matrix
  68557. * @param ray ray to transform
  68558. * @param matrix matrix to apply
  68559. * @returns the resulting new ray
  68560. */
  68561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  68562. /**
  68563. * Transforms a ray by a matrix
  68564. * @param ray ray to transform
  68565. * @param matrix matrix to apply
  68566. * @param result ray to store result in
  68567. */
  68568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  68569. /**
  68570. * Unproject a ray from screen space to object space
  68571. * @param sourceX defines the screen space x coordinate to use
  68572. * @param sourceY defines the screen space y coordinate to use
  68573. * @param viewportWidth defines the current width of the viewport
  68574. * @param viewportHeight defines the current height of the viewport
  68575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68576. * @param view defines the view matrix to use
  68577. * @param projection defines the projection matrix to use
  68578. */
  68579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  68580. }
  68581. /**
  68582. * Type used to define predicate used to select faces when a mesh intersection is detected
  68583. */
  68584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  68585. interface Scene {
  68586. /** @hidden */
  68587. _tempPickingRay: Nullable<Ray>;
  68588. /** @hidden */
  68589. _cachedRayForTransform: Ray;
  68590. /** @hidden */
  68591. _pickWithRayInverseMatrix: Matrix;
  68592. /** @hidden */
  68593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  68594. /** @hidden */
  68595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  68596. }
  68597. }
  68598. declare module BABYLON {
  68599. /**
  68600. * Groups all the scene component constants in one place to ease maintenance.
  68601. * @hidden
  68602. */
  68603. export class SceneComponentConstants {
  68604. static readonly NAME_EFFECTLAYER: string;
  68605. static readonly NAME_LAYER: string;
  68606. static readonly NAME_LENSFLARESYSTEM: string;
  68607. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68608. static readonly NAME_PARTICLESYSTEM: string;
  68609. static readonly NAME_GAMEPAD: string;
  68610. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68611. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68612. static readonly NAME_DEPTHRENDERER: string;
  68613. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68614. static readonly NAME_SPRITE: string;
  68615. static readonly NAME_OUTLINERENDERER: string;
  68616. static readonly NAME_PROCEDURALTEXTURE: string;
  68617. static readonly NAME_SHADOWGENERATOR: string;
  68618. static readonly NAME_OCTREE: string;
  68619. static readonly NAME_PHYSICSENGINE: string;
  68620. static readonly NAME_AUDIO: string;
  68621. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68622. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68623. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68624. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68625. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68626. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68627. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68628. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68629. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68630. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68631. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68632. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68633. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68634. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68635. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68636. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68637. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68638. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68639. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68640. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68641. static readonly STEP_AFTERRENDER_AUDIO: number;
  68642. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68643. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68644. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68645. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68646. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68647. static readonly STEP_POINTERMOVE_SPRITE: number;
  68648. static readonly STEP_POINTERDOWN_SPRITE: number;
  68649. static readonly STEP_POINTERUP_SPRITE: number;
  68650. }
  68651. /**
  68652. * This represents a scene component.
  68653. *
  68654. * This is used to decouple the dependency the scene is having on the different workloads like
  68655. * layers, post processes...
  68656. */
  68657. export interface ISceneComponent {
  68658. /**
  68659. * The name of the component. Each component must have a unique name.
  68660. */
  68661. name: string;
  68662. /**
  68663. * The scene the component belongs to.
  68664. */
  68665. scene: Scene;
  68666. /**
  68667. * Register the component to one instance of a scene.
  68668. */
  68669. register(): void;
  68670. /**
  68671. * Rebuilds the elements related to this component in case of
  68672. * context lost for instance.
  68673. */
  68674. rebuild(): void;
  68675. /**
  68676. * Disposes the component and the associated ressources.
  68677. */
  68678. dispose(): void;
  68679. }
  68680. /**
  68681. * This represents a SERIALIZABLE scene component.
  68682. *
  68683. * This extends Scene Component to add Serialization methods on top.
  68684. */
  68685. export interface ISceneSerializableComponent extends ISceneComponent {
  68686. /**
  68687. * Adds all the element from the container to the scene
  68688. * @param container the container holding the elements
  68689. */
  68690. addFromContainer(container: AbstractScene): void;
  68691. /**
  68692. * Removes all the elements in the container from the scene
  68693. * @param container contains the elements to remove
  68694. */
  68695. removeFromContainer(container: AbstractScene): void;
  68696. /**
  68697. * Serializes the component data to the specified json object
  68698. * @param serializationObject The object to serialize to
  68699. */
  68700. serialize(serializationObject: any): void;
  68701. }
  68702. /**
  68703. * Strong typing of a Mesh related stage step action
  68704. */
  68705. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68706. /**
  68707. * Strong typing of a Evaluate Sub Mesh related stage step action
  68708. */
  68709. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68710. /**
  68711. * Strong typing of a Active Mesh related stage step action
  68712. */
  68713. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68714. /**
  68715. * Strong typing of a Camera related stage step action
  68716. */
  68717. export type CameraStageAction = (camera: Camera) => void;
  68718. /**
  68719. * Strong typing of a Render Target related stage step action
  68720. */
  68721. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68722. /**
  68723. * Strong typing of a RenderingGroup related stage step action
  68724. */
  68725. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68726. /**
  68727. * Strong typing of a Mesh Render related stage step action
  68728. */
  68729. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68730. /**
  68731. * Strong typing of a simple stage step action
  68732. */
  68733. export type SimpleStageAction = () => void;
  68734. /**
  68735. * Strong typing of a render target action.
  68736. */
  68737. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68738. /**
  68739. * Strong typing of a pointer move action.
  68740. */
  68741. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  68742. /**
  68743. * Strong typing of a pointer up/down action.
  68744. */
  68745. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  68746. /**
  68747. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  68748. * @hidden
  68749. */
  68750. export class Stage<T extends Function> extends Array<{
  68751. index: number;
  68752. component: ISceneComponent;
  68753. action: T;
  68754. }> {
  68755. /**
  68756. * Hide ctor from the rest of the world.
  68757. * @param items The items to add.
  68758. */
  68759. private constructor();
  68760. /**
  68761. * Creates a new Stage.
  68762. * @returns A new instance of a Stage
  68763. */
  68764. static Create<T extends Function>(): Stage<T>;
  68765. /**
  68766. * Registers a step in an ordered way in the targeted stage.
  68767. * @param index Defines the position to register the step in
  68768. * @param component Defines the component attached to the step
  68769. * @param action Defines the action to launch during the step
  68770. */
  68771. registerStep(index: number, component: ISceneComponent, action: T): void;
  68772. /**
  68773. * Clears all the steps from the stage.
  68774. */
  68775. clear(): void;
  68776. }
  68777. }
  68778. declare module BABYLON {
  68779. interface Scene {
  68780. /** @hidden */
  68781. _pointerOverSprite: Nullable<Sprite>;
  68782. /** @hidden */
  68783. _pickedDownSprite: Nullable<Sprite>;
  68784. /** @hidden */
  68785. _tempSpritePickingRay: Nullable<Ray>;
  68786. /**
  68787. * All of the sprite managers added to this scene
  68788. * @see http://doc.babylonjs.com/babylon101/sprites
  68789. */
  68790. spriteManagers: Array<ISpriteManager>;
  68791. /**
  68792. * An event triggered when sprites rendering is about to start
  68793. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68794. */
  68795. onBeforeSpritesRenderingObservable: Observable<Scene>;
  68796. /**
  68797. * An event triggered when sprites rendering is done
  68798. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68799. */
  68800. onAfterSpritesRenderingObservable: Observable<Scene>;
  68801. /** @hidden */
  68802. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68803. /** Launch a ray to try to pick a sprite in the scene
  68804. * @param x position on screen
  68805. * @param y position on screen
  68806. * @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
  68807. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68808. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  68809. * @returns a PickingInfo
  68810. */
  68811. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68812. /** Use the given ray to pick a sprite in the scene
  68813. * @param ray The ray (in world space) to use to pick meshes
  68814. * @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
  68815. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68816. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  68817. * @returns a PickingInfo
  68818. */
  68819. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68820. /**
  68821. * Force the sprite under the pointer
  68822. * @param sprite defines the sprite to use
  68823. */
  68824. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  68825. /**
  68826. * Gets the sprite under the pointer
  68827. * @returns a Sprite or null if no sprite is under the pointer
  68828. */
  68829. getPointerOverSprite(): Nullable<Sprite>;
  68830. }
  68831. /**
  68832. * Defines the sprite scene component responsible to manage sprites
  68833. * in a given scene.
  68834. */
  68835. export class SpriteSceneComponent implements ISceneComponent {
  68836. /**
  68837. * The component name helpfull to identify the component in the list of scene components.
  68838. */
  68839. readonly name: string;
  68840. /**
  68841. * The scene the component belongs to.
  68842. */
  68843. scene: Scene;
  68844. /** @hidden */
  68845. private _spritePredicate;
  68846. /**
  68847. * Creates a new instance of the component for the given scene
  68848. * @param scene Defines the scene to register the component in
  68849. */
  68850. constructor(scene: Scene);
  68851. /**
  68852. * Registers the component in a given scene
  68853. */
  68854. register(): void;
  68855. /**
  68856. * Rebuilds the elements related to this component in case of
  68857. * context lost for instance.
  68858. */
  68859. rebuild(): void;
  68860. /**
  68861. * Disposes the component and the associated ressources.
  68862. */
  68863. dispose(): void;
  68864. private _pickSpriteButKeepRay;
  68865. private _pointerMove;
  68866. private _pointerDown;
  68867. private _pointerUp;
  68868. }
  68869. }
  68870. declare module BABYLON {
  68871. /** @hidden */
  68872. export var fogFragmentDeclaration: {
  68873. name: string;
  68874. shader: string;
  68875. };
  68876. }
  68877. declare module BABYLON {
  68878. /** @hidden */
  68879. export var fogFragment: {
  68880. name: string;
  68881. shader: string;
  68882. };
  68883. }
  68884. declare module BABYLON {
  68885. /** @hidden */
  68886. export var spritesPixelShader: {
  68887. name: string;
  68888. shader: string;
  68889. };
  68890. }
  68891. declare module BABYLON {
  68892. /** @hidden */
  68893. export var fogVertexDeclaration: {
  68894. name: string;
  68895. shader: string;
  68896. };
  68897. }
  68898. declare module BABYLON {
  68899. /** @hidden */
  68900. export var spritesVertexShader: {
  68901. name: string;
  68902. shader: string;
  68903. };
  68904. }
  68905. declare module BABYLON {
  68906. /**
  68907. * Defines the minimum interface to fullfil in order to be a sprite manager.
  68908. */
  68909. export interface ISpriteManager extends IDisposable {
  68910. /**
  68911. * Restricts the camera to viewing objects with the same layerMask.
  68912. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  68913. */
  68914. layerMask: number;
  68915. /**
  68916. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  68917. */
  68918. isPickable: boolean;
  68919. /**
  68920. * Specifies the rendering group id for this mesh (0 by default)
  68921. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  68922. */
  68923. renderingGroupId: number;
  68924. /**
  68925. * Defines the list of sprites managed by the manager.
  68926. */
  68927. sprites: Array<Sprite>;
  68928. /**
  68929. * Tests the intersection of a sprite with a specific ray.
  68930. * @param ray The ray we are sending to test the collision
  68931. * @param camera The camera space we are sending rays in
  68932. * @param predicate A predicate allowing excluding sprites from the list of object to test
  68933. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  68934. * @returns picking info or null.
  68935. */
  68936. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68937. /**
  68938. * Renders the list of sprites on screen.
  68939. */
  68940. render(): void;
  68941. }
  68942. /**
  68943. * Class used to manage multiple sprites on the same spritesheet
  68944. * @see http://doc.babylonjs.com/babylon101/sprites
  68945. */
  68946. export class SpriteManager implements ISpriteManager {
  68947. /** defines the manager's name */
  68948. name: string;
  68949. /** Gets the list of sprites */
  68950. sprites: Sprite[];
  68951. /** Gets or sets the rendering group id (0 by default) */
  68952. renderingGroupId: number;
  68953. /** Gets or sets camera layer mask */
  68954. layerMask: number;
  68955. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  68956. fogEnabled: boolean;
  68957. /** Gets or sets a boolean indicating if the sprites are pickable */
  68958. isPickable: boolean;
  68959. /** Defines the default width of a cell in the spritesheet */
  68960. cellWidth: number;
  68961. /** Defines the default height of a cell in the spritesheet */
  68962. cellHeight: number;
  68963. /**
  68964. * An event triggered when the manager is disposed.
  68965. */
  68966. onDisposeObservable: Observable<SpriteManager>;
  68967. private _onDisposeObserver;
  68968. /**
  68969. * Callback called when the manager is disposed
  68970. */
  68971. onDispose: () => void;
  68972. private _capacity;
  68973. private _spriteTexture;
  68974. private _epsilon;
  68975. private _scene;
  68976. private _vertexData;
  68977. private _buffer;
  68978. private _vertexBuffers;
  68979. private _indexBuffer;
  68980. private _effectBase;
  68981. private _effectFog;
  68982. /**
  68983. * Gets or sets the spritesheet texture
  68984. */
  68985. texture: Texture;
  68986. /**
  68987. * Creates a new sprite manager
  68988. * @param name defines the manager's name
  68989. * @param imgUrl defines the sprite sheet url
  68990. * @param capacity defines the maximum allowed number of sprites
  68991. * @param cellSize defines the size of a sprite cell
  68992. * @param scene defines the hosting scene
  68993. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68994. * @param samplingMode defines the smapling mode to use with spritesheet
  68995. */
  68996. constructor(
  68997. /** defines the manager's name */
  68998. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  68999. private _appendSpriteVertex;
  69000. /**
  69001. * Intersects the sprites with a ray
  69002. * @param ray defines the ray to intersect with
  69003. * @param camera defines the current active camera
  69004. * @param predicate defines a predicate used to select candidate sprites
  69005. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69006. * @returns null if no hit or a PickingInfo
  69007. */
  69008. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69009. /**
  69010. * Render all child sprites
  69011. */
  69012. render(): void;
  69013. /**
  69014. * Release associated resources
  69015. */
  69016. dispose(): void;
  69017. }
  69018. }
  69019. declare module BABYLON {
  69020. /**
  69021. * Class used to represent a sprite
  69022. * @see http://doc.babylonjs.com/babylon101/sprites
  69023. */
  69024. export class Sprite {
  69025. /** defines the name */
  69026. name: string;
  69027. /** Gets or sets the current world position */
  69028. position: Vector3;
  69029. /** Gets or sets the main color */
  69030. color: Color4;
  69031. /** Gets or sets the width */
  69032. width: number;
  69033. /** Gets or sets the height */
  69034. height: number;
  69035. /** Gets or sets rotation angle */
  69036. angle: number;
  69037. /** Gets or sets the cell index in the sprite sheet */
  69038. cellIndex: number;
  69039. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69040. invertU: number;
  69041. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69042. invertV: number;
  69043. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69044. disposeWhenFinishedAnimating: boolean;
  69045. /** Gets the list of attached animations */
  69046. animations: Animation[];
  69047. /** Gets or sets a boolean indicating if the sprite can be picked */
  69048. isPickable: boolean;
  69049. /**
  69050. * Gets or sets the associated action manager
  69051. */
  69052. actionManager: Nullable<ActionManager>;
  69053. private _animationStarted;
  69054. private _loopAnimation;
  69055. private _fromIndex;
  69056. private _toIndex;
  69057. private _delay;
  69058. private _direction;
  69059. private _manager;
  69060. private _time;
  69061. private _onAnimationEnd;
  69062. /**
  69063. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69064. */
  69065. isVisible: boolean;
  69066. /**
  69067. * Gets or sets the sprite size
  69068. */
  69069. size: number;
  69070. /**
  69071. * Creates a new Sprite
  69072. * @param name defines the name
  69073. * @param manager defines the manager
  69074. */
  69075. constructor(
  69076. /** defines the name */
  69077. name: string, manager: ISpriteManager);
  69078. /**
  69079. * Starts an animation
  69080. * @param from defines the initial key
  69081. * @param to defines the end key
  69082. * @param loop defines if the animation must loop
  69083. * @param delay defines the start delay (in ms)
  69084. * @param onAnimationEnd defines a callback to call when animation ends
  69085. */
  69086. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69087. /** Stops current animation (if any) */
  69088. stopAnimation(): void;
  69089. /** @hidden */
  69090. _animate(deltaTime: number): void;
  69091. /** Release associated resources */
  69092. dispose(): void;
  69093. }
  69094. }
  69095. declare module BABYLON {
  69096. /**
  69097. * Information about the result of picking within a scene
  69098. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69099. */
  69100. export class PickingInfo {
  69101. /** @hidden */
  69102. _pickingUnavailable: boolean;
  69103. /**
  69104. * If the pick collided with an object
  69105. */
  69106. hit: boolean;
  69107. /**
  69108. * Distance away where the pick collided
  69109. */
  69110. distance: number;
  69111. /**
  69112. * The location of pick collision
  69113. */
  69114. pickedPoint: Nullable<Vector3>;
  69115. /**
  69116. * The mesh corresponding the the pick collision
  69117. */
  69118. pickedMesh: Nullable<AbstractMesh>;
  69119. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69120. bu: number;
  69121. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69122. bv: number;
  69123. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69124. faceId: number;
  69125. /** Id of the the submesh that was picked */
  69126. subMeshId: number;
  69127. /** If a sprite was picked, this will be the sprite the pick collided with */
  69128. pickedSprite: Nullable<Sprite>;
  69129. /**
  69130. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69131. */
  69132. originMesh: Nullable<AbstractMesh>;
  69133. /**
  69134. * The ray that was used to perform the picking.
  69135. */
  69136. ray: Nullable<Ray>;
  69137. /**
  69138. * Gets the normal correspodning to the face the pick collided with
  69139. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69140. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69141. * @returns The normal correspodning to the face the pick collided with
  69142. */
  69143. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69144. /**
  69145. * Gets the texture coordinates of where the pick occured
  69146. * @returns the vector containing the coordnates of the texture
  69147. */
  69148. getTextureCoordinates(): Nullable<Vector2>;
  69149. }
  69150. }
  69151. declare module BABYLON {
  69152. /**
  69153. * Gather the list of pointer event types as constants.
  69154. */
  69155. export class PointerEventTypes {
  69156. /**
  69157. * 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.
  69158. */
  69159. static readonly POINTERDOWN: number;
  69160. /**
  69161. * The pointerup event is fired when a pointer is no longer active.
  69162. */
  69163. static readonly POINTERUP: number;
  69164. /**
  69165. * The pointermove event is fired when a pointer changes coordinates.
  69166. */
  69167. static readonly POINTERMOVE: number;
  69168. /**
  69169. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69170. */
  69171. static readonly POINTERWHEEL: number;
  69172. /**
  69173. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69174. */
  69175. static readonly POINTERPICK: number;
  69176. /**
  69177. * The pointertap event is fired when a the object has been touched and released without drag.
  69178. */
  69179. static readonly POINTERTAP: number;
  69180. /**
  69181. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69182. */
  69183. static readonly POINTERDOUBLETAP: number;
  69184. }
  69185. /**
  69186. * Base class of pointer info types.
  69187. */
  69188. export class PointerInfoBase {
  69189. /**
  69190. * Defines the type of event (PointerEventTypes)
  69191. */
  69192. type: number;
  69193. /**
  69194. * Defines the related dom event
  69195. */
  69196. event: PointerEvent | MouseWheelEvent;
  69197. /**
  69198. * Instantiates the base class of pointers info.
  69199. * @param type Defines the type of event (PointerEventTypes)
  69200. * @param event Defines the related dom event
  69201. */
  69202. constructor(
  69203. /**
  69204. * Defines the type of event (PointerEventTypes)
  69205. */
  69206. type: number,
  69207. /**
  69208. * Defines the related dom event
  69209. */
  69210. event: PointerEvent | MouseWheelEvent);
  69211. }
  69212. /**
  69213. * This class is used to store pointer related info for the onPrePointerObservable event.
  69214. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69215. */
  69216. export class PointerInfoPre extends PointerInfoBase {
  69217. /**
  69218. * Ray from a pointer if availible (eg. 6dof controller)
  69219. */
  69220. ray: Nullable<Ray>;
  69221. /**
  69222. * Defines the local position of the pointer on the canvas.
  69223. */
  69224. localPosition: Vector2;
  69225. /**
  69226. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69227. */
  69228. skipOnPointerObservable: boolean;
  69229. /**
  69230. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69231. * @param type Defines the type of event (PointerEventTypes)
  69232. * @param event Defines the related dom event
  69233. * @param localX Defines the local x coordinates of the pointer when the event occured
  69234. * @param localY Defines the local y coordinates of the pointer when the event occured
  69235. */
  69236. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69237. }
  69238. /**
  69239. * This type contains all the data related to a pointer event in Babylon.js.
  69240. * 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.
  69241. */
  69242. export class PointerInfo extends PointerInfoBase {
  69243. /**
  69244. * Defines the picking info associated to the info (if any)\
  69245. */
  69246. pickInfo: Nullable<PickingInfo>;
  69247. /**
  69248. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69249. * @param type Defines the type of event (PointerEventTypes)
  69250. * @param event Defines the related dom event
  69251. * @param pickInfo Defines the picking info associated to the info (if any)\
  69252. */
  69253. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69254. /**
  69255. * Defines the picking info associated to the info (if any)\
  69256. */
  69257. pickInfo: Nullable<PickingInfo>);
  69258. }
  69259. /**
  69260. * Data relating to a touch event on the screen.
  69261. */
  69262. export interface PointerTouch {
  69263. /**
  69264. * X coordinate of touch.
  69265. */
  69266. x: number;
  69267. /**
  69268. * Y coordinate of touch.
  69269. */
  69270. y: number;
  69271. /**
  69272. * Id of touch. Unique for each finger.
  69273. */
  69274. pointerId: number;
  69275. /**
  69276. * Event type passed from DOM.
  69277. */
  69278. type: any;
  69279. }
  69280. }
  69281. declare module BABYLON {
  69282. /**
  69283. * Manage the mouse inputs to control the movement of a free camera.
  69284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69285. */
  69286. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69287. /**
  69288. * Define if touch is enabled in the mouse input
  69289. */
  69290. touchEnabled: boolean;
  69291. /**
  69292. * Defines the camera the input is attached to.
  69293. */
  69294. camera: FreeCamera;
  69295. /**
  69296. * Defines the buttons associated with the input to handle camera move.
  69297. */
  69298. buttons: number[];
  69299. /**
  69300. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69301. */
  69302. angularSensibility: number;
  69303. private _pointerInput;
  69304. private _onMouseMove;
  69305. private _observer;
  69306. private previousPosition;
  69307. /**
  69308. * Manage the mouse inputs to control the movement of a free camera.
  69309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69310. * @param touchEnabled Defines if touch is enabled or not
  69311. */
  69312. constructor(
  69313. /**
  69314. * Define if touch is enabled in the mouse input
  69315. */
  69316. touchEnabled?: boolean);
  69317. /**
  69318. * Attach the input controls to a specific dom element to get the input from.
  69319. * @param element Defines the element the controls should be listened from
  69320. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69321. */
  69322. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69323. /**
  69324. * Detach the current controls from the specified dom element.
  69325. * @param element Defines the element to stop listening the inputs from
  69326. */
  69327. detachControl(element: Nullable<HTMLElement>): void;
  69328. /**
  69329. * Gets the class name of the current intput.
  69330. * @returns the class name
  69331. */
  69332. getClassName(): string;
  69333. /**
  69334. * Get the friendly name associated with the input class.
  69335. * @returns the input friendly name
  69336. */
  69337. getSimpleName(): string;
  69338. }
  69339. }
  69340. declare module BABYLON {
  69341. /**
  69342. * Manage the touch inputs to control the movement of a free camera.
  69343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69344. */
  69345. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69346. /**
  69347. * Defines the camera the input is attached to.
  69348. */
  69349. camera: FreeCamera;
  69350. /**
  69351. * Defines the touch sensibility for rotation.
  69352. * The higher the faster.
  69353. */
  69354. touchAngularSensibility: number;
  69355. /**
  69356. * Defines the touch sensibility for move.
  69357. * The higher the faster.
  69358. */
  69359. touchMoveSensibility: number;
  69360. private _offsetX;
  69361. private _offsetY;
  69362. private _pointerPressed;
  69363. private _pointerInput;
  69364. private _observer;
  69365. private _onLostFocus;
  69366. /**
  69367. * Attach the input controls to a specific dom element to get the input from.
  69368. * @param element Defines the element the controls should be listened from
  69369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69370. */
  69371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69372. /**
  69373. * Detach the current controls from the specified dom element.
  69374. * @param element Defines the element to stop listening the inputs from
  69375. */
  69376. detachControl(element: Nullable<HTMLElement>): void;
  69377. /**
  69378. * Update the current camera state depending on the inputs that have been used this frame.
  69379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69380. */
  69381. checkInputs(): void;
  69382. /**
  69383. * Gets the class name of the current intput.
  69384. * @returns the class name
  69385. */
  69386. getClassName(): string;
  69387. /**
  69388. * Get the friendly name associated with the input class.
  69389. * @returns the input friendly name
  69390. */
  69391. getSimpleName(): string;
  69392. }
  69393. }
  69394. declare module BABYLON {
  69395. /**
  69396. * Default Inputs manager for the FreeCamera.
  69397. * It groups all the default supported inputs for ease of use.
  69398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69399. */
  69400. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69401. /**
  69402. * Instantiates a new FreeCameraInputsManager.
  69403. * @param camera Defines the camera the inputs belong to
  69404. */
  69405. constructor(camera: FreeCamera);
  69406. /**
  69407. * Add keyboard input support to the input manager.
  69408. * @returns the current input manager
  69409. */
  69410. addKeyboard(): FreeCameraInputsManager;
  69411. /**
  69412. * Add mouse input support to the input manager.
  69413. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69414. * @returns the current input manager
  69415. */
  69416. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69417. /**
  69418. * Add touch input support to the input manager.
  69419. * @returns the current input manager
  69420. */
  69421. addTouch(): FreeCameraInputsManager;
  69422. }
  69423. }
  69424. declare module BABYLON {
  69425. /**
  69426. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69427. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69428. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69429. */
  69430. export class FreeCamera extends TargetCamera {
  69431. /**
  69432. * Define the collision ellipsoid of the camera.
  69433. * This is helpful to simulate a camera body like the player body around the camera
  69434. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69435. */
  69436. ellipsoid: Vector3;
  69437. /**
  69438. * Define an offset for the position of the ellipsoid around the camera.
  69439. * This can be helpful to determine the center of the body near the gravity center of the body
  69440. * instead of its head.
  69441. */
  69442. ellipsoidOffset: Vector3;
  69443. /**
  69444. * Enable or disable collisions of the camera with the rest of the scene objects.
  69445. */
  69446. checkCollisions: boolean;
  69447. /**
  69448. * Enable or disable gravity on the camera.
  69449. */
  69450. applyGravity: boolean;
  69451. /**
  69452. * Define the input manager associated to the camera.
  69453. */
  69454. inputs: FreeCameraInputsManager;
  69455. /**
  69456. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69457. * Higher values reduce sensitivity.
  69458. */
  69459. /**
  69460. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69461. * Higher values reduce sensitivity.
  69462. */
  69463. angularSensibility: number;
  69464. /**
  69465. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69466. */
  69467. keysUp: number[];
  69468. /**
  69469. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69470. */
  69471. keysDown: number[];
  69472. /**
  69473. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69474. */
  69475. keysLeft: number[];
  69476. /**
  69477. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69478. */
  69479. keysRight: number[];
  69480. /**
  69481. * Event raised when the camera collide with a mesh in the scene.
  69482. */
  69483. onCollide: (collidedMesh: AbstractMesh) => void;
  69484. private _collider;
  69485. private _needMoveForGravity;
  69486. private _oldPosition;
  69487. private _diffPosition;
  69488. private _newPosition;
  69489. /** @hidden */
  69490. _localDirection: Vector3;
  69491. /** @hidden */
  69492. _transformedDirection: Vector3;
  69493. /**
  69494. * Instantiates a Free Camera.
  69495. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69496. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69497. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69498. * @param name Define the name of the camera in the scene
  69499. * @param position Define the start position of the camera in the scene
  69500. * @param scene Define the scene the camera belongs to
  69501. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69502. */
  69503. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69504. /**
  69505. * Attached controls to the current camera.
  69506. * @param element Defines the element the controls should be listened from
  69507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69508. */
  69509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69510. /**
  69511. * Detach the current controls from the camera.
  69512. * The camera will stop reacting to inputs.
  69513. * @param element Defines the element to stop listening the inputs from
  69514. */
  69515. detachControl(element: HTMLElement): void;
  69516. private _collisionMask;
  69517. /**
  69518. * Define a collision mask to limit the list of object the camera can collide with
  69519. */
  69520. collisionMask: number;
  69521. /** @hidden */
  69522. _collideWithWorld(displacement: Vector3): void;
  69523. private _onCollisionPositionChange;
  69524. /** @hidden */
  69525. _checkInputs(): void;
  69526. /** @hidden */
  69527. _decideIfNeedsToMove(): boolean;
  69528. /** @hidden */
  69529. _updatePosition(): void;
  69530. /**
  69531. * Destroy the camera and release the current resources hold by it.
  69532. */
  69533. dispose(): void;
  69534. /**
  69535. * Gets the current object class name.
  69536. * @return the class name
  69537. */
  69538. getClassName(): string;
  69539. }
  69540. }
  69541. declare module BABYLON {
  69542. /**
  69543. * Represents a gamepad control stick position
  69544. */
  69545. export class StickValues {
  69546. /**
  69547. * The x component of the control stick
  69548. */
  69549. x: number;
  69550. /**
  69551. * The y component of the control stick
  69552. */
  69553. y: number;
  69554. /**
  69555. * Initializes the gamepad x and y control stick values
  69556. * @param x The x component of the gamepad control stick value
  69557. * @param y The y component of the gamepad control stick value
  69558. */
  69559. constructor(
  69560. /**
  69561. * The x component of the control stick
  69562. */
  69563. x: number,
  69564. /**
  69565. * The y component of the control stick
  69566. */
  69567. y: number);
  69568. }
  69569. /**
  69570. * An interface which manages callbacks for gamepad button changes
  69571. */
  69572. export interface GamepadButtonChanges {
  69573. /**
  69574. * Called when a gamepad has been changed
  69575. */
  69576. changed: boolean;
  69577. /**
  69578. * Called when a gamepad press event has been triggered
  69579. */
  69580. pressChanged: boolean;
  69581. /**
  69582. * Called when a touch event has been triggered
  69583. */
  69584. touchChanged: boolean;
  69585. /**
  69586. * Called when a value has changed
  69587. */
  69588. valueChanged: boolean;
  69589. }
  69590. /**
  69591. * Represents a gamepad
  69592. */
  69593. export class Gamepad {
  69594. /**
  69595. * The id of the gamepad
  69596. */
  69597. id: string;
  69598. /**
  69599. * The index of the gamepad
  69600. */
  69601. index: number;
  69602. /**
  69603. * The browser gamepad
  69604. */
  69605. browserGamepad: any;
  69606. /**
  69607. * Specifies what type of gamepad this represents
  69608. */
  69609. type: number;
  69610. private _leftStick;
  69611. private _rightStick;
  69612. /** @hidden */
  69613. _isConnected: boolean;
  69614. private _leftStickAxisX;
  69615. private _leftStickAxisY;
  69616. private _rightStickAxisX;
  69617. private _rightStickAxisY;
  69618. /**
  69619. * Triggered when the left control stick has been changed
  69620. */
  69621. private _onleftstickchanged;
  69622. /**
  69623. * Triggered when the right control stick has been changed
  69624. */
  69625. private _onrightstickchanged;
  69626. /**
  69627. * Represents a gamepad controller
  69628. */
  69629. static GAMEPAD: number;
  69630. /**
  69631. * Represents a generic controller
  69632. */
  69633. static GENERIC: number;
  69634. /**
  69635. * Represents an XBox controller
  69636. */
  69637. static XBOX: number;
  69638. /**
  69639. * Represents a pose-enabled controller
  69640. */
  69641. static POSE_ENABLED: number;
  69642. /**
  69643. * Specifies whether the left control stick should be Y-inverted
  69644. */
  69645. protected _invertLeftStickY: boolean;
  69646. /**
  69647. * Specifies if the gamepad has been connected
  69648. */
  69649. readonly isConnected: boolean;
  69650. /**
  69651. * Initializes the gamepad
  69652. * @param id The id of the gamepad
  69653. * @param index The index of the gamepad
  69654. * @param browserGamepad The browser gamepad
  69655. * @param leftStickX The x component of the left joystick
  69656. * @param leftStickY The y component of the left joystick
  69657. * @param rightStickX The x component of the right joystick
  69658. * @param rightStickY The y component of the right joystick
  69659. */
  69660. constructor(
  69661. /**
  69662. * The id of the gamepad
  69663. */
  69664. id: string,
  69665. /**
  69666. * The index of the gamepad
  69667. */
  69668. index: number,
  69669. /**
  69670. * The browser gamepad
  69671. */
  69672. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69673. /**
  69674. * Callback triggered when the left joystick has changed
  69675. * @param callback
  69676. */
  69677. onleftstickchanged(callback: (values: StickValues) => void): void;
  69678. /**
  69679. * Callback triggered when the right joystick has changed
  69680. * @param callback
  69681. */
  69682. onrightstickchanged(callback: (values: StickValues) => void): void;
  69683. /**
  69684. * Gets the left joystick
  69685. */
  69686. /**
  69687. * Sets the left joystick values
  69688. */
  69689. leftStick: StickValues;
  69690. /**
  69691. * Gets the right joystick
  69692. */
  69693. /**
  69694. * Sets the right joystick value
  69695. */
  69696. rightStick: StickValues;
  69697. /**
  69698. * Updates the gamepad joystick positions
  69699. */
  69700. update(): void;
  69701. /**
  69702. * Disposes the gamepad
  69703. */
  69704. dispose(): void;
  69705. }
  69706. /**
  69707. * Represents a generic gamepad
  69708. */
  69709. export class GenericPad extends Gamepad {
  69710. private _buttons;
  69711. private _onbuttondown;
  69712. private _onbuttonup;
  69713. /**
  69714. * Observable triggered when a button has been pressed
  69715. */
  69716. onButtonDownObservable: Observable<number>;
  69717. /**
  69718. * Observable triggered when a button has been released
  69719. */
  69720. onButtonUpObservable: Observable<number>;
  69721. /**
  69722. * Callback triggered when a button has been pressed
  69723. * @param callback Called when a button has been pressed
  69724. */
  69725. onbuttondown(callback: (buttonPressed: number) => void): void;
  69726. /**
  69727. * Callback triggered when a button has been released
  69728. * @param callback Called when a button has been released
  69729. */
  69730. onbuttonup(callback: (buttonReleased: number) => void): void;
  69731. /**
  69732. * Initializes the generic gamepad
  69733. * @param id The id of the generic gamepad
  69734. * @param index The index of the generic gamepad
  69735. * @param browserGamepad The browser gamepad
  69736. */
  69737. constructor(id: string, index: number, browserGamepad: any);
  69738. private _setButtonValue;
  69739. /**
  69740. * Updates the generic gamepad
  69741. */
  69742. update(): void;
  69743. /**
  69744. * Disposes the generic gamepad
  69745. */
  69746. dispose(): void;
  69747. }
  69748. }
  69749. declare module BABYLON {
  69750. /**
  69751. * Defines the types of pose enabled controllers that are supported
  69752. */
  69753. export enum PoseEnabledControllerType {
  69754. /**
  69755. * HTC Vive
  69756. */
  69757. VIVE = 0,
  69758. /**
  69759. * Oculus Rift
  69760. */
  69761. OCULUS = 1,
  69762. /**
  69763. * Windows mixed reality
  69764. */
  69765. WINDOWS = 2,
  69766. /**
  69767. * Samsung gear VR
  69768. */
  69769. GEAR_VR = 3,
  69770. /**
  69771. * Google Daydream
  69772. */
  69773. DAYDREAM = 4,
  69774. /**
  69775. * Generic
  69776. */
  69777. GENERIC = 5
  69778. }
  69779. /**
  69780. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69781. */
  69782. export interface MutableGamepadButton {
  69783. /**
  69784. * Value of the button/trigger
  69785. */
  69786. value: number;
  69787. /**
  69788. * If the button/trigger is currently touched
  69789. */
  69790. touched: boolean;
  69791. /**
  69792. * If the button/trigger is currently pressed
  69793. */
  69794. pressed: boolean;
  69795. }
  69796. /**
  69797. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69798. * @hidden
  69799. */
  69800. export interface ExtendedGamepadButton extends GamepadButton {
  69801. /**
  69802. * If the button/trigger is currently pressed
  69803. */
  69804. readonly pressed: boolean;
  69805. /**
  69806. * If the button/trigger is currently touched
  69807. */
  69808. readonly touched: boolean;
  69809. /**
  69810. * Value of the button/trigger
  69811. */
  69812. readonly value: number;
  69813. }
  69814. /** @hidden */
  69815. export interface _GamePadFactory {
  69816. /**
  69817. * Returns wether or not the current gamepad can be created for this type of controller.
  69818. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69819. * @returns true if it can be created, otherwise false
  69820. */
  69821. canCreate(gamepadInfo: any): boolean;
  69822. /**
  69823. * Creates a new instance of the Gamepad.
  69824. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69825. * @returns the new gamepad instance
  69826. */
  69827. create(gamepadInfo: any): Gamepad;
  69828. }
  69829. /**
  69830. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69831. */
  69832. export class PoseEnabledControllerHelper {
  69833. /** @hidden */
  69834. static _ControllerFactories: _GamePadFactory[];
  69835. /** @hidden */
  69836. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69837. /**
  69838. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69839. * @param vrGamepad the gamepad to initialized
  69840. * @returns a vr controller of the type the gamepad identified as
  69841. */
  69842. static InitiateController(vrGamepad: any): Gamepad;
  69843. }
  69844. /**
  69845. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69846. */
  69847. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69848. private _deviceRoomPosition;
  69849. private _deviceRoomRotationQuaternion;
  69850. /**
  69851. * The device position in babylon space
  69852. */
  69853. devicePosition: Vector3;
  69854. /**
  69855. * The device rotation in babylon space
  69856. */
  69857. deviceRotationQuaternion: Quaternion;
  69858. /**
  69859. * The scale factor of the device in babylon space
  69860. */
  69861. deviceScaleFactor: number;
  69862. /**
  69863. * (Likely devicePosition should be used instead) The device position in its room space
  69864. */
  69865. position: Vector3;
  69866. /**
  69867. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69868. */
  69869. rotationQuaternion: Quaternion;
  69870. /**
  69871. * The type of controller (Eg. Windows mixed reality)
  69872. */
  69873. controllerType: PoseEnabledControllerType;
  69874. protected _calculatedPosition: Vector3;
  69875. private _calculatedRotation;
  69876. /**
  69877. * The raw pose from the device
  69878. */
  69879. rawPose: DevicePose;
  69880. private _trackPosition;
  69881. private _maxRotationDistFromHeadset;
  69882. private _draggedRoomRotation;
  69883. /**
  69884. * @hidden
  69885. */
  69886. _disableTrackPosition(fixedPosition: Vector3): void;
  69887. /**
  69888. * Internal, the mesh attached to the controller
  69889. * @hidden
  69890. */
  69891. _mesh: Nullable<AbstractMesh>;
  69892. private _poseControlledCamera;
  69893. private _leftHandSystemQuaternion;
  69894. /**
  69895. * Internal, matrix used to convert room space to babylon space
  69896. * @hidden
  69897. */
  69898. _deviceToWorld: Matrix;
  69899. /**
  69900. * Node to be used when casting a ray from the controller
  69901. * @hidden
  69902. */
  69903. _pointingPoseNode: Nullable<TransformNode>;
  69904. /**
  69905. * Name of the child mesh that can be used to cast a ray from the controller
  69906. */
  69907. static readonly POINTING_POSE: string;
  69908. /**
  69909. * Creates a new PoseEnabledController from a gamepad
  69910. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69911. */
  69912. constructor(browserGamepad: any);
  69913. private _workingMatrix;
  69914. /**
  69915. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69916. */
  69917. update(): void;
  69918. /**
  69919. * Updates only the pose device and mesh without doing any button event checking
  69920. */
  69921. protected _updatePoseAndMesh(): void;
  69922. /**
  69923. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69924. * @param poseData raw pose fromthe device
  69925. */
  69926. updateFromDevice(poseData: DevicePose): void;
  69927. /**
  69928. * @hidden
  69929. */
  69930. _meshAttachedObservable: Observable<AbstractMesh>;
  69931. /**
  69932. * Attaches a mesh to the controller
  69933. * @param mesh the mesh to be attached
  69934. */
  69935. attachToMesh(mesh: AbstractMesh): void;
  69936. /**
  69937. * Attaches the controllers mesh to a camera
  69938. * @param camera the camera the mesh should be attached to
  69939. */
  69940. attachToPoseControlledCamera(camera: TargetCamera): void;
  69941. /**
  69942. * Disposes of the controller
  69943. */
  69944. dispose(): void;
  69945. /**
  69946. * The mesh that is attached to the controller
  69947. */
  69948. readonly mesh: Nullable<AbstractMesh>;
  69949. /**
  69950. * Gets the ray of the controller in the direction the controller is pointing
  69951. * @param length the length the resulting ray should be
  69952. * @returns a ray in the direction the controller is pointing
  69953. */
  69954. getForwardRay(length?: number): Ray;
  69955. }
  69956. }
  69957. declare module BABYLON {
  69958. /**
  69959. * Defines the WebVRController object that represents controllers tracked in 3D space
  69960. */
  69961. export abstract class WebVRController extends PoseEnabledController {
  69962. /**
  69963. * Internal, the default controller model for the controller
  69964. */
  69965. protected _defaultModel: AbstractMesh;
  69966. /**
  69967. * Fired when the trigger state has changed
  69968. */
  69969. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  69970. /**
  69971. * Fired when the main button state has changed
  69972. */
  69973. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69974. /**
  69975. * Fired when the secondary button state has changed
  69976. */
  69977. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69978. /**
  69979. * Fired when the pad state has changed
  69980. */
  69981. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  69982. /**
  69983. * Fired when controllers stick values have changed
  69984. */
  69985. onPadValuesChangedObservable: Observable<StickValues>;
  69986. /**
  69987. * Array of button availible on the controller
  69988. */
  69989. protected _buttons: Array<MutableGamepadButton>;
  69990. private _onButtonStateChange;
  69991. /**
  69992. * Fired when a controller button's state has changed
  69993. * @param callback the callback containing the button that was modified
  69994. */
  69995. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  69996. /**
  69997. * X and Y axis corrisponding to the controllers joystick
  69998. */
  69999. pad: StickValues;
  70000. /**
  70001. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70002. */
  70003. hand: string;
  70004. /**
  70005. * The default controller model for the controller
  70006. */
  70007. readonly defaultModel: AbstractMesh;
  70008. /**
  70009. * Creates a new WebVRController from a gamepad
  70010. * @param vrGamepad the gamepad that the WebVRController should be created from
  70011. */
  70012. constructor(vrGamepad: any);
  70013. /**
  70014. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70015. */
  70016. update(): void;
  70017. /**
  70018. * Function to be called when a button is modified
  70019. */
  70020. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70021. /**
  70022. * Loads a mesh and attaches it to the controller
  70023. * @param scene the scene the mesh should be added to
  70024. * @param meshLoaded callback for when the mesh has been loaded
  70025. */
  70026. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70027. private _setButtonValue;
  70028. private _changes;
  70029. private _checkChanges;
  70030. /**
  70031. * Disposes of th webVRCOntroller
  70032. */
  70033. dispose(): void;
  70034. }
  70035. }
  70036. declare module BABYLON {
  70037. /**
  70038. * The HemisphericLight simulates the ambient environment light,
  70039. * so the passed direction is the light reflection direction, not the incoming direction.
  70040. */
  70041. export class HemisphericLight extends Light {
  70042. /**
  70043. * The groundColor is the light in the opposite direction to the one specified during creation.
  70044. * 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.
  70045. */
  70046. groundColor: Color3;
  70047. /**
  70048. * The light reflection direction, not the incoming direction.
  70049. */
  70050. direction: Vector3;
  70051. /**
  70052. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70053. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70054. * The HemisphericLight can't cast shadows.
  70055. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70056. * @param name The friendly name of the light
  70057. * @param direction The direction of the light reflection
  70058. * @param scene The scene the light belongs to
  70059. */
  70060. constructor(name: string, direction: Vector3, scene: Scene);
  70061. protected _buildUniformLayout(): void;
  70062. /**
  70063. * Returns the string "HemisphericLight".
  70064. * @return The class name
  70065. */
  70066. getClassName(): string;
  70067. /**
  70068. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70069. * Returns the updated direction.
  70070. * @param target The target the direction should point to
  70071. * @return The computed direction
  70072. */
  70073. setDirectionToTarget(target: Vector3): Vector3;
  70074. /**
  70075. * Returns the shadow generator associated to the light.
  70076. * @returns Always null for hemispheric lights because it does not support shadows.
  70077. */
  70078. getShadowGenerator(): Nullable<IShadowGenerator>;
  70079. /**
  70080. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70081. * @param effect The effect to update
  70082. * @param lightIndex The index of the light in the effect to update
  70083. * @returns The hemispheric light
  70084. */
  70085. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70086. /**
  70087. * Computes the world matrix of the node
  70088. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70089. * @param useWasUpdatedFlag defines a reserved property
  70090. * @returns the world matrix
  70091. */
  70092. computeWorldMatrix(): Matrix;
  70093. /**
  70094. * Returns the integer 3.
  70095. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70096. */
  70097. getTypeID(): number;
  70098. /**
  70099. * Prepares the list of defines specific to the light type.
  70100. * @param defines the list of defines
  70101. * @param lightIndex defines the index of the light for the effect
  70102. */
  70103. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70104. }
  70105. }
  70106. declare module BABYLON {
  70107. /**
  70108. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70109. * IMPORTANT!! The data is right-hand data.
  70110. * @export
  70111. * @interface DevicePose
  70112. */
  70113. export interface DevicePose {
  70114. /**
  70115. * The position of the device, values in array are [x,y,z].
  70116. */
  70117. readonly position: Nullable<Float32Array>;
  70118. /**
  70119. * The linearVelocity of the device, values in array are [x,y,z].
  70120. */
  70121. readonly linearVelocity: Nullable<Float32Array>;
  70122. /**
  70123. * The linearAcceleration of the device, values in array are [x,y,z].
  70124. */
  70125. readonly linearAcceleration: Nullable<Float32Array>;
  70126. /**
  70127. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70128. */
  70129. readonly orientation: Nullable<Float32Array>;
  70130. /**
  70131. * The angularVelocity of the device, values in array are [x,y,z].
  70132. */
  70133. readonly angularVelocity: Nullable<Float32Array>;
  70134. /**
  70135. * The angularAcceleration of the device, values in array are [x,y,z].
  70136. */
  70137. readonly angularAcceleration: Nullable<Float32Array>;
  70138. }
  70139. /**
  70140. * Interface representing a pose controlled object in Babylon.
  70141. * A pose controlled object has both regular pose values as well as pose values
  70142. * from an external device such as a VR head mounted display
  70143. */
  70144. export interface PoseControlled {
  70145. /**
  70146. * The position of the object in babylon space.
  70147. */
  70148. position: Vector3;
  70149. /**
  70150. * The rotation quaternion of the object in babylon space.
  70151. */
  70152. rotationQuaternion: Quaternion;
  70153. /**
  70154. * The position of the device in babylon space.
  70155. */
  70156. devicePosition?: Vector3;
  70157. /**
  70158. * The rotation quaternion of the device in babylon space.
  70159. */
  70160. deviceRotationQuaternion: Quaternion;
  70161. /**
  70162. * The raw pose coming from the device.
  70163. */
  70164. rawPose: Nullable<DevicePose>;
  70165. /**
  70166. * The scale of the device to be used when translating from device space to babylon space.
  70167. */
  70168. deviceScaleFactor: number;
  70169. /**
  70170. * Updates the poseControlled values based on the input device pose.
  70171. * @param poseData the pose data to update the object with
  70172. */
  70173. updateFromDevice(poseData: DevicePose): void;
  70174. }
  70175. /**
  70176. * Set of options to customize the webVRCamera
  70177. */
  70178. export interface WebVROptions {
  70179. /**
  70180. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70181. */
  70182. trackPosition?: boolean;
  70183. /**
  70184. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70185. */
  70186. positionScale?: number;
  70187. /**
  70188. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70189. */
  70190. displayName?: string;
  70191. /**
  70192. * Should the native controller meshes be initialized. (default: true)
  70193. */
  70194. controllerMeshes?: boolean;
  70195. /**
  70196. * Creating a default HemiLight only on controllers. (default: true)
  70197. */
  70198. defaultLightingOnControllers?: boolean;
  70199. /**
  70200. * If you don't want to use the default VR button of the helper. (default: false)
  70201. */
  70202. useCustomVRButton?: boolean;
  70203. /**
  70204. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70205. */
  70206. customVRButton?: HTMLButtonElement;
  70207. /**
  70208. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70209. */
  70210. rayLength?: number;
  70211. /**
  70212. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70213. */
  70214. defaultHeight?: number;
  70215. }
  70216. /**
  70217. * This represents a WebVR camera.
  70218. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70219. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70220. */
  70221. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70222. private webVROptions;
  70223. /**
  70224. * @hidden
  70225. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70226. */
  70227. _vrDevice: any;
  70228. /**
  70229. * The rawPose of the vrDevice.
  70230. */
  70231. rawPose: Nullable<DevicePose>;
  70232. private _onVREnabled;
  70233. private _specsVersion;
  70234. private _attached;
  70235. private _frameData;
  70236. protected _descendants: Array<Node>;
  70237. private _deviceRoomPosition;
  70238. /** @hidden */
  70239. _deviceRoomRotationQuaternion: Quaternion;
  70240. private _standingMatrix;
  70241. /**
  70242. * Represents device position in babylon space.
  70243. */
  70244. devicePosition: Vector3;
  70245. /**
  70246. * Represents device rotation in babylon space.
  70247. */
  70248. deviceRotationQuaternion: Quaternion;
  70249. /**
  70250. * The scale of the device to be used when translating from device space to babylon space.
  70251. */
  70252. deviceScaleFactor: number;
  70253. private _deviceToWorld;
  70254. private _worldToDevice;
  70255. /**
  70256. * References to the webVR controllers for the vrDevice.
  70257. */
  70258. controllers: Array<WebVRController>;
  70259. /**
  70260. * Emits an event when a controller is attached.
  70261. */
  70262. onControllersAttachedObservable: Observable<WebVRController[]>;
  70263. /**
  70264. * Emits an event when a controller's mesh has been loaded;
  70265. */
  70266. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70267. /**
  70268. * Emits an event when the HMD's pose has been updated.
  70269. */
  70270. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70271. private _poseSet;
  70272. /**
  70273. * If the rig cameras be used as parent instead of this camera.
  70274. */
  70275. rigParenting: boolean;
  70276. private _lightOnControllers;
  70277. private _defaultHeight?;
  70278. /**
  70279. * Instantiates a WebVRFreeCamera.
  70280. * @param name The name of the WebVRFreeCamera
  70281. * @param position The starting anchor position for the camera
  70282. * @param scene The scene the camera belongs to
  70283. * @param webVROptions a set of customizable options for the webVRCamera
  70284. */
  70285. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70286. /**
  70287. * Gets the device distance from the ground in meters.
  70288. * @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.
  70289. */
  70290. deviceDistanceToRoomGround(): number;
  70291. /**
  70292. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70293. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70294. */
  70295. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70296. /**
  70297. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70298. * @returns A promise with a boolean set to if the standing matrix is supported.
  70299. */
  70300. useStandingMatrixAsync(): Promise<boolean>;
  70301. /**
  70302. * Disposes the camera
  70303. */
  70304. dispose(): void;
  70305. /**
  70306. * Gets a vrController by name.
  70307. * @param name The name of the controller to retreive
  70308. * @returns the controller matching the name specified or null if not found
  70309. */
  70310. getControllerByName(name: string): Nullable<WebVRController>;
  70311. private _leftController;
  70312. /**
  70313. * The controller corrisponding to the users left hand.
  70314. */
  70315. readonly leftController: Nullable<WebVRController>;
  70316. private _rightController;
  70317. /**
  70318. * The controller corrisponding to the users right hand.
  70319. */
  70320. readonly rightController: Nullable<WebVRController>;
  70321. /**
  70322. * Casts a ray forward from the vrCamera's gaze.
  70323. * @param length Length of the ray (default: 100)
  70324. * @returns the ray corrisponding to the gaze
  70325. */
  70326. getForwardRay(length?: number): Ray;
  70327. /**
  70328. * @hidden
  70329. * Updates the camera based on device's frame data
  70330. */
  70331. _checkInputs(): void;
  70332. /**
  70333. * Updates the poseControlled values based on the input device pose.
  70334. * @param poseData Pose coming from the device
  70335. */
  70336. updateFromDevice(poseData: DevicePose): void;
  70337. private _htmlElementAttached;
  70338. private _detachIfAttached;
  70339. /**
  70340. * WebVR's attach control will start broadcasting frames to the device.
  70341. * Note that in certain browsers (chrome for example) this function must be called
  70342. * within a user-interaction callback. Example:
  70343. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70344. *
  70345. * @param element html element to attach the vrDevice to
  70346. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70347. */
  70348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70349. /**
  70350. * Detaches the camera from the html element and disables VR
  70351. *
  70352. * @param element html element to detach from
  70353. */
  70354. detachControl(element: HTMLElement): void;
  70355. /**
  70356. * @returns the name of this class
  70357. */
  70358. getClassName(): string;
  70359. /**
  70360. * Calls resetPose on the vrDisplay
  70361. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70362. */
  70363. resetToCurrentRotation(): void;
  70364. /**
  70365. * @hidden
  70366. * Updates the rig cameras (left and right eye)
  70367. */
  70368. _updateRigCameras(): void;
  70369. private _workingVector;
  70370. private _oneVector;
  70371. private _workingMatrix;
  70372. private updateCacheCalled;
  70373. private _correctPositionIfNotTrackPosition;
  70374. /**
  70375. * @hidden
  70376. * Updates the cached values of the camera
  70377. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70378. */
  70379. _updateCache(ignoreParentClass?: boolean): void;
  70380. /**
  70381. * @hidden
  70382. * Get current device position in babylon world
  70383. */
  70384. _computeDevicePosition(): void;
  70385. /**
  70386. * Updates the current device position and rotation in the babylon world
  70387. */
  70388. update(): void;
  70389. /**
  70390. * @hidden
  70391. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70392. * @returns an identity matrix
  70393. */
  70394. _getViewMatrix(): Matrix;
  70395. private _tmpMatrix;
  70396. /**
  70397. * This function is called by the two RIG cameras.
  70398. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70399. * @hidden
  70400. */
  70401. _getWebVRViewMatrix(): Matrix;
  70402. /** @hidden */
  70403. _getWebVRProjectionMatrix(): Matrix;
  70404. private _onGamepadConnectedObserver;
  70405. private _onGamepadDisconnectedObserver;
  70406. private _updateCacheWhenTrackingDisabledObserver;
  70407. /**
  70408. * Initializes the controllers and their meshes
  70409. */
  70410. initControllers(): void;
  70411. }
  70412. }
  70413. declare module BABYLON {
  70414. /**
  70415. * Size options for a post process
  70416. */
  70417. export type PostProcessOptions = {
  70418. width: number;
  70419. height: number;
  70420. };
  70421. /**
  70422. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70423. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70424. */
  70425. export class PostProcess {
  70426. /** Name of the PostProcess. */
  70427. name: string;
  70428. /**
  70429. * Gets or sets the unique id of the post process
  70430. */
  70431. uniqueId: number;
  70432. /**
  70433. * Width of the texture to apply the post process on
  70434. */
  70435. width: number;
  70436. /**
  70437. * Height of the texture to apply the post process on
  70438. */
  70439. height: number;
  70440. /**
  70441. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70442. * @hidden
  70443. */
  70444. _outputTexture: Nullable<InternalTexture>;
  70445. /**
  70446. * Sampling mode used by the shader
  70447. * See https://doc.babylonjs.com/classes/3.1/texture
  70448. */
  70449. renderTargetSamplingMode: number;
  70450. /**
  70451. * Clear color to use when screen clearing
  70452. */
  70453. clearColor: Color4;
  70454. /**
  70455. * If the buffer needs to be cleared before applying the post process. (default: true)
  70456. * Should be set to false if shader will overwrite all previous pixels.
  70457. */
  70458. autoClear: boolean;
  70459. /**
  70460. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70461. */
  70462. alphaMode: number;
  70463. /**
  70464. * Sets the setAlphaBlendConstants of the babylon engine
  70465. */
  70466. alphaConstants: Color4;
  70467. /**
  70468. * Animations to be used for the post processing
  70469. */
  70470. animations: Animation[];
  70471. /**
  70472. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70473. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70474. */
  70475. enablePixelPerfectMode: boolean;
  70476. /**
  70477. * Force the postprocess to be applied without taking in account viewport
  70478. */
  70479. forceFullscreenViewport: boolean;
  70480. /**
  70481. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70482. *
  70483. * | Value | Type | Description |
  70484. * | ----- | ----------------------------------- | ----------- |
  70485. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70486. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70487. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70488. *
  70489. */
  70490. scaleMode: number;
  70491. /**
  70492. * Force textures to be a power of two (default: false)
  70493. */
  70494. alwaysForcePOT: boolean;
  70495. private _samples;
  70496. /**
  70497. * Number of sample textures (default: 1)
  70498. */
  70499. samples: number;
  70500. /**
  70501. * Modify the scale of the post process to be the same as the viewport (default: false)
  70502. */
  70503. adaptScaleToCurrentViewport: boolean;
  70504. private _camera;
  70505. private _scene;
  70506. private _engine;
  70507. private _options;
  70508. private _reusable;
  70509. private _textureType;
  70510. /**
  70511. * Smart array of input and output textures for the post process.
  70512. * @hidden
  70513. */
  70514. _textures: SmartArray<InternalTexture>;
  70515. /**
  70516. * The index in _textures that corresponds to the output texture.
  70517. * @hidden
  70518. */
  70519. _currentRenderTextureInd: number;
  70520. private _effect;
  70521. private _samplers;
  70522. private _fragmentUrl;
  70523. private _vertexUrl;
  70524. private _parameters;
  70525. private _scaleRatio;
  70526. protected _indexParameters: any;
  70527. private _shareOutputWithPostProcess;
  70528. private _texelSize;
  70529. private _forcedOutputTexture;
  70530. /**
  70531. * Returns the fragment url or shader name used in the post process.
  70532. * @returns the fragment url or name in the shader store.
  70533. */
  70534. getEffectName(): string;
  70535. /**
  70536. * An event triggered when the postprocess is activated.
  70537. */
  70538. onActivateObservable: Observable<Camera>;
  70539. private _onActivateObserver;
  70540. /**
  70541. * A function that is added to the onActivateObservable
  70542. */
  70543. onActivate: Nullable<(camera: Camera) => void>;
  70544. /**
  70545. * An event triggered when the postprocess changes its size.
  70546. */
  70547. onSizeChangedObservable: Observable<PostProcess>;
  70548. private _onSizeChangedObserver;
  70549. /**
  70550. * A function that is added to the onSizeChangedObservable
  70551. */
  70552. onSizeChanged: (postProcess: PostProcess) => void;
  70553. /**
  70554. * An event triggered when the postprocess applies its effect.
  70555. */
  70556. onApplyObservable: Observable<Effect>;
  70557. private _onApplyObserver;
  70558. /**
  70559. * A function that is added to the onApplyObservable
  70560. */
  70561. onApply: (effect: Effect) => void;
  70562. /**
  70563. * An event triggered before rendering the postprocess
  70564. */
  70565. onBeforeRenderObservable: Observable<Effect>;
  70566. private _onBeforeRenderObserver;
  70567. /**
  70568. * A function that is added to the onBeforeRenderObservable
  70569. */
  70570. onBeforeRender: (effect: Effect) => void;
  70571. /**
  70572. * An event triggered after rendering the postprocess
  70573. */
  70574. onAfterRenderObservable: Observable<Effect>;
  70575. private _onAfterRenderObserver;
  70576. /**
  70577. * A function that is added to the onAfterRenderObservable
  70578. */
  70579. onAfterRender: (efect: Effect) => void;
  70580. /**
  70581. * 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
  70582. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70583. */
  70584. inputTexture: InternalTexture;
  70585. /**
  70586. * Gets the camera which post process is applied to.
  70587. * @returns The camera the post process is applied to.
  70588. */
  70589. getCamera(): Camera;
  70590. /**
  70591. * Gets the texel size of the postprocess.
  70592. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70593. */
  70594. readonly texelSize: Vector2;
  70595. /**
  70596. * Creates a new instance PostProcess
  70597. * @param name The name of the PostProcess.
  70598. * @param fragmentUrl The url of the fragment shader to be used.
  70599. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70600. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70601. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70602. * @param camera The camera to apply the render pass to.
  70603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70604. * @param engine The engine which the post process will be applied. (default: current engine)
  70605. * @param reusable If the post process can be reused on the same frame. (default: false)
  70606. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70607. * @param textureType Type of textures used when performing the post process. (default: 0)
  70608. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70609. * @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
  70610. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70611. */
  70612. constructor(
  70613. /** Name of the PostProcess. */
  70614. 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);
  70615. /**
  70616. * Gets a string idenfifying the name of the class
  70617. * @returns "PostProcess" string
  70618. */
  70619. getClassName(): string;
  70620. /**
  70621. * Gets the engine which this post process belongs to.
  70622. * @returns The engine the post process was enabled with.
  70623. */
  70624. getEngine(): Engine;
  70625. /**
  70626. * The effect that is created when initializing the post process.
  70627. * @returns The created effect corrisponding the the postprocess.
  70628. */
  70629. getEffect(): Effect;
  70630. /**
  70631. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70632. * @param postProcess The post process to share the output with.
  70633. * @returns This post process.
  70634. */
  70635. shareOutputWith(postProcess: PostProcess): PostProcess;
  70636. /**
  70637. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70638. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70639. */
  70640. useOwnOutput(): void;
  70641. /**
  70642. * Updates the effect with the current post process compile time values and recompiles the shader.
  70643. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70644. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70645. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70646. * @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
  70647. * @param onCompiled Called when the shader has been compiled.
  70648. * @param onError Called if there is an error when compiling a shader.
  70649. */
  70650. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70651. /**
  70652. * The post process is reusable if it can be used multiple times within one frame.
  70653. * @returns If the post process is reusable
  70654. */
  70655. isReusable(): boolean;
  70656. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70657. markTextureDirty(): void;
  70658. /**
  70659. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70660. * 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.
  70661. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70662. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70663. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70664. * @returns The target texture that was bound to be written to.
  70665. */
  70666. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70667. /**
  70668. * If the post process is supported.
  70669. */
  70670. readonly isSupported: boolean;
  70671. /**
  70672. * The aspect ratio of the output texture.
  70673. */
  70674. readonly aspectRatio: number;
  70675. /**
  70676. * Get a value indicating if the post-process is ready to be used
  70677. * @returns true if the post-process is ready (shader is compiled)
  70678. */
  70679. isReady(): boolean;
  70680. /**
  70681. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70682. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70683. */
  70684. apply(): Nullable<Effect>;
  70685. private _disposeTextures;
  70686. /**
  70687. * Disposes the post process.
  70688. * @param camera The camera to dispose the post process on.
  70689. */
  70690. dispose(camera?: Camera): void;
  70691. }
  70692. }
  70693. declare module BABYLON {
  70694. /**
  70695. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70696. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70697. */
  70698. export class PostProcessManager {
  70699. private _scene;
  70700. private _indexBuffer;
  70701. private _vertexBuffers;
  70702. /**
  70703. * Creates a new instance PostProcess
  70704. * @param scene The scene that the post process is associated with.
  70705. */
  70706. constructor(scene: Scene);
  70707. private _prepareBuffers;
  70708. private _buildIndexBuffer;
  70709. /**
  70710. * Rebuilds the vertex buffers of the manager.
  70711. * @hidden
  70712. */
  70713. _rebuild(): void;
  70714. /**
  70715. * Prepares a frame to be run through a post process.
  70716. * @param sourceTexture The input texture to the post procesess. (default: null)
  70717. * @param postProcesses An array of post processes to be run. (default: null)
  70718. * @returns True if the post processes were able to be run.
  70719. * @hidden
  70720. */
  70721. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70722. /**
  70723. * Manually render a set of post processes to a texture.
  70724. * @param postProcesses An array of post processes to be run.
  70725. * @param targetTexture The target texture to render to.
  70726. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70727. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70728. * @param lodLevel defines which lod of the texture to render to
  70729. */
  70730. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70731. /**
  70732. * Finalize the result of the output of the postprocesses.
  70733. * @param doNotPresent If true the result will not be displayed to the screen.
  70734. * @param targetTexture The target texture to render to.
  70735. * @param faceIndex The index of the face to bind the target texture to.
  70736. * @param postProcesses The array of post processes to render.
  70737. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70738. * @hidden
  70739. */
  70740. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70741. /**
  70742. * Disposes of the post process manager.
  70743. */
  70744. dispose(): void;
  70745. }
  70746. }
  70747. declare module BABYLON {
  70748. interface AbstractScene {
  70749. /**
  70750. * The list of layers (background and foreground) of the scene
  70751. */
  70752. layers: Array<Layer>;
  70753. }
  70754. /**
  70755. * Defines the layer scene component responsible to manage any layers
  70756. * in a given scene.
  70757. */
  70758. export class LayerSceneComponent implements ISceneComponent {
  70759. /**
  70760. * The component name helpfull to identify the component in the list of scene components.
  70761. */
  70762. readonly name: string;
  70763. /**
  70764. * The scene the component belongs to.
  70765. */
  70766. scene: Scene;
  70767. private _engine;
  70768. /**
  70769. * Creates a new instance of the component for the given scene
  70770. * @param scene Defines the scene to register the component in
  70771. */
  70772. constructor(scene: Scene);
  70773. /**
  70774. * Registers the component in a given scene
  70775. */
  70776. register(): void;
  70777. /**
  70778. * Rebuilds the elements related to this component in case of
  70779. * context lost for instance.
  70780. */
  70781. rebuild(): void;
  70782. /**
  70783. * Disposes the component and the associated ressources.
  70784. */
  70785. dispose(): void;
  70786. private _draw;
  70787. private _drawCameraPredicate;
  70788. private _drawCameraBackground;
  70789. private _drawCameraForeground;
  70790. private _drawRenderTargetPredicate;
  70791. private _drawRenderTargetBackground;
  70792. private _drawRenderTargetForeground;
  70793. }
  70794. }
  70795. declare module BABYLON {
  70796. /** @hidden */
  70797. export var layerPixelShader: {
  70798. name: string;
  70799. shader: string;
  70800. };
  70801. }
  70802. declare module BABYLON {
  70803. /** @hidden */
  70804. export var layerVertexShader: {
  70805. name: string;
  70806. shader: string;
  70807. };
  70808. }
  70809. declare module BABYLON {
  70810. /**
  70811. * This represents a full screen 2d layer.
  70812. * This can be useful to display a picture in the background of your scene for instance.
  70813. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70814. */
  70815. export class Layer {
  70816. /**
  70817. * Define the name of the layer.
  70818. */
  70819. name: string;
  70820. /**
  70821. * Define the texture the layer should display.
  70822. */
  70823. texture: Nullable<Texture>;
  70824. /**
  70825. * Is the layer in background or foreground.
  70826. */
  70827. isBackground: boolean;
  70828. /**
  70829. * Define the color of the layer (instead of texture).
  70830. */
  70831. color: Color4;
  70832. /**
  70833. * Define the scale of the layer in order to zoom in out of the texture.
  70834. */
  70835. scale: Vector2;
  70836. /**
  70837. * Define an offset for the layer in order to shift the texture.
  70838. */
  70839. offset: Vector2;
  70840. /**
  70841. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70842. */
  70843. alphaBlendingMode: number;
  70844. /**
  70845. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70846. * Alpha test will not mix with the background color in case of transparency.
  70847. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70848. */
  70849. alphaTest: boolean;
  70850. /**
  70851. * Define a mask to restrict the layer to only some of the scene cameras.
  70852. */
  70853. layerMask: number;
  70854. /**
  70855. * Define the list of render target the layer is visible into.
  70856. */
  70857. renderTargetTextures: RenderTargetTexture[];
  70858. /**
  70859. * Define if the layer is only used in renderTarget or if it also
  70860. * renders in the main frame buffer of the canvas.
  70861. */
  70862. renderOnlyInRenderTargetTextures: boolean;
  70863. private _scene;
  70864. private _vertexBuffers;
  70865. private _indexBuffer;
  70866. private _effect;
  70867. private _alphaTestEffect;
  70868. /**
  70869. * An event triggered when the layer is disposed.
  70870. */
  70871. onDisposeObservable: Observable<Layer>;
  70872. private _onDisposeObserver;
  70873. /**
  70874. * Back compatibility with callback before the onDisposeObservable existed.
  70875. * The set callback will be triggered when the layer has been disposed.
  70876. */
  70877. onDispose: () => void;
  70878. /**
  70879. * An event triggered before rendering the scene
  70880. */
  70881. onBeforeRenderObservable: Observable<Layer>;
  70882. private _onBeforeRenderObserver;
  70883. /**
  70884. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70885. * The set callback will be triggered just before rendering the layer.
  70886. */
  70887. onBeforeRender: () => void;
  70888. /**
  70889. * An event triggered after rendering the scene
  70890. */
  70891. onAfterRenderObservable: Observable<Layer>;
  70892. private _onAfterRenderObserver;
  70893. /**
  70894. * Back compatibility with callback before the onAfterRenderObservable existed.
  70895. * The set callback will be triggered just after rendering the layer.
  70896. */
  70897. onAfterRender: () => void;
  70898. /**
  70899. * Instantiates a new layer.
  70900. * This represents a full screen 2d layer.
  70901. * This can be useful to display a picture in the background of your scene for instance.
  70902. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70903. * @param name Define the name of the layer in the scene
  70904. * @param imgUrl Define the url of the texture to display in the layer
  70905. * @param scene Define the scene the layer belongs to
  70906. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70907. * @param color Defines a color for the layer
  70908. */
  70909. constructor(
  70910. /**
  70911. * Define the name of the layer.
  70912. */
  70913. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70914. private _createIndexBuffer;
  70915. /** @hidden */
  70916. _rebuild(): void;
  70917. /**
  70918. * Renders the layer in the scene.
  70919. */
  70920. render(): void;
  70921. /**
  70922. * Disposes and releases the associated ressources.
  70923. */
  70924. dispose(): void;
  70925. }
  70926. }
  70927. declare module BABYLON {
  70928. interface AbstractScene {
  70929. /**
  70930. * The list of procedural textures added to the scene
  70931. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70932. */
  70933. proceduralTextures: Array<ProceduralTexture>;
  70934. }
  70935. /**
  70936. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70937. * in a given scene.
  70938. */
  70939. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70940. /**
  70941. * The component name helpfull to identify the component in the list of scene components.
  70942. */
  70943. readonly name: string;
  70944. /**
  70945. * The scene the component belongs to.
  70946. */
  70947. scene: Scene;
  70948. /**
  70949. * Creates a new instance of the component for the given scene
  70950. * @param scene Defines the scene to register the component in
  70951. */
  70952. constructor(scene: Scene);
  70953. /**
  70954. * Registers the component in a given scene
  70955. */
  70956. register(): void;
  70957. /**
  70958. * Rebuilds the elements related to this component in case of
  70959. * context lost for instance.
  70960. */
  70961. rebuild(): void;
  70962. /**
  70963. * Disposes the component and the associated ressources.
  70964. */
  70965. dispose(): void;
  70966. private _beforeClear;
  70967. }
  70968. }
  70969. declare module BABYLON {
  70970. /** @hidden */
  70971. export var proceduralVertexShader: {
  70972. name: string;
  70973. shader: string;
  70974. };
  70975. }
  70976. declare module BABYLON {
  70977. /**
  70978. * 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.
  70979. * This is the base class of any Procedural texture and contains most of the shareable code.
  70980. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70981. */
  70982. export class ProceduralTexture extends Texture {
  70983. isCube: boolean;
  70984. /**
  70985. * Define if the texture is enabled or not (disabled texture will not render)
  70986. */
  70987. isEnabled: boolean;
  70988. /**
  70989. * Define if the texture must be cleared before rendering (default is true)
  70990. */
  70991. autoClear: boolean;
  70992. /**
  70993. * Callback called when the texture is generated
  70994. */
  70995. onGenerated: () => void;
  70996. /**
  70997. * Event raised when the texture is generated
  70998. */
  70999. onGeneratedObservable: Observable<ProceduralTexture>;
  71000. /** @hidden */
  71001. _generateMipMaps: boolean;
  71002. /** @hidden **/
  71003. _effect: Effect;
  71004. /** @hidden */
  71005. _textures: {
  71006. [key: string]: Texture;
  71007. };
  71008. private _size;
  71009. private _currentRefreshId;
  71010. private _refreshRate;
  71011. private _vertexBuffers;
  71012. private _indexBuffer;
  71013. private _uniforms;
  71014. private _samplers;
  71015. private _fragment;
  71016. private _floats;
  71017. private _ints;
  71018. private _floatsArrays;
  71019. private _colors3;
  71020. private _colors4;
  71021. private _vectors2;
  71022. private _vectors3;
  71023. private _matrices;
  71024. private _fallbackTexture;
  71025. private _fallbackTextureUsed;
  71026. private _engine;
  71027. private _cachedDefines;
  71028. private _contentUpdateId;
  71029. private _contentData;
  71030. /**
  71031. * Instantiates a new procedural texture.
  71032. * 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.
  71033. * This is the base class of any Procedural texture and contains most of the shareable code.
  71034. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71035. * @param name Define the name of the texture
  71036. * @param size Define the size of the texture to create
  71037. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71038. * @param scene Define the scene the texture belongs to
  71039. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71040. * @param generateMipMaps Define if the texture should creates mip maps or not
  71041. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71042. */
  71043. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71044. /**
  71045. * The effect that is created when initializing the post process.
  71046. * @returns The created effect corrisponding the the postprocess.
  71047. */
  71048. getEffect(): Effect;
  71049. /**
  71050. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71051. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71052. */
  71053. getContent(): Nullable<ArrayBufferView>;
  71054. private _createIndexBuffer;
  71055. /** @hidden */
  71056. _rebuild(): void;
  71057. /**
  71058. * Resets the texture in order to recreate its associated resources.
  71059. * This can be called in case of context loss
  71060. */
  71061. reset(): void;
  71062. protected _getDefines(): string;
  71063. /**
  71064. * Is the texture ready to be used ? (rendered at least once)
  71065. * @returns true if ready, otherwise, false.
  71066. */
  71067. isReady(): boolean;
  71068. /**
  71069. * Resets the refresh counter of the texture and start bak from scratch.
  71070. * Could be useful to regenerate the texture if it is setup to render only once.
  71071. */
  71072. resetRefreshCounter(): void;
  71073. /**
  71074. * Set the fragment shader to use in order to render the texture.
  71075. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71076. */
  71077. setFragment(fragment: any): void;
  71078. /**
  71079. * Define the refresh rate of the texture or the rendering frequency.
  71080. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71081. */
  71082. refreshRate: number;
  71083. /** @hidden */
  71084. _shouldRender(): boolean;
  71085. /**
  71086. * Get the size the texture is rendering at.
  71087. * @returns the size (texture is always squared)
  71088. */
  71089. getRenderSize(): number;
  71090. /**
  71091. * Resize the texture to new value.
  71092. * @param size Define the new size the texture should have
  71093. * @param generateMipMaps Define whether the new texture should create mip maps
  71094. */
  71095. resize(size: number, generateMipMaps: boolean): void;
  71096. private _checkUniform;
  71097. /**
  71098. * Set a texture in the shader program used to render.
  71099. * @param name Define the name of the uniform samplers as defined in the shader
  71100. * @param texture Define the texture to bind to this sampler
  71101. * @return the texture itself allowing "fluent" like uniform updates
  71102. */
  71103. setTexture(name: string, texture: Texture): ProceduralTexture;
  71104. /**
  71105. * Set a float in the shader.
  71106. * @param name Define the name of the uniform as defined in the shader
  71107. * @param value Define the value to give to the uniform
  71108. * @return the texture itself allowing "fluent" like uniform updates
  71109. */
  71110. setFloat(name: string, value: number): ProceduralTexture;
  71111. /**
  71112. * Set a int in the shader.
  71113. * @param name Define the name of the uniform as defined in the shader
  71114. * @param value Define the value to give to the uniform
  71115. * @return the texture itself allowing "fluent" like uniform updates
  71116. */
  71117. setInt(name: string, value: number): ProceduralTexture;
  71118. /**
  71119. * Set an array of floats in the shader.
  71120. * @param name Define the name of the uniform as defined in the shader
  71121. * @param value Define the value to give to the uniform
  71122. * @return the texture itself allowing "fluent" like uniform updates
  71123. */
  71124. setFloats(name: string, value: number[]): ProceduralTexture;
  71125. /**
  71126. * Set a vec3 in the shader from a Color3.
  71127. * @param name Define the name of the uniform as defined in the shader
  71128. * @param value Define the value to give to the uniform
  71129. * @return the texture itself allowing "fluent" like uniform updates
  71130. */
  71131. setColor3(name: string, value: Color3): ProceduralTexture;
  71132. /**
  71133. * Set a vec4 in the shader from a Color4.
  71134. * @param name Define the name of the uniform as defined in the shader
  71135. * @param value Define the value to give to the uniform
  71136. * @return the texture itself allowing "fluent" like uniform updates
  71137. */
  71138. setColor4(name: string, value: Color4): ProceduralTexture;
  71139. /**
  71140. * Set a vec2 in the shader from a Vector2.
  71141. * @param name Define the name of the uniform as defined in the shader
  71142. * @param value Define the value to give to the uniform
  71143. * @return the texture itself allowing "fluent" like uniform updates
  71144. */
  71145. setVector2(name: string, value: Vector2): ProceduralTexture;
  71146. /**
  71147. * Set a vec3 in the shader from a Vector3.
  71148. * @param name Define the name of the uniform as defined in the shader
  71149. * @param value Define the value to give to the uniform
  71150. * @return the texture itself allowing "fluent" like uniform updates
  71151. */
  71152. setVector3(name: string, value: Vector3): ProceduralTexture;
  71153. /**
  71154. * Set a mat4 in the shader from a MAtrix.
  71155. * @param name Define the name of the uniform as defined in the shader
  71156. * @param value Define the value to give to the uniform
  71157. * @return the texture itself allowing "fluent" like uniform updates
  71158. */
  71159. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71160. /**
  71161. * Render the texture to its associated render target.
  71162. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71163. */
  71164. render(useCameraPostProcess?: boolean): void;
  71165. /**
  71166. * Clone the texture.
  71167. * @returns the cloned texture
  71168. */
  71169. clone(): ProceduralTexture;
  71170. /**
  71171. * Dispose the texture and release its asoociated resources.
  71172. */
  71173. dispose(): void;
  71174. }
  71175. }
  71176. declare module BABYLON {
  71177. /**
  71178. * This represents the base class for particle system in Babylon.
  71179. * 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.
  71180. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71181. * @example https://doc.babylonjs.com/babylon101/particles
  71182. */
  71183. export class BaseParticleSystem {
  71184. /**
  71185. * Source color is added to the destination color without alpha affecting the result
  71186. */
  71187. static BLENDMODE_ONEONE: number;
  71188. /**
  71189. * Blend current color and particle color using particle’s alpha
  71190. */
  71191. static BLENDMODE_STANDARD: number;
  71192. /**
  71193. * Add current color and particle color multiplied by particle’s alpha
  71194. */
  71195. static BLENDMODE_ADD: number;
  71196. /**
  71197. * Multiply current color with particle color
  71198. */
  71199. static BLENDMODE_MULTIPLY: number;
  71200. /**
  71201. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71202. */
  71203. static BLENDMODE_MULTIPLYADD: number;
  71204. /**
  71205. * List of animations used by the particle system.
  71206. */
  71207. animations: Animation[];
  71208. /**
  71209. * The id of the Particle system.
  71210. */
  71211. id: string;
  71212. /**
  71213. * The friendly name of the Particle system.
  71214. */
  71215. name: string;
  71216. /**
  71217. * The rendering group used by the Particle system to chose when to render.
  71218. */
  71219. renderingGroupId: number;
  71220. /**
  71221. * The emitter represents the Mesh or position we are attaching the particle system to.
  71222. */
  71223. emitter: Nullable<AbstractMesh | Vector3>;
  71224. /**
  71225. * The maximum number of particles to emit per frame
  71226. */
  71227. emitRate: number;
  71228. /**
  71229. * If you want to launch only a few particles at once, that can be done, as well.
  71230. */
  71231. manualEmitCount: number;
  71232. /**
  71233. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71234. */
  71235. updateSpeed: number;
  71236. /**
  71237. * The amount of time the particle system is running (depends of the overall update speed).
  71238. */
  71239. targetStopDuration: number;
  71240. /**
  71241. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71242. */
  71243. disposeOnStop: boolean;
  71244. /**
  71245. * Minimum power of emitting particles.
  71246. */
  71247. minEmitPower: number;
  71248. /**
  71249. * Maximum power of emitting particles.
  71250. */
  71251. maxEmitPower: number;
  71252. /**
  71253. * Minimum life time of emitting particles.
  71254. */
  71255. minLifeTime: number;
  71256. /**
  71257. * Maximum life time of emitting particles.
  71258. */
  71259. maxLifeTime: number;
  71260. /**
  71261. * Minimum Size of emitting particles.
  71262. */
  71263. minSize: number;
  71264. /**
  71265. * Maximum Size of emitting particles.
  71266. */
  71267. maxSize: number;
  71268. /**
  71269. * Minimum scale of emitting particles on X axis.
  71270. */
  71271. minScaleX: number;
  71272. /**
  71273. * Maximum scale of emitting particles on X axis.
  71274. */
  71275. maxScaleX: number;
  71276. /**
  71277. * Minimum scale of emitting particles on Y axis.
  71278. */
  71279. minScaleY: number;
  71280. /**
  71281. * Maximum scale of emitting particles on Y axis.
  71282. */
  71283. maxScaleY: number;
  71284. /**
  71285. * Gets or sets the minimal initial rotation in radians.
  71286. */
  71287. minInitialRotation: number;
  71288. /**
  71289. * Gets or sets the maximal initial rotation in radians.
  71290. */
  71291. maxInitialRotation: number;
  71292. /**
  71293. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71294. */
  71295. minAngularSpeed: number;
  71296. /**
  71297. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71298. */
  71299. maxAngularSpeed: number;
  71300. /**
  71301. * The texture used to render each particle. (this can be a spritesheet)
  71302. */
  71303. particleTexture: Nullable<Texture>;
  71304. /**
  71305. * The layer mask we are rendering the particles through.
  71306. */
  71307. layerMask: number;
  71308. /**
  71309. * This can help using your own shader to render the particle system.
  71310. * The according effect will be created
  71311. */
  71312. customShader: any;
  71313. /**
  71314. * By default particle system starts as soon as they are created. This prevents the
  71315. * automatic start to happen and let you decide when to start emitting particles.
  71316. */
  71317. preventAutoStart: boolean;
  71318. private _noiseTexture;
  71319. /**
  71320. * Gets or sets a texture used to add random noise to particle positions
  71321. */
  71322. noiseTexture: Nullable<ProceduralTexture>;
  71323. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71324. noiseStrength: Vector3;
  71325. /**
  71326. * Callback triggered when the particle animation is ending.
  71327. */
  71328. onAnimationEnd: Nullable<() => void>;
  71329. /**
  71330. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71331. */
  71332. blendMode: number;
  71333. /**
  71334. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71335. * to override the particles.
  71336. */
  71337. forceDepthWrite: boolean;
  71338. /** 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 */
  71339. preWarmCycles: number;
  71340. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71341. preWarmStepOffset: number;
  71342. /**
  71343. * 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)
  71344. */
  71345. spriteCellChangeSpeed: number;
  71346. /**
  71347. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71348. */
  71349. startSpriteCellID: number;
  71350. /**
  71351. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71352. */
  71353. endSpriteCellID: number;
  71354. /**
  71355. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71356. */
  71357. spriteCellWidth: number;
  71358. /**
  71359. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71360. */
  71361. spriteCellHeight: number;
  71362. /**
  71363. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71364. */
  71365. spriteRandomStartCell: boolean;
  71366. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71367. translationPivot: Vector2;
  71368. /** @hidden */
  71369. protected _isAnimationSheetEnabled: boolean;
  71370. /**
  71371. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71372. */
  71373. beginAnimationOnStart: boolean;
  71374. /**
  71375. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71376. */
  71377. beginAnimationFrom: number;
  71378. /**
  71379. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71380. */
  71381. beginAnimationTo: number;
  71382. /**
  71383. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71384. */
  71385. beginAnimationLoop: boolean;
  71386. /**
  71387. * Gets or sets a world offset applied to all particles
  71388. */
  71389. worldOffset: Vector3;
  71390. /**
  71391. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71392. */
  71393. isAnimationSheetEnabled: boolean;
  71394. /**
  71395. * Get hosting scene
  71396. * @returns the scene
  71397. */
  71398. getScene(): Scene;
  71399. /**
  71400. * You can use gravity if you want to give an orientation to your particles.
  71401. */
  71402. gravity: Vector3;
  71403. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71404. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71405. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71406. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71407. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71408. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71409. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71410. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71411. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71412. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71413. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71414. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71415. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71416. /**
  71417. * Defines the delay in milliseconds before starting the system (0 by default)
  71418. */
  71419. startDelay: number;
  71420. /**
  71421. * Gets the current list of drag gradients.
  71422. * You must use addDragGradient and removeDragGradient to udpate this list
  71423. * @returns the list of drag gradients
  71424. */
  71425. getDragGradients(): Nullable<Array<FactorGradient>>;
  71426. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71427. limitVelocityDamping: number;
  71428. /**
  71429. * Gets the current list of limit velocity gradients.
  71430. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71431. * @returns the list of limit velocity gradients
  71432. */
  71433. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71434. /**
  71435. * Gets the current list of color gradients.
  71436. * You must use addColorGradient and removeColorGradient to udpate this list
  71437. * @returns the list of color gradients
  71438. */
  71439. getColorGradients(): Nullable<Array<ColorGradient>>;
  71440. /**
  71441. * Gets the current list of size gradients.
  71442. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71443. * @returns the list of size gradients
  71444. */
  71445. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71446. /**
  71447. * Gets the current list of color remap gradients.
  71448. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71449. * @returns the list of color remap gradients
  71450. */
  71451. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71452. /**
  71453. * Gets the current list of alpha remap gradients.
  71454. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71455. * @returns the list of alpha remap gradients
  71456. */
  71457. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71458. /**
  71459. * Gets the current list of life time gradients.
  71460. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71461. * @returns the list of life time gradients
  71462. */
  71463. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71464. /**
  71465. * Gets the current list of angular speed gradients.
  71466. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71467. * @returns the list of angular speed gradients
  71468. */
  71469. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71470. /**
  71471. * Gets the current list of velocity gradients.
  71472. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71473. * @returns the list of velocity gradients
  71474. */
  71475. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71476. /**
  71477. * Gets the current list of start size gradients.
  71478. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71479. * @returns the list of start size gradients
  71480. */
  71481. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71482. /**
  71483. * Gets the current list of emit rate gradients.
  71484. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71485. * @returns the list of emit rate gradients
  71486. */
  71487. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71488. /**
  71489. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71490. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71491. */
  71492. direction1: Vector3;
  71493. /**
  71494. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71495. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71496. */
  71497. direction2: Vector3;
  71498. /**
  71499. * 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.
  71500. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71501. */
  71502. minEmitBox: Vector3;
  71503. /**
  71504. * 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.
  71505. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71506. */
  71507. maxEmitBox: Vector3;
  71508. /**
  71509. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71510. */
  71511. color1: Color4;
  71512. /**
  71513. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71514. */
  71515. color2: Color4;
  71516. /**
  71517. * Color the particle will have at the end of its lifetime
  71518. */
  71519. colorDead: Color4;
  71520. /**
  71521. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71522. */
  71523. textureMask: Color4;
  71524. /**
  71525. * The particle emitter type defines the emitter used by the particle system.
  71526. * It can be for example box, sphere, or cone...
  71527. */
  71528. particleEmitterType: IParticleEmitterType;
  71529. /** @hidden */
  71530. _isSubEmitter: boolean;
  71531. /**
  71532. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71533. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71534. */
  71535. billboardMode: number;
  71536. protected _isBillboardBased: boolean;
  71537. /**
  71538. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71539. */
  71540. isBillboardBased: boolean;
  71541. /**
  71542. * The scene the particle system belongs to.
  71543. */
  71544. protected _scene: Scene;
  71545. /**
  71546. * Local cache of defines for image processing.
  71547. */
  71548. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71549. /**
  71550. * Default configuration related to image processing available in the standard Material.
  71551. */
  71552. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71553. /**
  71554. * Gets the image processing configuration used either in this material.
  71555. */
  71556. /**
  71557. * Sets the Default image processing configuration used either in the this material.
  71558. *
  71559. * If sets to null, the scene one is in use.
  71560. */
  71561. imageProcessingConfiguration: ImageProcessingConfiguration;
  71562. /**
  71563. * Attaches a new image processing configuration to the Standard Material.
  71564. * @param configuration
  71565. */
  71566. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71567. /** @hidden */
  71568. protected _reset(): void;
  71569. /** @hidden */
  71570. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71571. /**
  71572. * Instantiates a particle system.
  71573. * 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.
  71574. * @param name The name of the particle system
  71575. */
  71576. constructor(name: string);
  71577. /**
  71578. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71579. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71580. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71581. * @returns the emitter
  71582. */
  71583. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71584. /**
  71585. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71586. * @param radius The radius of the hemisphere to emit from
  71587. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71588. * @returns the emitter
  71589. */
  71590. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71591. /**
  71592. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71593. * @param radius The radius of the sphere to emit from
  71594. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71595. * @returns the emitter
  71596. */
  71597. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71598. /**
  71599. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71600. * @param radius The radius of the sphere to emit from
  71601. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71602. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71603. * @returns the emitter
  71604. */
  71605. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71606. /**
  71607. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71608. * @param radius The radius of the emission cylinder
  71609. * @param height The height of the emission cylinder
  71610. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71611. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71612. * @returns the emitter
  71613. */
  71614. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71615. /**
  71616. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71617. * @param radius The radius of the cylinder to emit from
  71618. * @param height The height of the emission cylinder
  71619. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71620. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71621. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71622. * @returns the emitter
  71623. */
  71624. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71625. /**
  71626. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71627. * @param radius The radius of the cone to emit from
  71628. * @param angle The base angle of the cone
  71629. * @returns the emitter
  71630. */
  71631. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71632. /**
  71633. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71634. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71635. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71636. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71637. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71638. * @returns the emitter
  71639. */
  71640. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71641. }
  71642. }
  71643. declare module BABYLON {
  71644. /**
  71645. * Type of sub emitter
  71646. */
  71647. export enum SubEmitterType {
  71648. /**
  71649. * Attached to the particle over it's lifetime
  71650. */
  71651. ATTACHED = 0,
  71652. /**
  71653. * Created when the particle dies
  71654. */
  71655. END = 1
  71656. }
  71657. /**
  71658. * Sub emitter class used to emit particles from an existing particle
  71659. */
  71660. export class SubEmitter {
  71661. /**
  71662. * the particle system to be used by the sub emitter
  71663. */
  71664. particleSystem: ParticleSystem;
  71665. /**
  71666. * Type of the submitter (Default: END)
  71667. */
  71668. type: SubEmitterType;
  71669. /**
  71670. * 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)
  71671. * Note: This only is supported when using an emitter of type Mesh
  71672. */
  71673. inheritDirection: boolean;
  71674. /**
  71675. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71676. */
  71677. inheritedVelocityAmount: number;
  71678. /**
  71679. * Creates a sub emitter
  71680. * @param particleSystem the particle system to be used by the sub emitter
  71681. */
  71682. constructor(
  71683. /**
  71684. * the particle system to be used by the sub emitter
  71685. */
  71686. particleSystem: ParticleSystem);
  71687. /**
  71688. * Clones the sub emitter
  71689. * @returns the cloned sub emitter
  71690. */
  71691. clone(): SubEmitter;
  71692. /**
  71693. * Serialize current object to a JSON object
  71694. * @returns the serialized object
  71695. */
  71696. serialize(): any;
  71697. /** @hidden */
  71698. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71699. /**
  71700. * Creates a new SubEmitter from a serialized JSON version
  71701. * @param serializationObject defines the JSON object to read from
  71702. * @param scene defines the hosting scene
  71703. * @param rootUrl defines the rootUrl for data loading
  71704. * @returns a new SubEmitter
  71705. */
  71706. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71707. /** Release associated resources */
  71708. dispose(): void;
  71709. }
  71710. }
  71711. declare module BABYLON {
  71712. /** @hidden */
  71713. export var clipPlaneFragmentDeclaration: {
  71714. name: string;
  71715. shader: string;
  71716. };
  71717. }
  71718. declare module BABYLON {
  71719. /** @hidden */
  71720. export var imageProcessingDeclaration: {
  71721. name: string;
  71722. shader: string;
  71723. };
  71724. }
  71725. declare module BABYLON {
  71726. /** @hidden */
  71727. export var imageProcessingFunctions: {
  71728. name: string;
  71729. shader: string;
  71730. };
  71731. }
  71732. declare module BABYLON {
  71733. /** @hidden */
  71734. export var clipPlaneFragment: {
  71735. name: string;
  71736. shader: string;
  71737. };
  71738. }
  71739. declare module BABYLON {
  71740. /** @hidden */
  71741. export var particlesPixelShader: {
  71742. name: string;
  71743. shader: string;
  71744. };
  71745. }
  71746. declare module BABYLON {
  71747. /** @hidden */
  71748. export var clipPlaneVertexDeclaration: {
  71749. name: string;
  71750. shader: string;
  71751. };
  71752. }
  71753. declare module BABYLON {
  71754. /** @hidden */
  71755. export var clipPlaneVertex: {
  71756. name: string;
  71757. shader: string;
  71758. };
  71759. }
  71760. declare module BABYLON {
  71761. /** @hidden */
  71762. export var particlesVertexShader: {
  71763. name: string;
  71764. shader: string;
  71765. };
  71766. }
  71767. declare module BABYLON {
  71768. /**
  71769. * This represents a particle system in Babylon.
  71770. * 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.
  71771. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71772. * @example https://doc.babylonjs.com/babylon101/particles
  71773. */
  71774. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71775. /**
  71776. * Billboard mode will only apply to Y axis
  71777. */
  71778. static readonly BILLBOARDMODE_Y: number;
  71779. /**
  71780. * Billboard mode will apply to all axes
  71781. */
  71782. static readonly BILLBOARDMODE_ALL: number;
  71783. /**
  71784. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71785. */
  71786. static readonly BILLBOARDMODE_STRETCHED: number;
  71787. /**
  71788. * This function can be defined to provide custom update for active particles.
  71789. * This function will be called instead of regular update (age, position, color, etc.).
  71790. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71791. */
  71792. updateFunction: (particles: Particle[]) => void;
  71793. private _emitterWorldMatrix;
  71794. /**
  71795. * This function can be defined to specify initial direction for every new particle.
  71796. * It by default use the emitterType defined function
  71797. */
  71798. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71799. /**
  71800. * This function can be defined to specify initial position for every new particle.
  71801. * It by default use the emitterType defined function
  71802. */
  71803. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71804. /**
  71805. * @hidden
  71806. */
  71807. _inheritedVelocityOffset: Vector3;
  71808. /**
  71809. * An event triggered when the system is disposed
  71810. */
  71811. onDisposeObservable: Observable<ParticleSystem>;
  71812. private _onDisposeObserver;
  71813. /**
  71814. * Sets a callback that will be triggered when the system is disposed
  71815. */
  71816. onDispose: () => void;
  71817. private _particles;
  71818. private _epsilon;
  71819. private _capacity;
  71820. private _stockParticles;
  71821. private _newPartsExcess;
  71822. private _vertexData;
  71823. private _vertexBuffer;
  71824. private _vertexBuffers;
  71825. private _spriteBuffer;
  71826. private _indexBuffer;
  71827. private _effect;
  71828. private _customEffect;
  71829. private _cachedDefines;
  71830. private _scaledColorStep;
  71831. private _colorDiff;
  71832. private _scaledDirection;
  71833. private _scaledGravity;
  71834. private _currentRenderId;
  71835. private _alive;
  71836. private _useInstancing;
  71837. private _started;
  71838. private _stopped;
  71839. private _actualFrame;
  71840. private _scaledUpdateSpeed;
  71841. private _vertexBufferSize;
  71842. /** @hidden */
  71843. _currentEmitRateGradient: Nullable<FactorGradient>;
  71844. /** @hidden */
  71845. _currentEmitRate1: number;
  71846. /** @hidden */
  71847. _currentEmitRate2: number;
  71848. /** @hidden */
  71849. _currentStartSizeGradient: Nullable<FactorGradient>;
  71850. /** @hidden */
  71851. _currentStartSize1: number;
  71852. /** @hidden */
  71853. _currentStartSize2: number;
  71854. private readonly _rawTextureWidth;
  71855. private _rampGradientsTexture;
  71856. private _useRampGradients;
  71857. /** Gets or sets a boolean indicating that ramp gradients must be used
  71858. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71859. */
  71860. useRampGradients: boolean;
  71861. /**
  71862. * 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.
  71863. * 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: [])
  71864. */
  71865. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71866. private _subEmitters;
  71867. /**
  71868. * @hidden
  71869. * If the particle systems emitter should be disposed when the particle system is disposed
  71870. */
  71871. _disposeEmitterOnDispose: boolean;
  71872. /**
  71873. * The current active Sub-systems, this property is used by the root particle system only.
  71874. */
  71875. activeSubSystems: Array<ParticleSystem>;
  71876. private _rootParticleSystem;
  71877. /**
  71878. * Gets the current list of active particles
  71879. */
  71880. readonly particles: Particle[];
  71881. /**
  71882. * Returns the string "ParticleSystem"
  71883. * @returns a string containing the class name
  71884. */
  71885. getClassName(): string;
  71886. /**
  71887. * Instantiates a particle system.
  71888. * 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.
  71889. * @param name The name of the particle system
  71890. * @param capacity The max number of particles alive at the same time
  71891. * @param scene The scene the particle system belongs to
  71892. * @param customEffect a custom effect used to change the way particles are rendered by default
  71893. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71894. * @param epsilon Offset used to render the particles
  71895. */
  71896. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71897. private _addFactorGradient;
  71898. private _removeFactorGradient;
  71899. /**
  71900. * Adds a new life time gradient
  71901. * @param gradient defines the gradient to use (between 0 and 1)
  71902. * @param factor defines the life time factor to affect to the specified gradient
  71903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71904. * @returns the current particle system
  71905. */
  71906. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71907. /**
  71908. * Remove a specific life time gradient
  71909. * @param gradient defines the gradient to remove
  71910. * @returns the current particle system
  71911. */
  71912. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71913. /**
  71914. * Adds a new size gradient
  71915. * @param gradient defines the gradient to use (between 0 and 1)
  71916. * @param factor defines the size factor to affect to the specified gradient
  71917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71918. * @returns the current particle system
  71919. */
  71920. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71921. /**
  71922. * Remove a specific size gradient
  71923. * @param gradient defines the gradient to remove
  71924. * @returns the current particle system
  71925. */
  71926. removeSizeGradient(gradient: number): IParticleSystem;
  71927. /**
  71928. * Adds a new color remap gradient
  71929. * @param gradient defines the gradient to use (between 0 and 1)
  71930. * @param min defines the color remap minimal range
  71931. * @param max defines the color remap maximal range
  71932. * @returns the current particle system
  71933. */
  71934. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71935. /**
  71936. * Remove a specific color remap gradient
  71937. * @param gradient defines the gradient to remove
  71938. * @returns the current particle system
  71939. */
  71940. removeColorRemapGradient(gradient: number): IParticleSystem;
  71941. /**
  71942. * Adds a new alpha remap gradient
  71943. * @param gradient defines the gradient to use (between 0 and 1)
  71944. * @param min defines the alpha remap minimal range
  71945. * @param max defines the alpha remap maximal range
  71946. * @returns the current particle system
  71947. */
  71948. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71949. /**
  71950. * Remove a specific alpha remap gradient
  71951. * @param gradient defines the gradient to remove
  71952. * @returns the current particle system
  71953. */
  71954. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  71955. /**
  71956. * Adds a new angular speed gradient
  71957. * @param gradient defines the gradient to use (between 0 and 1)
  71958. * @param factor defines the angular speed to affect to the specified gradient
  71959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71960. * @returns the current particle system
  71961. */
  71962. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71963. /**
  71964. * Remove a specific angular speed gradient
  71965. * @param gradient defines the gradient to remove
  71966. * @returns the current particle system
  71967. */
  71968. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  71969. /**
  71970. * Adds a new velocity gradient
  71971. * @param gradient defines the gradient to use (between 0 and 1)
  71972. * @param factor defines the velocity to affect to the specified gradient
  71973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71974. * @returns the current particle system
  71975. */
  71976. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71977. /**
  71978. * Remove a specific velocity gradient
  71979. * @param gradient defines the gradient to remove
  71980. * @returns the current particle system
  71981. */
  71982. removeVelocityGradient(gradient: number): IParticleSystem;
  71983. /**
  71984. * Adds a new limit velocity gradient
  71985. * @param gradient defines the gradient to use (between 0 and 1)
  71986. * @param factor defines the limit velocity value to affect to the specified gradient
  71987. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71988. * @returns the current particle system
  71989. */
  71990. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71991. /**
  71992. * Remove a specific limit velocity gradient
  71993. * @param gradient defines the gradient to remove
  71994. * @returns the current particle system
  71995. */
  71996. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  71997. /**
  71998. * Adds a new drag gradient
  71999. * @param gradient defines the gradient to use (between 0 and 1)
  72000. * @param factor defines the drag value to affect to the specified gradient
  72001. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72002. * @returns the current particle system
  72003. */
  72004. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72005. /**
  72006. * Remove a specific drag gradient
  72007. * @param gradient defines the gradient to remove
  72008. * @returns the current particle system
  72009. */
  72010. removeDragGradient(gradient: number): IParticleSystem;
  72011. /**
  72012. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72013. * @param gradient defines the gradient to use (between 0 and 1)
  72014. * @param factor defines the emit rate value to affect to the specified gradient
  72015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72016. * @returns the current particle system
  72017. */
  72018. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72019. /**
  72020. * Remove a specific emit rate gradient
  72021. * @param gradient defines the gradient to remove
  72022. * @returns the current particle system
  72023. */
  72024. removeEmitRateGradient(gradient: number): IParticleSystem;
  72025. /**
  72026. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72027. * @param gradient defines the gradient to use (between 0 and 1)
  72028. * @param factor defines the start size value 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. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72033. /**
  72034. * Remove a specific start size gradient
  72035. * @param gradient defines the gradient to remove
  72036. * @returns the current particle system
  72037. */
  72038. removeStartSizeGradient(gradient: number): IParticleSystem;
  72039. private _createRampGradientTexture;
  72040. /**
  72041. * Gets the current list of ramp gradients.
  72042. * You must use addRampGradient and removeRampGradient to udpate this list
  72043. * @returns the list of ramp gradients
  72044. */
  72045. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72046. /**
  72047. * Adds a new ramp gradient used to remap particle colors
  72048. * @param gradient defines the gradient to use (between 0 and 1)
  72049. * @param color defines the color to affect to the specified gradient
  72050. * @returns the current particle system
  72051. */
  72052. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72053. /**
  72054. * Remove a specific ramp gradient
  72055. * @param gradient defines the gradient to remove
  72056. * @returns the current particle system
  72057. */
  72058. removeRampGradient(gradient: number): ParticleSystem;
  72059. /**
  72060. * Adds a new color gradient
  72061. * @param gradient defines the gradient to use (between 0 and 1)
  72062. * @param color1 defines the color to affect to the specified gradient
  72063. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72064. * @returns this particle system
  72065. */
  72066. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72067. /**
  72068. * Remove a specific color gradient
  72069. * @param gradient defines the gradient to remove
  72070. * @returns this particle system
  72071. */
  72072. removeColorGradient(gradient: number): IParticleSystem;
  72073. private _fetchR;
  72074. protected _reset(): void;
  72075. private _resetEffect;
  72076. private _createVertexBuffers;
  72077. private _createIndexBuffer;
  72078. /**
  72079. * Gets the maximum number of particles active at the same time.
  72080. * @returns The max number of active particles.
  72081. */
  72082. getCapacity(): number;
  72083. /**
  72084. * Gets whether there are still active particles in the system.
  72085. * @returns True if it is alive, otherwise false.
  72086. */
  72087. isAlive(): boolean;
  72088. /**
  72089. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72090. * @returns True if it has been started, otherwise false.
  72091. */
  72092. isStarted(): boolean;
  72093. private _prepareSubEmitterInternalArray;
  72094. /**
  72095. * Starts the particle system and begins to emit
  72096. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72097. */
  72098. start(delay?: number): void;
  72099. /**
  72100. * Stops the particle system.
  72101. * @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.
  72102. */
  72103. stop(stopSubEmitters?: boolean): void;
  72104. /**
  72105. * Remove all active particles
  72106. */
  72107. reset(): void;
  72108. /**
  72109. * @hidden (for internal use only)
  72110. */
  72111. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72112. /**
  72113. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72114. * Its lifetime will start back at 0.
  72115. */
  72116. recycleParticle: (particle: Particle) => void;
  72117. private _stopSubEmitters;
  72118. private _createParticle;
  72119. private _removeFromRoot;
  72120. private _emitFromParticle;
  72121. private _update;
  72122. /** @hidden */
  72123. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72124. /** @hidden */
  72125. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72126. /** @hidden */
  72127. private _getEffect;
  72128. /**
  72129. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72130. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72131. */
  72132. animate(preWarmOnly?: boolean): void;
  72133. private _appendParticleVertices;
  72134. /**
  72135. * Rebuilds the particle system.
  72136. */
  72137. rebuild(): void;
  72138. /**
  72139. * Is this system ready to be used/rendered
  72140. * @return true if the system is ready
  72141. */
  72142. isReady(): boolean;
  72143. private _render;
  72144. /**
  72145. * Renders the particle system in its current state.
  72146. * @returns the current number of particles
  72147. */
  72148. render(): number;
  72149. /**
  72150. * Disposes the particle system and free the associated resources
  72151. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72152. */
  72153. dispose(disposeTexture?: boolean): void;
  72154. /**
  72155. * Clones the particle system.
  72156. * @param name The name of the cloned object
  72157. * @param newEmitter The new emitter to use
  72158. * @returns the cloned particle system
  72159. */
  72160. clone(name: string, newEmitter: any): ParticleSystem;
  72161. /**
  72162. * Serializes the particle system to a JSON object.
  72163. * @returns the JSON object
  72164. */
  72165. serialize(): any;
  72166. /** @hidden */
  72167. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72168. /** @hidden */
  72169. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72170. /**
  72171. * Parses a JSON object to create a particle system.
  72172. * @param parsedParticleSystem The JSON object to parse
  72173. * @param scene The scene to create the particle system in
  72174. * @param rootUrl The root url to use to load external dependencies like texture
  72175. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72176. * @returns the Parsed particle system
  72177. */
  72178. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72179. }
  72180. }
  72181. declare module BABYLON {
  72182. /**
  72183. * A particle represents one of the element emitted by a particle system.
  72184. * This is mainly define by its coordinates, direction, velocity and age.
  72185. */
  72186. export class Particle {
  72187. /**
  72188. * The particle system the particle belongs to.
  72189. */
  72190. particleSystem: ParticleSystem;
  72191. private static _Count;
  72192. /**
  72193. * Unique ID of the particle
  72194. */
  72195. id: number;
  72196. /**
  72197. * The world position of the particle in the scene.
  72198. */
  72199. position: Vector3;
  72200. /**
  72201. * The world direction of the particle in the scene.
  72202. */
  72203. direction: Vector3;
  72204. /**
  72205. * The color of the particle.
  72206. */
  72207. color: Color4;
  72208. /**
  72209. * The color change of the particle per step.
  72210. */
  72211. colorStep: Color4;
  72212. /**
  72213. * Defines how long will the life of the particle be.
  72214. */
  72215. lifeTime: number;
  72216. /**
  72217. * The current age of the particle.
  72218. */
  72219. age: number;
  72220. /**
  72221. * The current size of the particle.
  72222. */
  72223. size: number;
  72224. /**
  72225. * The current scale of the particle.
  72226. */
  72227. scale: Vector2;
  72228. /**
  72229. * The current angle of the particle.
  72230. */
  72231. angle: number;
  72232. /**
  72233. * Defines how fast is the angle changing.
  72234. */
  72235. angularSpeed: number;
  72236. /**
  72237. * Defines the cell index used by the particle to be rendered from a sprite.
  72238. */
  72239. cellIndex: number;
  72240. /**
  72241. * The information required to support color remapping
  72242. */
  72243. remapData: Vector4;
  72244. /** @hidden */
  72245. _randomCellOffset?: number;
  72246. /** @hidden */
  72247. _initialDirection: Nullable<Vector3>;
  72248. /** @hidden */
  72249. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72250. /** @hidden */
  72251. _initialStartSpriteCellID: number;
  72252. /** @hidden */
  72253. _initialEndSpriteCellID: number;
  72254. /** @hidden */
  72255. _currentColorGradient: Nullable<ColorGradient>;
  72256. /** @hidden */
  72257. _currentColor1: Color4;
  72258. /** @hidden */
  72259. _currentColor2: Color4;
  72260. /** @hidden */
  72261. _currentSizeGradient: Nullable<FactorGradient>;
  72262. /** @hidden */
  72263. _currentSize1: number;
  72264. /** @hidden */
  72265. _currentSize2: number;
  72266. /** @hidden */
  72267. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72268. /** @hidden */
  72269. _currentAngularSpeed1: number;
  72270. /** @hidden */
  72271. _currentAngularSpeed2: number;
  72272. /** @hidden */
  72273. _currentVelocityGradient: Nullable<FactorGradient>;
  72274. /** @hidden */
  72275. _currentVelocity1: number;
  72276. /** @hidden */
  72277. _currentVelocity2: number;
  72278. /** @hidden */
  72279. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72280. /** @hidden */
  72281. _currentLimitVelocity1: number;
  72282. /** @hidden */
  72283. _currentLimitVelocity2: number;
  72284. /** @hidden */
  72285. _currentDragGradient: Nullable<FactorGradient>;
  72286. /** @hidden */
  72287. _currentDrag1: number;
  72288. /** @hidden */
  72289. _currentDrag2: number;
  72290. /** @hidden */
  72291. _randomNoiseCoordinates1: Vector3;
  72292. /** @hidden */
  72293. _randomNoiseCoordinates2: Vector3;
  72294. /**
  72295. * Creates a new instance Particle
  72296. * @param particleSystem the particle system the particle belongs to
  72297. */
  72298. constructor(
  72299. /**
  72300. * The particle system the particle belongs to.
  72301. */
  72302. particleSystem: ParticleSystem);
  72303. private updateCellInfoFromSystem;
  72304. /**
  72305. * Defines how the sprite cell index is updated for the particle
  72306. */
  72307. updateCellIndex(): void;
  72308. /** @hidden */
  72309. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72310. /** @hidden */
  72311. _inheritParticleInfoToSubEmitters(): void;
  72312. /** @hidden */
  72313. _reset(): void;
  72314. /**
  72315. * Copy the properties of particle to another one.
  72316. * @param other the particle to copy the information to.
  72317. */
  72318. copyTo(other: Particle): void;
  72319. }
  72320. }
  72321. declare module BABYLON {
  72322. /**
  72323. * Particle emitter represents a volume emitting particles.
  72324. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72325. */
  72326. export interface IParticleEmitterType {
  72327. /**
  72328. * Called by the particle System when the direction is computed for the created particle.
  72329. * @param worldMatrix is the world matrix of the particle system
  72330. * @param directionToUpdate is the direction vector to update with the result
  72331. * @param particle is the particle we are computed the direction for
  72332. */
  72333. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72334. /**
  72335. * Called by the particle System when the position is computed for the created particle.
  72336. * @param worldMatrix is the world matrix of the particle system
  72337. * @param positionToUpdate is the position vector to update with the result
  72338. * @param particle is the particle we are computed the position for
  72339. */
  72340. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72341. /**
  72342. * Clones the current emitter and returns a copy of it
  72343. * @returns the new emitter
  72344. */
  72345. clone(): IParticleEmitterType;
  72346. /**
  72347. * Called by the GPUParticleSystem to setup the update shader
  72348. * @param effect defines the update shader
  72349. */
  72350. applyToShader(effect: Effect): void;
  72351. /**
  72352. * Returns a string to use to update the GPU particles update shader
  72353. * @returns the effect defines string
  72354. */
  72355. getEffectDefines(): string;
  72356. /**
  72357. * Returns a string representing the class name
  72358. * @returns a string containing the class name
  72359. */
  72360. getClassName(): string;
  72361. /**
  72362. * Serializes the particle system to a JSON object.
  72363. * @returns the JSON object
  72364. */
  72365. serialize(): any;
  72366. /**
  72367. * Parse properties from a JSON object
  72368. * @param serializationObject defines the JSON object
  72369. */
  72370. parse(serializationObject: any): void;
  72371. }
  72372. }
  72373. declare module BABYLON {
  72374. /**
  72375. * Particle emitter emitting particles from the inside of a box.
  72376. * It emits the particles randomly between 2 given directions.
  72377. */
  72378. export class BoxParticleEmitter implements IParticleEmitterType {
  72379. /**
  72380. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72381. */
  72382. direction1: Vector3;
  72383. /**
  72384. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72385. */
  72386. direction2: Vector3;
  72387. /**
  72388. * 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.
  72389. */
  72390. minEmitBox: Vector3;
  72391. /**
  72392. * 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.
  72393. */
  72394. maxEmitBox: Vector3;
  72395. /**
  72396. * Creates a new instance BoxParticleEmitter
  72397. */
  72398. constructor();
  72399. /**
  72400. * Called by the particle System when the direction is computed for the created particle.
  72401. * @param worldMatrix is the world matrix of the particle system
  72402. * @param directionToUpdate is the direction vector to update with the result
  72403. * @param particle is the particle we are computed the direction for
  72404. */
  72405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72406. /**
  72407. * Called by the particle System when the position is computed for the created particle.
  72408. * @param worldMatrix is the world matrix of the particle system
  72409. * @param positionToUpdate is the position vector to update with the result
  72410. * @param particle is the particle we are computed the position for
  72411. */
  72412. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72413. /**
  72414. * Clones the current emitter and returns a copy of it
  72415. * @returns the new emitter
  72416. */
  72417. clone(): BoxParticleEmitter;
  72418. /**
  72419. * Called by the GPUParticleSystem to setup the update shader
  72420. * @param effect defines the update shader
  72421. */
  72422. applyToShader(effect: Effect): void;
  72423. /**
  72424. * Returns a string to use to update the GPU particles update shader
  72425. * @returns a string containng the defines string
  72426. */
  72427. getEffectDefines(): string;
  72428. /**
  72429. * Returns the string "BoxParticleEmitter"
  72430. * @returns a string containing the class name
  72431. */
  72432. getClassName(): string;
  72433. /**
  72434. * Serializes the particle system to a JSON object.
  72435. * @returns the JSON object
  72436. */
  72437. serialize(): any;
  72438. /**
  72439. * Parse properties from a JSON object
  72440. * @param serializationObject defines the JSON object
  72441. */
  72442. parse(serializationObject: any): void;
  72443. }
  72444. }
  72445. declare module BABYLON {
  72446. /**
  72447. * Particle emitter emitting particles from the inside of a cone.
  72448. * It emits the particles alongside the cone volume from the base to the particle.
  72449. * The emission direction might be randomized.
  72450. */
  72451. export class ConeParticleEmitter implements IParticleEmitterType {
  72452. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72453. directionRandomizer: number;
  72454. private _radius;
  72455. private _angle;
  72456. private _height;
  72457. /**
  72458. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72459. */
  72460. radiusRange: number;
  72461. /**
  72462. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72463. */
  72464. heightRange: number;
  72465. /**
  72466. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72467. */
  72468. emitFromSpawnPointOnly: boolean;
  72469. /**
  72470. * Gets or sets the radius of the emission cone
  72471. */
  72472. radius: number;
  72473. /**
  72474. * Gets or sets the angle of the emission cone
  72475. */
  72476. angle: number;
  72477. private _buildHeight;
  72478. /**
  72479. * Creates a new instance ConeParticleEmitter
  72480. * @param radius the radius of the emission cone (1 by default)
  72481. * @param angle the cone base angle (PI by default)
  72482. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72483. */
  72484. constructor(radius?: number, angle?: number,
  72485. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72486. directionRandomizer?: number);
  72487. /**
  72488. * Called by the particle System when the direction is computed for the created particle.
  72489. * @param worldMatrix is the world matrix of the particle system
  72490. * @param directionToUpdate is the direction vector to update with the result
  72491. * @param particle is the particle we are computed the direction for
  72492. */
  72493. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72494. /**
  72495. * Called by the particle System when the position is computed for the created particle.
  72496. * @param worldMatrix is the world matrix of the particle system
  72497. * @param positionToUpdate is the position vector to update with the result
  72498. * @param particle is the particle we are computed the position for
  72499. */
  72500. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72501. /**
  72502. * Clones the current emitter and returns a copy of it
  72503. * @returns the new emitter
  72504. */
  72505. clone(): ConeParticleEmitter;
  72506. /**
  72507. * Called by the GPUParticleSystem to setup the update shader
  72508. * @param effect defines the update shader
  72509. */
  72510. applyToShader(effect: Effect): void;
  72511. /**
  72512. * Returns a string to use to update the GPU particles update shader
  72513. * @returns a string containng the defines string
  72514. */
  72515. getEffectDefines(): string;
  72516. /**
  72517. * Returns the string "ConeParticleEmitter"
  72518. * @returns a string containing the class name
  72519. */
  72520. getClassName(): string;
  72521. /**
  72522. * Serializes the particle system to a JSON object.
  72523. * @returns the JSON object
  72524. */
  72525. serialize(): any;
  72526. /**
  72527. * Parse properties from a JSON object
  72528. * @param serializationObject defines the JSON object
  72529. */
  72530. parse(serializationObject: any): void;
  72531. }
  72532. }
  72533. declare module BABYLON {
  72534. /**
  72535. * Particle emitter emitting particles from the inside of a cylinder.
  72536. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72537. */
  72538. export class CylinderParticleEmitter implements IParticleEmitterType {
  72539. /**
  72540. * The radius of the emission cylinder.
  72541. */
  72542. radius: number;
  72543. /**
  72544. * The height of the emission cylinder.
  72545. */
  72546. height: number;
  72547. /**
  72548. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72549. */
  72550. radiusRange: number;
  72551. /**
  72552. * How much to randomize the particle direction [0-1].
  72553. */
  72554. directionRandomizer: number;
  72555. /**
  72556. * Creates a new instance CylinderParticleEmitter
  72557. * @param radius the radius of the emission cylinder (1 by default)
  72558. * @param height the height of the emission cylinder (1 by default)
  72559. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72560. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72561. */
  72562. constructor(
  72563. /**
  72564. * The radius of the emission cylinder.
  72565. */
  72566. radius?: number,
  72567. /**
  72568. * The height of the emission cylinder.
  72569. */
  72570. height?: number,
  72571. /**
  72572. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72573. */
  72574. radiusRange?: number,
  72575. /**
  72576. * How much to randomize the particle direction [0-1].
  72577. */
  72578. directionRandomizer?: number);
  72579. /**
  72580. * Called by the particle System when the direction is computed for the created particle.
  72581. * @param worldMatrix is the world matrix of the particle system
  72582. * @param directionToUpdate is the direction vector to update with the result
  72583. * @param particle is the particle we are computed the direction for
  72584. */
  72585. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72586. /**
  72587. * Called by the particle System when the position is computed for the created particle.
  72588. * @param worldMatrix is the world matrix of the particle system
  72589. * @param positionToUpdate is the position vector to update with the result
  72590. * @param particle is the particle we are computed the position for
  72591. */
  72592. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72593. /**
  72594. * Clones the current emitter and returns a copy of it
  72595. * @returns the new emitter
  72596. */
  72597. clone(): CylinderParticleEmitter;
  72598. /**
  72599. * Called by the GPUParticleSystem to setup the update shader
  72600. * @param effect defines the update shader
  72601. */
  72602. applyToShader(effect: Effect): void;
  72603. /**
  72604. * Returns a string to use to update the GPU particles update shader
  72605. * @returns a string containng the defines string
  72606. */
  72607. getEffectDefines(): string;
  72608. /**
  72609. * Returns the string "CylinderParticleEmitter"
  72610. * @returns a string containing the class name
  72611. */
  72612. getClassName(): string;
  72613. /**
  72614. * Serializes the particle system to a JSON object.
  72615. * @returns the JSON object
  72616. */
  72617. serialize(): any;
  72618. /**
  72619. * Parse properties from a JSON object
  72620. * @param serializationObject defines the JSON object
  72621. */
  72622. parse(serializationObject: any): void;
  72623. }
  72624. /**
  72625. * Particle emitter emitting particles from the inside of a cylinder.
  72626. * It emits the particles randomly between two vectors.
  72627. */
  72628. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72629. /**
  72630. * The min limit of the emission direction.
  72631. */
  72632. direction1: Vector3;
  72633. /**
  72634. * The max limit of the emission direction.
  72635. */
  72636. direction2: Vector3;
  72637. /**
  72638. * Creates a new instance CylinderDirectedParticleEmitter
  72639. * @param radius the radius of the emission cylinder (1 by default)
  72640. * @param height the height of the emission cylinder (1 by default)
  72641. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72642. * @param direction1 the min limit of the emission direction (up vector by default)
  72643. * @param direction2 the max limit of the emission direction (up vector by default)
  72644. */
  72645. constructor(radius?: number, height?: number, radiusRange?: number,
  72646. /**
  72647. * The min limit of the emission direction.
  72648. */
  72649. direction1?: Vector3,
  72650. /**
  72651. * The max limit of the emission direction.
  72652. */
  72653. direction2?: Vector3);
  72654. /**
  72655. * Called by the particle System when the direction is computed for the created particle.
  72656. * @param worldMatrix is the world matrix of the particle system
  72657. * @param directionToUpdate is the direction vector to update with the result
  72658. * @param particle is the particle we are computed the direction for
  72659. */
  72660. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72661. /**
  72662. * Clones the current emitter and returns a copy of it
  72663. * @returns the new emitter
  72664. */
  72665. clone(): CylinderDirectedParticleEmitter;
  72666. /**
  72667. * Called by the GPUParticleSystem to setup the update shader
  72668. * @param effect defines the update shader
  72669. */
  72670. applyToShader(effect: Effect): void;
  72671. /**
  72672. * Returns a string to use to update the GPU particles update shader
  72673. * @returns a string containng the defines string
  72674. */
  72675. getEffectDefines(): string;
  72676. /**
  72677. * Returns the string "CylinderDirectedParticleEmitter"
  72678. * @returns a string containing the class name
  72679. */
  72680. getClassName(): string;
  72681. /**
  72682. * Serializes the particle system to a JSON object.
  72683. * @returns the JSON object
  72684. */
  72685. serialize(): any;
  72686. /**
  72687. * Parse properties from a JSON object
  72688. * @param serializationObject defines the JSON object
  72689. */
  72690. parse(serializationObject: any): void;
  72691. }
  72692. }
  72693. declare module BABYLON {
  72694. /**
  72695. * Particle emitter emitting particles from the inside of a hemisphere.
  72696. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72697. */
  72698. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72699. /**
  72700. * The radius of the emission hemisphere.
  72701. */
  72702. radius: number;
  72703. /**
  72704. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72705. */
  72706. radiusRange: number;
  72707. /**
  72708. * How much to randomize the particle direction [0-1].
  72709. */
  72710. directionRandomizer: number;
  72711. /**
  72712. * Creates a new instance HemisphericParticleEmitter
  72713. * @param radius the radius of the emission hemisphere (1 by default)
  72714. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72715. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72716. */
  72717. constructor(
  72718. /**
  72719. * The radius of the emission hemisphere.
  72720. */
  72721. radius?: number,
  72722. /**
  72723. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72724. */
  72725. radiusRange?: number,
  72726. /**
  72727. * How much to randomize the particle direction [0-1].
  72728. */
  72729. directionRandomizer?: number);
  72730. /**
  72731. * Called by the particle System when the direction is computed for the created particle.
  72732. * @param worldMatrix is the world matrix of the particle system
  72733. * @param directionToUpdate is the direction vector to update with the result
  72734. * @param particle is the particle we are computed the direction for
  72735. */
  72736. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72737. /**
  72738. * Called by the particle System when the position is computed for the created particle.
  72739. * @param worldMatrix is the world matrix of the particle system
  72740. * @param positionToUpdate is the position vector to update with the result
  72741. * @param particle is the particle we are computed the position for
  72742. */
  72743. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72744. /**
  72745. * Clones the current emitter and returns a copy of it
  72746. * @returns the new emitter
  72747. */
  72748. clone(): HemisphericParticleEmitter;
  72749. /**
  72750. * Called by the GPUParticleSystem to setup the update shader
  72751. * @param effect defines the update shader
  72752. */
  72753. applyToShader(effect: Effect): void;
  72754. /**
  72755. * Returns a string to use to update the GPU particles update shader
  72756. * @returns a string containng the defines string
  72757. */
  72758. getEffectDefines(): string;
  72759. /**
  72760. * Returns the string "HemisphericParticleEmitter"
  72761. * @returns a string containing the class name
  72762. */
  72763. getClassName(): string;
  72764. /**
  72765. * Serializes the particle system to a JSON object.
  72766. * @returns the JSON object
  72767. */
  72768. serialize(): any;
  72769. /**
  72770. * Parse properties from a JSON object
  72771. * @param serializationObject defines the JSON object
  72772. */
  72773. parse(serializationObject: any): void;
  72774. }
  72775. }
  72776. declare module BABYLON {
  72777. /**
  72778. * Particle emitter emitting particles from a point.
  72779. * It emits the particles randomly between 2 given directions.
  72780. */
  72781. export class PointParticleEmitter implements IParticleEmitterType {
  72782. /**
  72783. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72784. */
  72785. direction1: Vector3;
  72786. /**
  72787. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72788. */
  72789. direction2: Vector3;
  72790. /**
  72791. * Creates a new instance PointParticleEmitter
  72792. */
  72793. constructor();
  72794. /**
  72795. * Called by the particle System when the direction is computed for the created particle.
  72796. * @param worldMatrix is the world matrix of the particle system
  72797. * @param directionToUpdate is the direction vector to update with the result
  72798. * @param particle is the particle we are computed the direction for
  72799. */
  72800. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72801. /**
  72802. * Called by the particle System when the position is computed for the created particle.
  72803. * @param worldMatrix is the world matrix of the particle system
  72804. * @param positionToUpdate is the position vector to update with the result
  72805. * @param particle is the particle we are computed the position for
  72806. */
  72807. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72808. /**
  72809. * Clones the current emitter and returns a copy of it
  72810. * @returns the new emitter
  72811. */
  72812. clone(): PointParticleEmitter;
  72813. /**
  72814. * Called by the GPUParticleSystem to setup the update shader
  72815. * @param effect defines the update shader
  72816. */
  72817. applyToShader(effect: Effect): void;
  72818. /**
  72819. * Returns a string to use to update the GPU particles update shader
  72820. * @returns a string containng the defines string
  72821. */
  72822. getEffectDefines(): string;
  72823. /**
  72824. * Returns the string "PointParticleEmitter"
  72825. * @returns a string containing the class name
  72826. */
  72827. getClassName(): string;
  72828. /**
  72829. * Serializes the particle system to a JSON object.
  72830. * @returns the JSON object
  72831. */
  72832. serialize(): any;
  72833. /**
  72834. * Parse properties from a JSON object
  72835. * @param serializationObject defines the JSON object
  72836. */
  72837. parse(serializationObject: any): void;
  72838. }
  72839. }
  72840. declare module BABYLON {
  72841. /**
  72842. * Particle emitter emitting particles from the inside of a sphere.
  72843. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72844. */
  72845. export class SphereParticleEmitter implements IParticleEmitterType {
  72846. /**
  72847. * The radius of the emission sphere.
  72848. */
  72849. radius: number;
  72850. /**
  72851. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72852. */
  72853. radiusRange: number;
  72854. /**
  72855. * How much to randomize the particle direction [0-1].
  72856. */
  72857. directionRandomizer: number;
  72858. /**
  72859. * Creates a new instance SphereParticleEmitter
  72860. * @param radius the radius of the emission sphere (1 by default)
  72861. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72862. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72863. */
  72864. constructor(
  72865. /**
  72866. * The radius of the emission sphere.
  72867. */
  72868. radius?: number,
  72869. /**
  72870. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72871. */
  72872. radiusRange?: number,
  72873. /**
  72874. * How much to randomize the particle direction [0-1].
  72875. */
  72876. directionRandomizer?: number);
  72877. /**
  72878. * Called by the particle System when the direction is computed for the created particle.
  72879. * @param worldMatrix is the world matrix of the particle system
  72880. * @param directionToUpdate is the direction vector to update with the result
  72881. * @param particle is the particle we are computed the direction for
  72882. */
  72883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72884. /**
  72885. * Called by the particle System when the position is computed for the created particle.
  72886. * @param worldMatrix is the world matrix of the particle system
  72887. * @param positionToUpdate is the position vector to update with the result
  72888. * @param particle is the particle we are computed the position for
  72889. */
  72890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72891. /**
  72892. * Clones the current emitter and returns a copy of it
  72893. * @returns the new emitter
  72894. */
  72895. clone(): SphereParticleEmitter;
  72896. /**
  72897. * Called by the GPUParticleSystem to setup the update shader
  72898. * @param effect defines the update shader
  72899. */
  72900. applyToShader(effect: Effect): void;
  72901. /**
  72902. * Returns a string to use to update the GPU particles update shader
  72903. * @returns a string containng the defines string
  72904. */
  72905. getEffectDefines(): string;
  72906. /**
  72907. * Returns the string "SphereParticleEmitter"
  72908. * @returns a string containing the class name
  72909. */
  72910. getClassName(): string;
  72911. /**
  72912. * Serializes the particle system to a JSON object.
  72913. * @returns the JSON object
  72914. */
  72915. serialize(): any;
  72916. /**
  72917. * Parse properties from a JSON object
  72918. * @param serializationObject defines the JSON object
  72919. */
  72920. parse(serializationObject: any): void;
  72921. }
  72922. /**
  72923. * Particle emitter emitting particles from the inside of a sphere.
  72924. * It emits the particles randomly between two vectors.
  72925. */
  72926. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72927. /**
  72928. * The min limit of the emission direction.
  72929. */
  72930. direction1: Vector3;
  72931. /**
  72932. * The max limit of the emission direction.
  72933. */
  72934. direction2: Vector3;
  72935. /**
  72936. * Creates a new instance SphereDirectedParticleEmitter
  72937. * @param radius the radius of the emission sphere (1 by default)
  72938. * @param direction1 the min limit of the emission direction (up vector by default)
  72939. * @param direction2 the max limit of the emission direction (up vector by default)
  72940. */
  72941. constructor(radius?: number,
  72942. /**
  72943. * The min limit of the emission direction.
  72944. */
  72945. direction1?: Vector3,
  72946. /**
  72947. * The max limit of the emission direction.
  72948. */
  72949. direction2?: Vector3);
  72950. /**
  72951. * Called by the particle System when the direction is computed for the created particle.
  72952. * @param worldMatrix is the world matrix of the particle system
  72953. * @param directionToUpdate is the direction vector to update with the result
  72954. * @param particle is the particle we are computed the direction for
  72955. */
  72956. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72957. /**
  72958. * Clones the current emitter and returns a copy of it
  72959. * @returns the new emitter
  72960. */
  72961. clone(): SphereDirectedParticleEmitter;
  72962. /**
  72963. * Called by the GPUParticleSystem to setup the update shader
  72964. * @param effect defines the update shader
  72965. */
  72966. applyToShader(effect: Effect): void;
  72967. /**
  72968. * Returns a string to use to update the GPU particles update shader
  72969. * @returns a string containng the defines string
  72970. */
  72971. getEffectDefines(): string;
  72972. /**
  72973. * Returns the string "SphereDirectedParticleEmitter"
  72974. * @returns a string containing the class name
  72975. */
  72976. getClassName(): string;
  72977. /**
  72978. * Serializes the particle system to a JSON object.
  72979. * @returns the JSON object
  72980. */
  72981. serialize(): any;
  72982. /**
  72983. * Parse properties from a JSON object
  72984. * @param serializationObject defines the JSON object
  72985. */
  72986. parse(serializationObject: any): void;
  72987. }
  72988. }
  72989. declare module BABYLON {
  72990. /**
  72991. * Interface representing a particle system in Babylon.js.
  72992. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  72993. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  72994. */
  72995. export interface IParticleSystem {
  72996. /**
  72997. * List of animations used by the particle system.
  72998. */
  72999. animations: Animation[];
  73000. /**
  73001. * The id of the Particle system.
  73002. */
  73003. id: string;
  73004. /**
  73005. * The name of the Particle system.
  73006. */
  73007. name: string;
  73008. /**
  73009. * The emitter represents the Mesh or position we are attaching the particle system to.
  73010. */
  73011. emitter: Nullable<AbstractMesh | Vector3>;
  73012. /**
  73013. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73014. */
  73015. isBillboardBased: boolean;
  73016. /**
  73017. * The rendering group used by the Particle system to chose when to render.
  73018. */
  73019. renderingGroupId: number;
  73020. /**
  73021. * The layer mask we are rendering the particles through.
  73022. */
  73023. layerMask: number;
  73024. /**
  73025. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73026. */
  73027. updateSpeed: number;
  73028. /**
  73029. * The amount of time the particle system is running (depends of the overall update speed).
  73030. */
  73031. targetStopDuration: number;
  73032. /**
  73033. * The texture used to render each particle. (this can be a spritesheet)
  73034. */
  73035. particleTexture: Nullable<Texture>;
  73036. /**
  73037. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73038. */
  73039. blendMode: number;
  73040. /**
  73041. * Minimum life time of emitting particles.
  73042. */
  73043. minLifeTime: number;
  73044. /**
  73045. * Maximum life time of emitting particles.
  73046. */
  73047. maxLifeTime: number;
  73048. /**
  73049. * Minimum Size of emitting particles.
  73050. */
  73051. minSize: number;
  73052. /**
  73053. * Maximum Size of emitting particles.
  73054. */
  73055. maxSize: number;
  73056. /**
  73057. * Minimum scale of emitting particles on X axis.
  73058. */
  73059. minScaleX: number;
  73060. /**
  73061. * Maximum scale of emitting particles on X axis.
  73062. */
  73063. maxScaleX: number;
  73064. /**
  73065. * Minimum scale of emitting particles on Y axis.
  73066. */
  73067. minScaleY: number;
  73068. /**
  73069. * Maximum scale of emitting particles on Y axis.
  73070. */
  73071. maxScaleY: number;
  73072. /**
  73073. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73074. */
  73075. color1: Color4;
  73076. /**
  73077. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73078. */
  73079. color2: Color4;
  73080. /**
  73081. * Color the particle will have at the end of its lifetime.
  73082. */
  73083. colorDead: Color4;
  73084. /**
  73085. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73086. */
  73087. emitRate: number;
  73088. /**
  73089. * You can use gravity if you want to give an orientation to your particles.
  73090. */
  73091. gravity: Vector3;
  73092. /**
  73093. * Minimum power of emitting particles.
  73094. */
  73095. minEmitPower: number;
  73096. /**
  73097. * Maximum power of emitting particles.
  73098. */
  73099. maxEmitPower: number;
  73100. /**
  73101. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73102. */
  73103. minAngularSpeed: number;
  73104. /**
  73105. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73106. */
  73107. maxAngularSpeed: number;
  73108. /**
  73109. * Gets or sets the minimal initial rotation in radians.
  73110. */
  73111. minInitialRotation: number;
  73112. /**
  73113. * Gets or sets the maximal initial rotation in radians.
  73114. */
  73115. maxInitialRotation: number;
  73116. /**
  73117. * The particle emitter type defines the emitter used by the particle system.
  73118. * It can be for example box, sphere, or cone...
  73119. */
  73120. particleEmitterType: Nullable<IParticleEmitterType>;
  73121. /**
  73122. * Defines the delay in milliseconds before starting the system (0 by default)
  73123. */
  73124. startDelay: number;
  73125. /**
  73126. * 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
  73127. */
  73128. preWarmCycles: number;
  73129. /**
  73130. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73131. */
  73132. preWarmStepOffset: number;
  73133. /**
  73134. * 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)
  73135. */
  73136. spriteCellChangeSpeed: number;
  73137. /**
  73138. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73139. */
  73140. startSpriteCellID: number;
  73141. /**
  73142. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73143. */
  73144. endSpriteCellID: number;
  73145. /**
  73146. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73147. */
  73148. spriteCellWidth: number;
  73149. /**
  73150. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73151. */
  73152. spriteCellHeight: number;
  73153. /**
  73154. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73155. */
  73156. spriteRandomStartCell: boolean;
  73157. /**
  73158. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73159. */
  73160. isAnimationSheetEnabled: boolean;
  73161. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73162. translationPivot: Vector2;
  73163. /**
  73164. * Gets or sets a texture used to add random noise to particle positions
  73165. */
  73166. noiseTexture: Nullable<BaseTexture>;
  73167. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73168. noiseStrength: Vector3;
  73169. /**
  73170. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73171. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73172. */
  73173. billboardMode: number;
  73174. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73175. limitVelocityDamping: number;
  73176. /**
  73177. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73178. */
  73179. beginAnimationOnStart: boolean;
  73180. /**
  73181. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73182. */
  73183. beginAnimationFrom: number;
  73184. /**
  73185. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73186. */
  73187. beginAnimationTo: number;
  73188. /**
  73189. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73190. */
  73191. beginAnimationLoop: boolean;
  73192. /**
  73193. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73194. */
  73195. disposeOnStop: boolean;
  73196. /**
  73197. * Gets the maximum number of particles active at the same time.
  73198. * @returns The max number of active particles.
  73199. */
  73200. getCapacity(): number;
  73201. /**
  73202. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73203. * @returns True if it has been started, otherwise false.
  73204. */
  73205. isStarted(): boolean;
  73206. /**
  73207. * Animates the particle system for this frame.
  73208. */
  73209. animate(): void;
  73210. /**
  73211. * Renders the particle system in its current state.
  73212. * @returns the current number of particles
  73213. */
  73214. render(): number;
  73215. /**
  73216. * Dispose the particle system and frees its associated resources.
  73217. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73218. */
  73219. dispose(disposeTexture?: boolean): void;
  73220. /**
  73221. * Clones the particle system.
  73222. * @param name The name of the cloned object
  73223. * @param newEmitter The new emitter to use
  73224. * @returns the cloned particle system
  73225. */
  73226. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73227. /**
  73228. * Serializes the particle system to a JSON object.
  73229. * @returns the JSON object
  73230. */
  73231. serialize(): any;
  73232. /**
  73233. * Rebuild the particle system
  73234. */
  73235. rebuild(): void;
  73236. /**
  73237. * Starts the particle system and begins to emit
  73238. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73239. */
  73240. start(delay?: number): void;
  73241. /**
  73242. * Stops the particle system.
  73243. */
  73244. stop(): void;
  73245. /**
  73246. * Remove all active particles
  73247. */
  73248. reset(): void;
  73249. /**
  73250. * Is this system ready to be used/rendered
  73251. * @return true if the system is ready
  73252. */
  73253. isReady(): boolean;
  73254. /**
  73255. * Adds a new color gradient
  73256. * @param gradient defines the gradient to use (between 0 and 1)
  73257. * @param color1 defines the color to affect to the specified gradient
  73258. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73259. * @returns the current particle system
  73260. */
  73261. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73262. /**
  73263. * Remove a specific color gradient
  73264. * @param gradient defines the gradient to remove
  73265. * @returns the current particle system
  73266. */
  73267. removeColorGradient(gradient: number): IParticleSystem;
  73268. /**
  73269. * Adds a new size gradient
  73270. * @param gradient defines the gradient to use (between 0 and 1)
  73271. * @param factor defines the size factor to affect to the specified gradient
  73272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73273. * @returns the current particle system
  73274. */
  73275. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73276. /**
  73277. * Remove a specific size gradient
  73278. * @param gradient defines the gradient to remove
  73279. * @returns the current particle system
  73280. */
  73281. removeSizeGradient(gradient: number): IParticleSystem;
  73282. /**
  73283. * Gets the current list of color gradients.
  73284. * You must use addColorGradient and removeColorGradient to udpate this list
  73285. * @returns the list of color gradients
  73286. */
  73287. getColorGradients(): Nullable<Array<ColorGradient>>;
  73288. /**
  73289. * Gets the current list of size gradients.
  73290. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73291. * @returns the list of size gradients
  73292. */
  73293. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73294. /**
  73295. * Gets the current list of angular speed gradients.
  73296. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73297. * @returns the list of angular speed gradients
  73298. */
  73299. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73300. /**
  73301. * Adds a new angular speed gradient
  73302. * @param gradient defines the gradient to use (between 0 and 1)
  73303. * @param factor defines the angular speed to affect to the specified gradient
  73304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73305. * @returns the current particle system
  73306. */
  73307. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73308. /**
  73309. * Remove a specific angular speed gradient
  73310. * @param gradient defines the gradient to remove
  73311. * @returns the current particle system
  73312. */
  73313. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73314. /**
  73315. * Gets the current list of velocity gradients.
  73316. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73317. * @returns the list of velocity gradients
  73318. */
  73319. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73320. /**
  73321. * Adds a new velocity gradient
  73322. * @param gradient defines the gradient to use (between 0 and 1)
  73323. * @param factor defines the velocity to affect to the specified gradient
  73324. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73325. * @returns the current particle system
  73326. */
  73327. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73328. /**
  73329. * Remove a specific velocity gradient
  73330. * @param gradient defines the gradient to remove
  73331. * @returns the current particle system
  73332. */
  73333. removeVelocityGradient(gradient: number): IParticleSystem;
  73334. /**
  73335. * Gets the current list of limit velocity gradients.
  73336. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73337. * @returns the list of limit velocity gradients
  73338. */
  73339. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73340. /**
  73341. * Adds a new limit velocity gradient
  73342. * @param gradient defines the gradient to use (between 0 and 1)
  73343. * @param factor defines the limit velocity to affect to the specified gradient
  73344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73345. * @returns the current particle system
  73346. */
  73347. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73348. /**
  73349. * Remove a specific limit velocity gradient
  73350. * @param gradient defines the gradient to remove
  73351. * @returns the current particle system
  73352. */
  73353. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73354. /**
  73355. * Adds a new drag gradient
  73356. * @param gradient defines the gradient to use (between 0 and 1)
  73357. * @param factor defines the drag to affect to the specified gradient
  73358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73359. * @returns the current particle system
  73360. */
  73361. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73362. /**
  73363. * Remove a specific drag gradient
  73364. * @param gradient defines the gradient to remove
  73365. * @returns the current particle system
  73366. */
  73367. removeDragGradient(gradient: number): IParticleSystem;
  73368. /**
  73369. * Gets the current list of drag gradients.
  73370. * You must use addDragGradient and removeDragGradient to udpate this list
  73371. * @returns the list of drag gradients
  73372. */
  73373. getDragGradients(): Nullable<Array<FactorGradient>>;
  73374. /**
  73375. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73376. * @param gradient defines the gradient to use (between 0 and 1)
  73377. * @param factor defines the emit rate to affect to the specified gradient
  73378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73379. * @returns the current particle system
  73380. */
  73381. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73382. /**
  73383. * Remove a specific emit rate gradient
  73384. * @param gradient defines the gradient to remove
  73385. * @returns the current particle system
  73386. */
  73387. removeEmitRateGradient(gradient: number): IParticleSystem;
  73388. /**
  73389. * Gets the current list of emit rate gradients.
  73390. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73391. * @returns the list of emit rate gradients
  73392. */
  73393. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73394. /**
  73395. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73396. * @param gradient defines the gradient to use (between 0 and 1)
  73397. * @param factor defines the start size to affect to the specified gradient
  73398. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73399. * @returns the current particle system
  73400. */
  73401. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73402. /**
  73403. * Remove a specific start size gradient
  73404. * @param gradient defines the gradient to remove
  73405. * @returns the current particle system
  73406. */
  73407. removeStartSizeGradient(gradient: number): IParticleSystem;
  73408. /**
  73409. * Gets the current list of start size gradients.
  73410. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73411. * @returns the list of start size gradients
  73412. */
  73413. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73414. /**
  73415. * Adds a new life time gradient
  73416. * @param gradient defines the gradient to use (between 0 and 1)
  73417. * @param factor defines the life time factor to affect to the specified gradient
  73418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73419. * @returns the current particle system
  73420. */
  73421. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73422. /**
  73423. * Remove a specific life time gradient
  73424. * @param gradient defines the gradient to remove
  73425. * @returns the current particle system
  73426. */
  73427. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73428. /**
  73429. * Gets the current list of life time gradients.
  73430. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73431. * @returns the list of life time gradients
  73432. */
  73433. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73434. /**
  73435. * Gets the current list of color gradients.
  73436. * You must use addColorGradient and removeColorGradient to udpate this list
  73437. * @returns the list of color gradients
  73438. */
  73439. getColorGradients(): Nullable<Array<ColorGradient>>;
  73440. /**
  73441. * Adds a new ramp gradient used to remap particle colors
  73442. * @param gradient defines the gradient to use (between 0 and 1)
  73443. * @param color defines the color to affect to the specified gradient
  73444. * @returns the current particle system
  73445. */
  73446. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73447. /**
  73448. * Gets the current list of ramp gradients.
  73449. * You must use addRampGradient and removeRampGradient to udpate this list
  73450. * @returns the list of ramp gradients
  73451. */
  73452. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73453. /** Gets or sets a boolean indicating that ramp gradients must be used
  73454. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73455. */
  73456. useRampGradients: boolean;
  73457. /**
  73458. * Adds a new color remap gradient
  73459. * @param gradient defines the gradient to use (between 0 and 1)
  73460. * @param min defines the color remap minimal range
  73461. * @param max defines the color remap maximal range
  73462. * @returns the current particle system
  73463. */
  73464. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73465. /**
  73466. * Gets the current list of color remap gradients.
  73467. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73468. * @returns the list of color remap gradients
  73469. */
  73470. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73471. /**
  73472. * Adds a new alpha remap gradient
  73473. * @param gradient defines the gradient to use (between 0 and 1)
  73474. * @param min defines the alpha remap minimal range
  73475. * @param max defines the alpha remap maximal range
  73476. * @returns the current particle system
  73477. */
  73478. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73479. /**
  73480. * Gets the current list of alpha remap gradients.
  73481. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73482. * @returns the list of alpha remap gradients
  73483. */
  73484. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73485. /**
  73486. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73487. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73488. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73489. * @returns the emitter
  73490. */
  73491. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73492. /**
  73493. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73494. * @param radius The radius of the hemisphere to emit from
  73495. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73496. * @returns the emitter
  73497. */
  73498. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73499. /**
  73500. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73501. * @param radius The radius of the sphere to emit from
  73502. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73503. * @returns the emitter
  73504. */
  73505. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73506. /**
  73507. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73508. * @param radius The radius of the sphere to emit from
  73509. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73510. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73511. * @returns the emitter
  73512. */
  73513. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73514. /**
  73515. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73516. * @param radius The radius of the emission cylinder
  73517. * @param height The height of the emission cylinder
  73518. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73519. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73520. * @returns the emitter
  73521. */
  73522. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73523. /**
  73524. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73525. * @param radius The radius of the cylinder to emit from
  73526. * @param height The height of the emission cylinder
  73527. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73530. * @returns the emitter
  73531. */
  73532. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73533. /**
  73534. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73535. * @param radius The radius of the cone to emit from
  73536. * @param angle The base angle of the cone
  73537. * @returns the emitter
  73538. */
  73539. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73540. /**
  73541. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73542. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73543. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73544. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73545. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73546. * @returns the emitter
  73547. */
  73548. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73549. /**
  73550. * Get hosting scene
  73551. * @returns the scene
  73552. */
  73553. getScene(): Scene;
  73554. }
  73555. }
  73556. declare module BABYLON {
  73557. /**
  73558. * Creates an instance based on a source mesh.
  73559. */
  73560. export class InstancedMesh extends AbstractMesh {
  73561. private _sourceMesh;
  73562. private _currentLOD;
  73563. /** @hidden */
  73564. _indexInSourceMeshInstanceArray: number;
  73565. constructor(name: string, source: Mesh);
  73566. /**
  73567. * Returns the string "InstancedMesh".
  73568. */
  73569. getClassName(): string;
  73570. /**
  73571. * If the source mesh receives shadows
  73572. */
  73573. readonly receiveShadows: boolean;
  73574. /**
  73575. * The material of the source mesh
  73576. */
  73577. readonly material: Nullable<Material>;
  73578. /**
  73579. * Visibility of the source mesh
  73580. */
  73581. readonly visibility: number;
  73582. /**
  73583. * Skeleton of the source mesh
  73584. */
  73585. readonly skeleton: Nullable<Skeleton>;
  73586. /**
  73587. * Rendering ground id of the source mesh
  73588. */
  73589. renderingGroupId: number;
  73590. /**
  73591. * Returns the total number of vertices (integer).
  73592. */
  73593. getTotalVertices(): number;
  73594. /**
  73595. * Returns a positive integer : the total number of indices in this mesh geometry.
  73596. * @returns the numner of indices or zero if the mesh has no geometry.
  73597. */
  73598. getTotalIndices(): number;
  73599. /**
  73600. * The source mesh of the instance
  73601. */
  73602. readonly sourceMesh: Mesh;
  73603. /**
  73604. * Is this node ready to be used/rendered
  73605. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73606. * @return {boolean} is it ready
  73607. */
  73608. isReady(completeCheck?: boolean): boolean;
  73609. /**
  73610. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73611. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73612. * @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.
  73613. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73614. */
  73615. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73616. /**
  73617. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73618. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73619. * The `data` are either a numeric array either a Float32Array.
  73620. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73621. * 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).
  73622. * Note that a new underlying VertexBuffer object is created each call.
  73623. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73624. *
  73625. * Possible `kind` values :
  73626. * - VertexBuffer.PositionKind
  73627. * - VertexBuffer.UVKind
  73628. * - VertexBuffer.UV2Kind
  73629. * - VertexBuffer.UV3Kind
  73630. * - VertexBuffer.UV4Kind
  73631. * - VertexBuffer.UV5Kind
  73632. * - VertexBuffer.UV6Kind
  73633. * - VertexBuffer.ColorKind
  73634. * - VertexBuffer.MatricesIndicesKind
  73635. * - VertexBuffer.MatricesIndicesExtraKind
  73636. * - VertexBuffer.MatricesWeightsKind
  73637. * - VertexBuffer.MatricesWeightsExtraKind
  73638. *
  73639. * Returns the Mesh.
  73640. */
  73641. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73642. /**
  73643. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73644. * If the mesh has no geometry, it is simply returned as it is.
  73645. * The `data` are either a numeric array either a Float32Array.
  73646. * No new underlying VertexBuffer object is created.
  73647. * 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.
  73648. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73649. *
  73650. * Possible `kind` values :
  73651. * - VertexBuffer.PositionKind
  73652. * - VertexBuffer.UVKind
  73653. * - VertexBuffer.UV2Kind
  73654. * - VertexBuffer.UV3Kind
  73655. * - VertexBuffer.UV4Kind
  73656. * - VertexBuffer.UV5Kind
  73657. * - VertexBuffer.UV6Kind
  73658. * - VertexBuffer.ColorKind
  73659. * - VertexBuffer.MatricesIndicesKind
  73660. * - VertexBuffer.MatricesIndicesExtraKind
  73661. * - VertexBuffer.MatricesWeightsKind
  73662. * - VertexBuffer.MatricesWeightsExtraKind
  73663. *
  73664. * Returns the Mesh.
  73665. */
  73666. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73667. /**
  73668. * Sets the mesh indices.
  73669. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73670. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73671. * This method creates a new index buffer each call.
  73672. * Returns the Mesh.
  73673. */
  73674. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73675. /**
  73676. * Boolean : True if the mesh owns the requested kind of data.
  73677. */
  73678. isVerticesDataPresent(kind: string): boolean;
  73679. /**
  73680. * Returns an array of indices (IndicesArray).
  73681. */
  73682. getIndices(): Nullable<IndicesArray>;
  73683. readonly _positions: Nullable<Vector3[]>;
  73684. /**
  73685. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73686. * This means the mesh underlying bounding box and sphere are recomputed.
  73687. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73688. * @returns the current mesh
  73689. */
  73690. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73691. /** @hidden */
  73692. _preActivate(): InstancedMesh;
  73693. /** @hidden */
  73694. _activate(renderId: number): InstancedMesh;
  73695. /**
  73696. * Returns the current associated LOD AbstractMesh.
  73697. */
  73698. getLOD(camera: Camera): AbstractMesh;
  73699. /** @hidden */
  73700. _syncSubMeshes(): InstancedMesh;
  73701. /** @hidden */
  73702. _generatePointsArray(): boolean;
  73703. /**
  73704. * Creates a new InstancedMesh from the current mesh.
  73705. * - name (string) : the cloned mesh name
  73706. * - newParent (optional Node) : the optional Node to parent the clone to.
  73707. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73708. *
  73709. * Returns the clone.
  73710. */
  73711. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73712. /**
  73713. * Disposes the InstancedMesh.
  73714. * Returns nothing.
  73715. */
  73716. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73717. }
  73718. }
  73719. declare module BABYLON {
  73720. /**
  73721. * Defines the options associated with the creation of a shader material.
  73722. */
  73723. export interface IShaderMaterialOptions {
  73724. /**
  73725. * Does the material work in alpha blend mode
  73726. */
  73727. needAlphaBlending: boolean;
  73728. /**
  73729. * Does the material work in alpha test mode
  73730. */
  73731. needAlphaTesting: boolean;
  73732. /**
  73733. * The list of attribute names used in the shader
  73734. */
  73735. attributes: string[];
  73736. /**
  73737. * The list of unifrom names used in the shader
  73738. */
  73739. uniforms: string[];
  73740. /**
  73741. * The list of UBO names used in the shader
  73742. */
  73743. uniformBuffers: string[];
  73744. /**
  73745. * The list of sampler names used in the shader
  73746. */
  73747. samplers: string[];
  73748. /**
  73749. * The list of defines used in the shader
  73750. */
  73751. defines: string[];
  73752. }
  73753. /**
  73754. * 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.
  73755. *
  73756. * This returned material effects how the mesh will look based on the code in the shaders.
  73757. *
  73758. * @see http://doc.babylonjs.com/how_to/shader_material
  73759. */
  73760. export class ShaderMaterial extends Material {
  73761. private _shaderPath;
  73762. private _options;
  73763. private _textures;
  73764. private _textureArrays;
  73765. private _floats;
  73766. private _ints;
  73767. private _floatsArrays;
  73768. private _colors3;
  73769. private _colors3Arrays;
  73770. private _colors4;
  73771. private _vectors2;
  73772. private _vectors3;
  73773. private _vectors4;
  73774. private _matrices;
  73775. private _matrices3x3;
  73776. private _matrices2x2;
  73777. private _vectors2Arrays;
  73778. private _vectors3Arrays;
  73779. private _cachedWorldViewMatrix;
  73780. private _renderId;
  73781. /**
  73782. * Instantiate a new shader material.
  73783. * 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.
  73784. * This returned material effects how the mesh will look based on the code in the shaders.
  73785. * @see http://doc.babylonjs.com/how_to/shader_material
  73786. * @param name Define the name of the material in the scene
  73787. * @param scene Define the scene the material belongs to
  73788. * @param shaderPath Defines the route to the shader code in one of three ways:
  73789. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  73790. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  73791. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  73792. * @param options Define the options used to create the shader
  73793. */
  73794. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  73795. /**
  73796. * Gets the current class name of the material e.g. "ShaderMaterial"
  73797. * Mainly use in serialization.
  73798. * @returns the class name
  73799. */
  73800. getClassName(): string;
  73801. /**
  73802. * Specifies if the material will require alpha blending
  73803. * @returns a boolean specifying if alpha blending is needed
  73804. */
  73805. needAlphaBlending(): boolean;
  73806. /**
  73807. * Specifies if this material should be rendered in alpha test mode
  73808. * @returns a boolean specifying if an alpha test is needed.
  73809. */
  73810. needAlphaTesting(): boolean;
  73811. private _checkUniform;
  73812. /**
  73813. * Set a texture in the shader.
  73814. * @param name Define the name of the uniform samplers as defined in the shader
  73815. * @param texture Define the texture to bind to this sampler
  73816. * @return the material itself allowing "fluent" like uniform updates
  73817. */
  73818. setTexture(name: string, texture: Texture): ShaderMaterial;
  73819. /**
  73820. * Set a texture array in the shader.
  73821. * @param name Define the name of the uniform sampler array as defined in the shader
  73822. * @param textures Define the list of textures to bind to this sampler
  73823. * @return the material itself allowing "fluent" like uniform updates
  73824. */
  73825. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  73826. /**
  73827. * Set a float in the shader.
  73828. * @param name Define the name of the uniform as defined in the shader
  73829. * @param value Define the value to give to the uniform
  73830. * @return the material itself allowing "fluent" like uniform updates
  73831. */
  73832. setFloat(name: string, value: number): ShaderMaterial;
  73833. /**
  73834. * Set a int in the shader.
  73835. * @param name Define the name of the uniform as defined in the shader
  73836. * @param value Define the value to give to the uniform
  73837. * @return the material itself allowing "fluent" like uniform updates
  73838. */
  73839. setInt(name: string, value: number): ShaderMaterial;
  73840. /**
  73841. * Set an array of floats in the shader.
  73842. * @param name Define the name of the uniform as defined in the shader
  73843. * @param value Define the value to give to the uniform
  73844. * @return the material itself allowing "fluent" like uniform updates
  73845. */
  73846. setFloats(name: string, value: number[]): ShaderMaterial;
  73847. /**
  73848. * Set a vec3 in the shader from a Color3.
  73849. * @param name Define the name of the uniform as defined in the shader
  73850. * @param value Define the value to give to the uniform
  73851. * @return the material itself allowing "fluent" like uniform updates
  73852. */
  73853. setColor3(name: string, value: Color3): ShaderMaterial;
  73854. /**
  73855. * Set a vec3 array in the shader from a Color3 array.
  73856. * @param name Define the name of the uniform as defined in the shader
  73857. * @param value Define the value to give to the uniform
  73858. * @return the material itself allowing "fluent" like uniform updates
  73859. */
  73860. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  73861. /**
  73862. * Set a vec4 in the shader from a Color4.
  73863. * @param name Define the name of the uniform as defined in the shader
  73864. * @param value Define the value to give to the uniform
  73865. * @return the material itself allowing "fluent" like uniform updates
  73866. */
  73867. setColor4(name: string, value: Color4): ShaderMaterial;
  73868. /**
  73869. * Set a vec2 in the shader from a Vector2.
  73870. * @param name Define the name of the uniform as defined in the shader
  73871. * @param value Define the value to give to the uniform
  73872. * @return the material itself allowing "fluent" like uniform updates
  73873. */
  73874. setVector2(name: string, value: Vector2): ShaderMaterial;
  73875. /**
  73876. * Set a vec3 in the shader from a Vector3.
  73877. * @param name Define the name of the uniform as defined in the shader
  73878. * @param value Define the value to give to the uniform
  73879. * @return the material itself allowing "fluent" like uniform updates
  73880. */
  73881. setVector3(name: string, value: Vector3): ShaderMaterial;
  73882. /**
  73883. * Set a vec4 in the shader from a Vector4.
  73884. * @param name Define the name of the uniform as defined in the shader
  73885. * @param value Define the value to give to the uniform
  73886. * @return the material itself allowing "fluent" like uniform updates
  73887. */
  73888. setVector4(name: string, value: Vector4): ShaderMaterial;
  73889. /**
  73890. * Set a mat4 in the shader from a Matrix.
  73891. * @param name Define the name of the uniform as defined in the shader
  73892. * @param value Define the value to give to the uniform
  73893. * @return the material itself allowing "fluent" like uniform updates
  73894. */
  73895. setMatrix(name: string, value: Matrix): ShaderMaterial;
  73896. /**
  73897. * Set a mat3 in the shader from a Float32Array.
  73898. * @param name Define the name of the uniform as defined in the shader
  73899. * @param value Define the value to give to the uniform
  73900. * @return the material itself allowing "fluent" like uniform updates
  73901. */
  73902. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  73903. /**
  73904. * Set a mat2 in the shader from a Float32Array.
  73905. * @param name Define the name of the uniform as defined in the shader
  73906. * @param value Define the value to give to the uniform
  73907. * @return the material itself allowing "fluent" like uniform updates
  73908. */
  73909. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  73910. /**
  73911. * Set a vec2 array in the shader from a number array.
  73912. * @param name Define the name of the uniform as defined in the shader
  73913. * @param value Define the value to give to the uniform
  73914. * @return the material itself allowing "fluent" like uniform updates
  73915. */
  73916. setArray2(name: string, value: number[]): ShaderMaterial;
  73917. /**
  73918. * Set a vec3 array in the shader from a number array.
  73919. * @param name Define the name of the uniform as defined in the shader
  73920. * @param value Define the value to give to the uniform
  73921. * @return the material itself allowing "fluent" like uniform updates
  73922. */
  73923. setArray3(name: string, value: number[]): ShaderMaterial;
  73924. private _checkCache;
  73925. /**
  73926. * Checks if the material is ready to render the requested mesh
  73927. * @param mesh Define the mesh to render
  73928. * @param useInstances Define whether or not the material is used with instances
  73929. * @returns true if ready, otherwise false
  73930. */
  73931. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  73932. /**
  73933. * Binds the world matrix to the material
  73934. * @param world defines the world transformation matrix
  73935. */
  73936. bindOnlyWorldMatrix(world: Matrix): void;
  73937. /**
  73938. * Binds the material to the mesh
  73939. * @param world defines the world transformation matrix
  73940. * @param mesh defines the mesh to bind the material to
  73941. */
  73942. bind(world: Matrix, mesh?: Mesh): void;
  73943. /**
  73944. * Gets the active textures from the material
  73945. * @returns an array of textures
  73946. */
  73947. getActiveTextures(): BaseTexture[];
  73948. /**
  73949. * Specifies if the material uses a texture
  73950. * @param texture defines the texture to check against the material
  73951. * @returns a boolean specifying if the material uses the texture
  73952. */
  73953. hasTexture(texture: BaseTexture): boolean;
  73954. /**
  73955. * Makes a duplicate of the material, and gives it a new name
  73956. * @param name defines the new name for the duplicated material
  73957. * @returns the cloned material
  73958. */
  73959. clone(name: string): ShaderMaterial;
  73960. /**
  73961. * Disposes the material
  73962. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73963. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  73964. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  73965. */
  73966. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  73967. /**
  73968. * Serializes this material in a JSON representation
  73969. * @returns the serialized material object
  73970. */
  73971. serialize(): any;
  73972. /**
  73973. * Creates a shader material from parsed shader material data
  73974. * @param source defines the JSON represnetation of the material
  73975. * @param scene defines the hosting scene
  73976. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73977. * @returns a new material
  73978. */
  73979. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  73980. }
  73981. }
  73982. declare module BABYLON {
  73983. /** @hidden */
  73984. export var colorPixelShader: {
  73985. name: string;
  73986. shader: string;
  73987. };
  73988. }
  73989. declare module BABYLON {
  73990. /** @hidden */
  73991. export var colorVertexShader: {
  73992. name: string;
  73993. shader: string;
  73994. };
  73995. }
  73996. declare module BABYLON {
  73997. /**
  73998. * Line mesh
  73999. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74000. */
  74001. export class LinesMesh extends Mesh {
  74002. /**
  74003. * If vertex color should be applied to the mesh
  74004. */
  74005. useVertexColor?: boolean | undefined;
  74006. /**
  74007. * If vertex alpha should be applied to the mesh
  74008. */
  74009. useVertexAlpha?: boolean | undefined;
  74010. /**
  74011. * Color of the line (Default: White)
  74012. */
  74013. color: Color3;
  74014. /**
  74015. * Alpha of the line (Default: 1)
  74016. */
  74017. alpha: number;
  74018. /**
  74019. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74020. * This margin is expressed in world space coordinates, so its value may vary.
  74021. * Default value is 0.1
  74022. */
  74023. intersectionThreshold: number;
  74024. private _colorShader;
  74025. /**
  74026. * Creates a new LinesMesh
  74027. * @param name defines the name
  74028. * @param scene defines the hosting scene
  74029. * @param parent defines the parent mesh if any
  74030. * @param source defines the optional source LinesMesh used to clone data from
  74031. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74032. * When false, achieved by calling a clone(), also passing False.
  74033. * This will make creation of children, recursive.
  74034. * @param useVertexColor defines if this LinesMesh supports vertex color
  74035. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74036. */
  74037. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74038. /**
  74039. * If vertex color should be applied to the mesh
  74040. */
  74041. useVertexColor?: boolean | undefined,
  74042. /**
  74043. * If vertex alpha should be applied to the mesh
  74044. */
  74045. useVertexAlpha?: boolean | undefined);
  74046. /**
  74047. * Returns the string "LineMesh"
  74048. */
  74049. getClassName(): string;
  74050. /**
  74051. * @hidden
  74052. */
  74053. /**
  74054. * @hidden
  74055. */
  74056. material: Material;
  74057. /**
  74058. * @hidden
  74059. */
  74060. readonly checkCollisions: boolean;
  74061. /** @hidden */
  74062. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74063. /** @hidden */
  74064. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74065. /**
  74066. * Disposes of the line mesh
  74067. * @param doNotRecurse If children should be disposed
  74068. */
  74069. dispose(doNotRecurse?: boolean): void;
  74070. /**
  74071. * Returns a new LineMesh object cloned from the current one.
  74072. */
  74073. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74074. /**
  74075. * Creates a new InstancedLinesMesh object from the mesh model.
  74076. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74077. * @param name defines the name of the new instance
  74078. * @returns a new InstancedLinesMesh
  74079. */
  74080. createInstance(name: string): InstancedLinesMesh;
  74081. }
  74082. /**
  74083. * Creates an instance based on a source LinesMesh
  74084. */
  74085. export class InstancedLinesMesh extends InstancedMesh {
  74086. /**
  74087. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74088. * This margin is expressed in world space coordinates, so its value may vary.
  74089. * Initilized with the intersectionThreshold value of the source LinesMesh
  74090. */
  74091. intersectionThreshold: number;
  74092. constructor(name: string, source: LinesMesh);
  74093. /**
  74094. * Returns the string "InstancedLinesMesh".
  74095. */
  74096. getClassName(): string;
  74097. }
  74098. }
  74099. declare module BABYLON {
  74100. /** @hidden */
  74101. export var linePixelShader: {
  74102. name: string;
  74103. shader: string;
  74104. };
  74105. }
  74106. declare module BABYLON {
  74107. /** @hidden */
  74108. export var lineVertexShader: {
  74109. name: string;
  74110. shader: string;
  74111. };
  74112. }
  74113. declare module BABYLON {
  74114. interface AbstractMesh {
  74115. /**
  74116. * Disables the mesh edge rendering mode
  74117. * @returns the currentAbstractMesh
  74118. */
  74119. disableEdgesRendering(): AbstractMesh;
  74120. /**
  74121. * Enables the edge rendering mode on the mesh.
  74122. * This mode makes the mesh edges visible
  74123. * @param epsilon defines the maximal distance between two angles to detect a face
  74124. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74125. * @returns the currentAbstractMesh
  74126. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74127. */
  74128. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74129. /**
  74130. * Gets the edgesRenderer associated with the mesh
  74131. */
  74132. edgesRenderer: Nullable<EdgesRenderer>;
  74133. }
  74134. interface LinesMesh {
  74135. /**
  74136. * Enables the edge rendering mode on the mesh.
  74137. * This mode makes the mesh edges visible
  74138. * @param epsilon defines the maximal distance between two angles to detect a face
  74139. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74140. * @returns the currentAbstractMesh
  74141. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74142. */
  74143. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74144. }
  74145. interface InstancedLinesMesh {
  74146. /**
  74147. * Enables the edge rendering mode on the mesh.
  74148. * This mode makes the mesh edges visible
  74149. * @param epsilon defines the maximal distance between two angles to detect a face
  74150. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74151. * @returns the current InstancedLinesMesh
  74152. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74153. */
  74154. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74155. }
  74156. /**
  74157. * Defines the minimum contract an Edges renderer should follow.
  74158. */
  74159. export interface IEdgesRenderer extends IDisposable {
  74160. /**
  74161. * Gets or sets a boolean indicating if the edgesRenderer is active
  74162. */
  74163. isEnabled: boolean;
  74164. /**
  74165. * Renders the edges of the attached mesh,
  74166. */
  74167. render(): void;
  74168. /**
  74169. * Checks wether or not the edges renderer is ready to render.
  74170. * @return true if ready, otherwise false.
  74171. */
  74172. isReady(): boolean;
  74173. }
  74174. /**
  74175. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74176. */
  74177. export class EdgesRenderer implements IEdgesRenderer {
  74178. /**
  74179. * Define the size of the edges with an orthographic camera
  74180. */
  74181. edgesWidthScalerForOrthographic: number;
  74182. /**
  74183. * Define the size of the edges with a perspective camera
  74184. */
  74185. edgesWidthScalerForPerspective: number;
  74186. protected _source: AbstractMesh;
  74187. protected _linesPositions: number[];
  74188. protected _linesNormals: number[];
  74189. protected _linesIndices: number[];
  74190. protected _epsilon: number;
  74191. protected _indicesCount: number;
  74192. protected _lineShader: ShaderMaterial;
  74193. protected _ib: WebGLBuffer;
  74194. protected _buffers: {
  74195. [key: string]: Nullable<VertexBuffer>;
  74196. };
  74197. protected _checkVerticesInsteadOfIndices: boolean;
  74198. private _meshRebuildObserver;
  74199. private _meshDisposeObserver;
  74200. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74201. isEnabled: boolean;
  74202. /**
  74203. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74204. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74205. * @param source Mesh used to create edges
  74206. * @param epsilon sum of angles in adjacency to check for edge
  74207. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74208. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74209. */
  74210. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74211. protected _prepareRessources(): void;
  74212. /** @hidden */
  74213. _rebuild(): void;
  74214. /**
  74215. * Releases the required resources for the edges renderer
  74216. */
  74217. dispose(): void;
  74218. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74219. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74220. /**
  74221. * Checks if the pair of p0 and p1 is en edge
  74222. * @param faceIndex
  74223. * @param edge
  74224. * @param faceNormals
  74225. * @param p0
  74226. * @param p1
  74227. * @private
  74228. */
  74229. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74230. /**
  74231. * push line into the position, normal and index buffer
  74232. * @protected
  74233. */
  74234. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74235. /**
  74236. * Generates lines edges from adjacencjes
  74237. * @private
  74238. */
  74239. _generateEdgesLines(): void;
  74240. /**
  74241. * Checks wether or not the edges renderer is ready to render.
  74242. * @return true if ready, otherwise false.
  74243. */
  74244. isReady(): boolean;
  74245. /**
  74246. * Renders the edges of the attached mesh,
  74247. */
  74248. render(): void;
  74249. }
  74250. /**
  74251. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74252. */
  74253. export class LineEdgesRenderer extends EdgesRenderer {
  74254. /**
  74255. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74256. * @param source LineMesh used to generate edges
  74257. * @param epsilon not important (specified angle for edge detection)
  74258. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74259. */
  74260. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74261. /**
  74262. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74263. */
  74264. _generateEdgesLines(): void;
  74265. }
  74266. }
  74267. declare module BABYLON {
  74268. /**
  74269. * This represents the object necessary to create a rendering group.
  74270. * This is exclusively used and created by the rendering manager.
  74271. * To modify the behavior, you use the available helpers in your scene or meshes.
  74272. * @hidden
  74273. */
  74274. export class RenderingGroup {
  74275. index: number;
  74276. private _scene;
  74277. private _opaqueSubMeshes;
  74278. private _transparentSubMeshes;
  74279. private _alphaTestSubMeshes;
  74280. private _depthOnlySubMeshes;
  74281. private _particleSystems;
  74282. private _spriteManagers;
  74283. private _opaqueSortCompareFn;
  74284. private _alphaTestSortCompareFn;
  74285. private _transparentSortCompareFn;
  74286. private _renderOpaque;
  74287. private _renderAlphaTest;
  74288. private _renderTransparent;
  74289. private _edgesRenderers;
  74290. onBeforeTransparentRendering: () => void;
  74291. /**
  74292. * Set the opaque sort comparison function.
  74293. * If null the sub meshes will be render in the order they were created
  74294. */
  74295. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74296. /**
  74297. * Set the alpha test sort comparison function.
  74298. * If null the sub meshes will be render in the order they were created
  74299. */
  74300. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74301. /**
  74302. * Set the transparent sort comparison function.
  74303. * If null the sub meshes will be render in the order they were created
  74304. */
  74305. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74306. /**
  74307. * Creates a new rendering group.
  74308. * @param index The rendering group index
  74309. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74310. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74311. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74312. */
  74313. 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>);
  74314. /**
  74315. * Render all the sub meshes contained in the group.
  74316. * @param customRenderFunction Used to override the default render behaviour of the group.
  74317. * @returns true if rendered some submeshes.
  74318. */
  74319. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74320. /**
  74321. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74322. * @param subMeshes The submeshes to render
  74323. */
  74324. private renderOpaqueSorted;
  74325. /**
  74326. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74327. * @param subMeshes The submeshes to render
  74328. */
  74329. private renderAlphaTestSorted;
  74330. /**
  74331. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74332. * @param subMeshes The submeshes to render
  74333. */
  74334. private renderTransparentSorted;
  74335. /**
  74336. * Renders the submeshes in a specified order.
  74337. * @param subMeshes The submeshes to sort before render
  74338. * @param sortCompareFn The comparison function use to sort
  74339. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74340. * @param transparent Specifies to activate blending if true
  74341. */
  74342. private static renderSorted;
  74343. /**
  74344. * Renders the submeshes in the order they were dispatched (no sort applied).
  74345. * @param subMeshes The submeshes to render
  74346. */
  74347. private static renderUnsorted;
  74348. /**
  74349. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74350. * are rendered back to front if in the same alpha index.
  74351. *
  74352. * @param a The first submesh
  74353. * @param b The second submesh
  74354. * @returns The result of the comparison
  74355. */
  74356. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74357. /**
  74358. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74359. * are rendered back to front.
  74360. *
  74361. * @param a The first submesh
  74362. * @param b The second submesh
  74363. * @returns The result of the comparison
  74364. */
  74365. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74366. /**
  74367. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74368. * are rendered front to back (prevent overdraw).
  74369. *
  74370. * @param a The first submesh
  74371. * @param b The second submesh
  74372. * @returns The result of the comparison
  74373. */
  74374. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74375. /**
  74376. * Resets the different lists of submeshes to prepare a new frame.
  74377. */
  74378. prepare(): void;
  74379. dispose(): void;
  74380. /**
  74381. * Inserts the submesh in its correct queue depending on its material.
  74382. * @param subMesh The submesh to dispatch
  74383. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74384. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74385. */
  74386. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74387. dispatchSprites(spriteManager: ISpriteManager): void;
  74388. dispatchParticles(particleSystem: IParticleSystem): void;
  74389. private _renderParticles;
  74390. private _renderSprites;
  74391. }
  74392. }
  74393. declare module BABYLON {
  74394. /**
  74395. * Interface describing the different options available in the rendering manager
  74396. * regarding Auto Clear between groups.
  74397. */
  74398. export interface IRenderingManagerAutoClearSetup {
  74399. /**
  74400. * Defines whether or not autoclear is enable.
  74401. */
  74402. autoClear: boolean;
  74403. /**
  74404. * Defines whether or not to autoclear the depth buffer.
  74405. */
  74406. depth: boolean;
  74407. /**
  74408. * Defines whether or not to autoclear the stencil buffer.
  74409. */
  74410. stencil: boolean;
  74411. }
  74412. /**
  74413. * This class is used by the onRenderingGroupObservable
  74414. */
  74415. export class RenderingGroupInfo {
  74416. /**
  74417. * The Scene that being rendered
  74418. */
  74419. scene: Scene;
  74420. /**
  74421. * The camera currently used for the rendering pass
  74422. */
  74423. camera: Nullable<Camera>;
  74424. /**
  74425. * The ID of the renderingGroup being processed
  74426. */
  74427. renderingGroupId: number;
  74428. }
  74429. /**
  74430. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74431. * It is enable to manage the different groups as well as the different necessary sort functions.
  74432. * This should not be used directly aside of the few static configurations
  74433. */
  74434. export class RenderingManager {
  74435. /**
  74436. * The max id used for rendering groups (not included)
  74437. */
  74438. static MAX_RENDERINGGROUPS: number;
  74439. /**
  74440. * The min id used for rendering groups (included)
  74441. */
  74442. static MIN_RENDERINGGROUPS: number;
  74443. /**
  74444. * Used to globally prevent autoclearing scenes.
  74445. */
  74446. static AUTOCLEAR: boolean;
  74447. /**
  74448. * @hidden
  74449. */
  74450. _useSceneAutoClearSetup: boolean;
  74451. private _scene;
  74452. private _renderingGroups;
  74453. private _depthStencilBufferAlreadyCleaned;
  74454. private _autoClearDepthStencil;
  74455. private _customOpaqueSortCompareFn;
  74456. private _customAlphaTestSortCompareFn;
  74457. private _customTransparentSortCompareFn;
  74458. private _renderingGroupInfo;
  74459. /**
  74460. * Instantiates a new rendering group for a particular scene
  74461. * @param scene Defines the scene the groups belongs to
  74462. */
  74463. constructor(scene: Scene);
  74464. private _clearDepthStencilBuffer;
  74465. /**
  74466. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74467. * @hidden
  74468. */
  74469. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74470. /**
  74471. * Resets the different information of the group to prepare a new frame
  74472. * @hidden
  74473. */
  74474. reset(): void;
  74475. /**
  74476. * Dispose and release the group and its associated resources.
  74477. * @hidden
  74478. */
  74479. dispose(): void;
  74480. /**
  74481. * Clear the info related to rendering groups preventing retention points during dispose.
  74482. */
  74483. freeRenderingGroups(): void;
  74484. private _prepareRenderingGroup;
  74485. /**
  74486. * Add a sprite manager to the rendering manager in order to render it this frame.
  74487. * @param spriteManager Define the sprite manager to render
  74488. */
  74489. dispatchSprites(spriteManager: ISpriteManager): void;
  74490. /**
  74491. * Add a particle system to the rendering manager in order to render it this frame.
  74492. * @param particleSystem Define the particle system to render
  74493. */
  74494. dispatchParticles(particleSystem: IParticleSystem): void;
  74495. /**
  74496. * Add a submesh to the manager in order to render it this frame
  74497. * @param subMesh The submesh to dispatch
  74498. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74499. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74500. */
  74501. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74502. /**
  74503. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74504. * This allowed control for front to back rendering or reversly depending of the special needs.
  74505. *
  74506. * @param renderingGroupId The rendering group id corresponding to its index
  74507. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74508. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74509. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74510. */
  74511. 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;
  74512. /**
  74513. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74514. *
  74515. * @param renderingGroupId The rendering group id corresponding to its index
  74516. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74517. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74518. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74519. */
  74520. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74521. /**
  74522. * Gets the current auto clear configuration for one rendering group of the rendering
  74523. * manager.
  74524. * @param index the rendering group index to get the information for
  74525. * @returns The auto clear setup for the requested rendering group
  74526. */
  74527. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74528. }
  74529. }
  74530. declare module BABYLON {
  74531. /**
  74532. * This Helps creating a texture that will be created from a camera in your scene.
  74533. * It is basically a dynamic texture that could be used to create special effects for instance.
  74534. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74535. */
  74536. export class RenderTargetTexture extends Texture {
  74537. isCube: boolean;
  74538. /**
  74539. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74540. */
  74541. static readonly REFRESHRATE_RENDER_ONCE: number;
  74542. /**
  74543. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74544. */
  74545. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74546. /**
  74547. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74548. * the central point of your effect and can save a lot of performances.
  74549. */
  74550. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74551. /**
  74552. * Use this predicate to dynamically define the list of mesh you want to render.
  74553. * If set, the renderList property will be overwritten.
  74554. */
  74555. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74556. private _renderList;
  74557. /**
  74558. * Use this list to define the list of mesh you want to render.
  74559. */
  74560. renderList: Nullable<Array<AbstractMesh>>;
  74561. private _hookArray;
  74562. /**
  74563. * Define if particles should be rendered in your texture.
  74564. */
  74565. renderParticles: boolean;
  74566. /**
  74567. * Define if sprites should be rendered in your texture.
  74568. */
  74569. renderSprites: boolean;
  74570. /**
  74571. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74572. */
  74573. coordinatesMode: number;
  74574. /**
  74575. * Define the camera used to render the texture.
  74576. */
  74577. activeCamera: Nullable<Camera>;
  74578. /**
  74579. * Override the render function of the texture with your own one.
  74580. */
  74581. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74582. /**
  74583. * Define if camera post processes should be use while rendering the texture.
  74584. */
  74585. useCameraPostProcesses: boolean;
  74586. /**
  74587. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74588. */
  74589. ignoreCameraViewport: boolean;
  74590. private _postProcessManager;
  74591. private _postProcesses;
  74592. private _resizeObserver;
  74593. /**
  74594. * An event triggered when the texture is unbind.
  74595. */
  74596. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74597. /**
  74598. * An event triggered when the texture is unbind.
  74599. */
  74600. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74601. private _onAfterUnbindObserver;
  74602. /**
  74603. * Set a after unbind callback in the texture.
  74604. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74605. */
  74606. onAfterUnbind: () => void;
  74607. /**
  74608. * An event triggered before rendering the texture
  74609. */
  74610. onBeforeRenderObservable: Observable<number>;
  74611. private _onBeforeRenderObserver;
  74612. /**
  74613. * Set a before render callback in the texture.
  74614. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74615. */
  74616. onBeforeRender: (faceIndex: number) => void;
  74617. /**
  74618. * An event triggered after rendering the texture
  74619. */
  74620. onAfterRenderObservable: Observable<number>;
  74621. private _onAfterRenderObserver;
  74622. /**
  74623. * Set a after render callback in the texture.
  74624. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74625. */
  74626. onAfterRender: (faceIndex: number) => void;
  74627. /**
  74628. * An event triggered after the texture clear
  74629. */
  74630. onClearObservable: Observable<Engine>;
  74631. private _onClearObserver;
  74632. /**
  74633. * Set a clear callback in the texture.
  74634. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74635. */
  74636. onClear: (Engine: Engine) => void;
  74637. /**
  74638. * Define the clear color of the Render Target if it should be different from the scene.
  74639. */
  74640. clearColor: Color4;
  74641. protected _size: number | {
  74642. width: number;
  74643. height: number;
  74644. };
  74645. protected _initialSizeParameter: number | {
  74646. width: number;
  74647. height: number;
  74648. } | {
  74649. ratio: number;
  74650. };
  74651. protected _sizeRatio: Nullable<number>;
  74652. /** @hidden */
  74653. _generateMipMaps: boolean;
  74654. protected _renderingManager: RenderingManager;
  74655. /** @hidden */
  74656. _waitingRenderList: string[];
  74657. protected _doNotChangeAspectRatio: boolean;
  74658. protected _currentRefreshId: number;
  74659. protected _refreshRate: number;
  74660. protected _textureMatrix: Matrix;
  74661. protected _samples: number;
  74662. protected _renderTargetOptions: RenderTargetCreationOptions;
  74663. /**
  74664. * Gets render target creation options that were used.
  74665. */
  74666. readonly renderTargetOptions: RenderTargetCreationOptions;
  74667. protected _engine: Engine;
  74668. protected _onRatioRescale(): void;
  74669. /**
  74670. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74671. * It must define where the camera used to render the texture is set
  74672. */
  74673. boundingBoxPosition: Vector3;
  74674. private _boundingBoxSize;
  74675. /**
  74676. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74677. * When defined, the cubemap will switch to local mode
  74678. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74679. * @example https://www.babylonjs-playground.com/#RNASML
  74680. */
  74681. boundingBoxSize: Vector3;
  74682. /**
  74683. * In case the RTT has been created with a depth texture, get the associated
  74684. * depth texture.
  74685. * Otherwise, return null.
  74686. */
  74687. depthStencilTexture: Nullable<InternalTexture>;
  74688. /**
  74689. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74690. * or used a shadow, depth texture...
  74691. * @param name The friendly name of the texture
  74692. * @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)
  74693. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74694. * @param generateMipMaps True if mip maps need to be generated after render.
  74695. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74696. * @param type The type of the buffer in the RTT (int, half float, float...)
  74697. * @param isCube True if a cube texture needs to be created
  74698. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74699. * @param generateDepthBuffer True to generate a depth buffer
  74700. * @param generateStencilBuffer True to generate a stencil buffer
  74701. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74702. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74703. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74704. */
  74705. constructor(name: string, size: number | {
  74706. width: number;
  74707. height: number;
  74708. } | {
  74709. ratio: number;
  74710. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74711. /**
  74712. * Creates a depth stencil texture.
  74713. * This is only available in WebGL 2 or with the depth texture extension available.
  74714. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74715. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74716. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  74717. */
  74718. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  74719. private _processSizeParameter;
  74720. /**
  74721. * Define the number of samples to use in case of MSAA.
  74722. * It defaults to one meaning no MSAA has been enabled.
  74723. */
  74724. samples: number;
  74725. /**
  74726. * Resets the refresh counter of the texture and start bak from scratch.
  74727. * Could be useful to regenerate the texture if it is setup to render only once.
  74728. */
  74729. resetRefreshCounter(): void;
  74730. /**
  74731. * Define the refresh rate of the texture or the rendering frequency.
  74732. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74733. */
  74734. refreshRate: number;
  74735. /**
  74736. * Adds a post process to the render target rendering passes.
  74737. * @param postProcess define the post process to add
  74738. */
  74739. addPostProcess(postProcess: PostProcess): void;
  74740. /**
  74741. * Clear all the post processes attached to the render target
  74742. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  74743. */
  74744. clearPostProcesses(dispose?: boolean): void;
  74745. /**
  74746. * Remove one of the post process from the list of attached post processes to the texture
  74747. * @param postProcess define the post process to remove from the list
  74748. */
  74749. removePostProcess(postProcess: PostProcess): void;
  74750. /** @hidden */
  74751. _shouldRender(): boolean;
  74752. /**
  74753. * Gets the actual render size of the texture.
  74754. * @returns the width of the render size
  74755. */
  74756. getRenderSize(): number;
  74757. /**
  74758. * Gets the actual render width of the texture.
  74759. * @returns the width of the render size
  74760. */
  74761. getRenderWidth(): number;
  74762. /**
  74763. * Gets the actual render height of the texture.
  74764. * @returns the height of the render size
  74765. */
  74766. getRenderHeight(): number;
  74767. /**
  74768. * Get if the texture can be rescaled or not.
  74769. */
  74770. readonly canRescale: boolean;
  74771. /**
  74772. * Resize the texture using a ratio.
  74773. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  74774. */
  74775. scale(ratio: number): void;
  74776. /**
  74777. * Get the texture reflection matrix used to rotate/transform the reflection.
  74778. * @returns the reflection matrix
  74779. */
  74780. getReflectionTextureMatrix(): Matrix;
  74781. /**
  74782. * Resize the texture to a new desired size.
  74783. * Be carrefull as it will recreate all the data in the new texture.
  74784. * @param size Define the new size. It can be:
  74785. * - a number for squared texture,
  74786. * - an object containing { width: number, height: number }
  74787. * - or an object containing a ratio { ratio: number }
  74788. */
  74789. resize(size: number | {
  74790. width: number;
  74791. height: number;
  74792. } | {
  74793. ratio: number;
  74794. }): void;
  74795. /**
  74796. * Renders all the objects from the render list into the texture.
  74797. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  74798. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  74799. */
  74800. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  74801. private _bestReflectionRenderTargetDimension;
  74802. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  74803. private renderToTarget;
  74804. /**
  74805. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74806. * This allowed control for front to back rendering or reversly depending of the special needs.
  74807. *
  74808. * @param renderingGroupId The rendering group id corresponding to its index
  74809. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74810. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74811. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74812. */
  74813. 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;
  74814. /**
  74815. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74816. *
  74817. * @param renderingGroupId The rendering group id corresponding to its index
  74818. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74819. */
  74820. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  74821. /**
  74822. * Clones the texture.
  74823. * @returns the cloned texture
  74824. */
  74825. clone(): RenderTargetTexture;
  74826. /**
  74827. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74828. * @returns The JSON representation of the texture
  74829. */
  74830. serialize(): any;
  74831. /**
  74832. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  74833. */
  74834. disposeFramebufferObjects(): void;
  74835. /**
  74836. * Dispose the texture and release its associated resources.
  74837. */
  74838. dispose(): void;
  74839. /** @hidden */
  74840. _rebuild(): void;
  74841. /**
  74842. * Clear the info related to rendering groups preventing retention point in material dispose.
  74843. */
  74844. freeRenderingGroups(): void;
  74845. }
  74846. }
  74847. declare module BABYLON {
  74848. /**
  74849. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74850. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74851. * You can then easily use it as a reflectionTexture on a flat surface.
  74852. * In case the surface is not a plane, please consider relying on reflection probes.
  74853. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74854. */
  74855. export class MirrorTexture extends RenderTargetTexture {
  74856. private scene;
  74857. /**
  74858. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  74859. * 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.
  74860. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74861. */
  74862. mirrorPlane: Plane;
  74863. /**
  74864. * Define the blur ratio used to blur the reflection if needed.
  74865. */
  74866. blurRatio: number;
  74867. /**
  74868. * Define the adaptive blur kernel used to blur the reflection if needed.
  74869. * This will autocompute the closest best match for the `blurKernel`
  74870. */
  74871. adaptiveBlurKernel: number;
  74872. /**
  74873. * Define the blur kernel used to blur the reflection if needed.
  74874. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74875. */
  74876. blurKernel: number;
  74877. /**
  74878. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  74879. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74880. */
  74881. blurKernelX: number;
  74882. /**
  74883. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  74884. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74885. */
  74886. blurKernelY: number;
  74887. private _autoComputeBlurKernel;
  74888. protected _onRatioRescale(): void;
  74889. private _updateGammaSpace;
  74890. private _imageProcessingConfigChangeObserver;
  74891. private _transformMatrix;
  74892. private _mirrorMatrix;
  74893. private _savedViewMatrix;
  74894. private _blurX;
  74895. private _blurY;
  74896. private _adaptiveBlurKernel;
  74897. private _blurKernelX;
  74898. private _blurKernelY;
  74899. private _blurRatio;
  74900. /**
  74901. * Instantiates a Mirror Texture.
  74902. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74903. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74904. * You can then easily use it as a reflectionTexture on a flat surface.
  74905. * In case the surface is not a plane, please consider relying on reflection probes.
  74906. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74907. * @param name
  74908. * @param size
  74909. * @param scene
  74910. * @param generateMipMaps
  74911. * @param type
  74912. * @param samplingMode
  74913. * @param generateDepthBuffer
  74914. */
  74915. constructor(name: string, size: number | {
  74916. width: number;
  74917. height: number;
  74918. } | {
  74919. ratio: number;
  74920. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  74921. private _preparePostProcesses;
  74922. /**
  74923. * Clone the mirror texture.
  74924. * @returns the cloned texture
  74925. */
  74926. clone(): MirrorTexture;
  74927. /**
  74928. * Serialize the texture to a JSON representation you could use in Parse later on
  74929. * @returns the serialized JSON representation
  74930. */
  74931. serialize(): any;
  74932. /**
  74933. * Dispose the texture and release its associated resources.
  74934. */
  74935. dispose(): void;
  74936. }
  74937. }
  74938. declare module BABYLON {
  74939. /**
  74940. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74941. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74942. */
  74943. export class Texture extends BaseTexture {
  74944. /** @hidden */
  74945. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  74946. /** @hidden */
  74947. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  74948. /** @hidden */
  74949. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  74950. /** nearest is mag = nearest and min = nearest and mip = linear */
  74951. static readonly NEAREST_SAMPLINGMODE: number;
  74952. /** nearest is mag = nearest and min = nearest and mip = linear */
  74953. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  74954. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74955. static readonly BILINEAR_SAMPLINGMODE: number;
  74956. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74957. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  74958. /** Trilinear is mag = linear and min = linear and mip = linear */
  74959. static readonly TRILINEAR_SAMPLINGMODE: number;
  74960. /** Trilinear is mag = linear and min = linear and mip = linear */
  74961. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  74962. /** mag = nearest and min = nearest and mip = nearest */
  74963. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  74964. /** mag = nearest and min = linear and mip = nearest */
  74965. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  74966. /** mag = nearest and min = linear and mip = linear */
  74967. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  74968. /** mag = nearest and min = linear and mip = none */
  74969. static readonly NEAREST_LINEAR: number;
  74970. /** mag = nearest and min = nearest and mip = none */
  74971. static readonly NEAREST_NEAREST: number;
  74972. /** mag = linear and min = nearest and mip = nearest */
  74973. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  74974. /** mag = linear and min = nearest and mip = linear */
  74975. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  74976. /** mag = linear and min = linear and mip = none */
  74977. static readonly LINEAR_LINEAR: number;
  74978. /** mag = linear and min = nearest and mip = none */
  74979. static readonly LINEAR_NEAREST: number;
  74980. /** Explicit coordinates mode */
  74981. static readonly EXPLICIT_MODE: number;
  74982. /** Spherical coordinates mode */
  74983. static readonly SPHERICAL_MODE: number;
  74984. /** Planar coordinates mode */
  74985. static readonly PLANAR_MODE: number;
  74986. /** Cubic coordinates mode */
  74987. static readonly CUBIC_MODE: number;
  74988. /** Projection coordinates mode */
  74989. static readonly PROJECTION_MODE: number;
  74990. /** Inverse Cubic coordinates mode */
  74991. static readonly SKYBOX_MODE: number;
  74992. /** Inverse Cubic coordinates mode */
  74993. static readonly INVCUBIC_MODE: number;
  74994. /** Equirectangular coordinates mode */
  74995. static readonly EQUIRECTANGULAR_MODE: number;
  74996. /** Equirectangular Fixed coordinates mode */
  74997. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  74998. /** Equirectangular Fixed Mirrored coordinates mode */
  74999. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75000. /** Texture is not repeating outside of 0..1 UVs */
  75001. static readonly CLAMP_ADDRESSMODE: number;
  75002. /** Texture is repeating outside of 0..1 UVs */
  75003. static readonly WRAP_ADDRESSMODE: number;
  75004. /** Texture is repeating and mirrored */
  75005. static readonly MIRROR_ADDRESSMODE: number;
  75006. /**
  75007. * 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
  75008. */
  75009. static UseSerializedUrlIfAny: boolean;
  75010. /**
  75011. * Define the url of the texture.
  75012. */
  75013. url: Nullable<string>;
  75014. /**
  75015. * Define an offset on the texture to offset the u coordinates of the UVs
  75016. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75017. */
  75018. uOffset: number;
  75019. /**
  75020. * Define an offset on the texture to offset the v coordinates of the UVs
  75021. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75022. */
  75023. vOffset: number;
  75024. /**
  75025. * Define an offset on the texture to scale the u coordinates of the UVs
  75026. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75027. */
  75028. uScale: number;
  75029. /**
  75030. * Define an offset on the texture to scale the v coordinates of the UVs
  75031. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75032. */
  75033. vScale: number;
  75034. /**
  75035. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75036. * @see http://doc.babylonjs.com/how_to/more_materials
  75037. */
  75038. uAng: number;
  75039. /**
  75040. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75041. * @see http://doc.babylonjs.com/how_to/more_materials
  75042. */
  75043. vAng: number;
  75044. /**
  75045. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75046. * @see http://doc.babylonjs.com/how_to/more_materials
  75047. */
  75048. wAng: number;
  75049. /**
  75050. * Defines the center of rotation (U)
  75051. */
  75052. uRotationCenter: number;
  75053. /**
  75054. * Defines the center of rotation (V)
  75055. */
  75056. vRotationCenter: number;
  75057. /**
  75058. * Defines the center of rotation (W)
  75059. */
  75060. wRotationCenter: number;
  75061. /**
  75062. * Are mip maps generated for this texture or not.
  75063. */
  75064. readonly noMipmap: boolean;
  75065. private _noMipmap;
  75066. /** @hidden */
  75067. _invertY: boolean;
  75068. private _rowGenerationMatrix;
  75069. private _cachedTextureMatrix;
  75070. private _projectionModeMatrix;
  75071. private _t0;
  75072. private _t1;
  75073. private _t2;
  75074. private _cachedUOffset;
  75075. private _cachedVOffset;
  75076. private _cachedUScale;
  75077. private _cachedVScale;
  75078. private _cachedUAng;
  75079. private _cachedVAng;
  75080. private _cachedWAng;
  75081. private _cachedProjectionMatrixId;
  75082. private _cachedCoordinatesMode;
  75083. /** @hidden */
  75084. protected _initialSamplingMode: number;
  75085. /** @hidden */
  75086. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75087. private _deleteBuffer;
  75088. protected _format: Nullable<number>;
  75089. private _delayedOnLoad;
  75090. private _delayedOnError;
  75091. /**
  75092. * Observable triggered once the texture has been loaded.
  75093. */
  75094. onLoadObservable: Observable<Texture>;
  75095. protected _isBlocking: boolean;
  75096. /**
  75097. * Is the texture preventing material to render while loading.
  75098. * If false, a default texture will be used instead of the loading one during the preparation step.
  75099. */
  75100. isBlocking: boolean;
  75101. /**
  75102. * Get the current sampling mode associated with the texture.
  75103. */
  75104. readonly samplingMode: number;
  75105. /**
  75106. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75107. */
  75108. readonly invertY: boolean;
  75109. /**
  75110. * Instantiates a new texture.
  75111. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75112. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75113. * @param url define the url of the picture to load as a texture
  75114. * @param scene define the scene the texture will belong to
  75115. * @param noMipmap define if the texture will require mip maps or not
  75116. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75117. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75118. * @param onLoad define a callback triggered when the texture has been loaded
  75119. * @param onError define a callback triggered when an error occurred during the loading session
  75120. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75121. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75122. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75123. */
  75124. 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);
  75125. /**
  75126. * Update the url (and optional buffer) of this texture if url was null during construction.
  75127. * @param url the url of the texture
  75128. * @param buffer the buffer of the texture (defaults to null)
  75129. * @param onLoad callback called when the texture is loaded (defaults to null)
  75130. */
  75131. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75132. /**
  75133. * Finish the loading sequence of a texture flagged as delayed load.
  75134. * @hidden
  75135. */
  75136. delayLoad(): void;
  75137. private _prepareRowForTextureGeneration;
  75138. /**
  75139. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75140. * @returns the transform matrix of the texture.
  75141. */
  75142. getTextureMatrix(): Matrix;
  75143. /**
  75144. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75145. * @returns The reflection texture transform
  75146. */
  75147. getReflectionTextureMatrix(): Matrix;
  75148. /**
  75149. * Clones the texture.
  75150. * @returns the cloned texture
  75151. */
  75152. clone(): Texture;
  75153. /**
  75154. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75155. * @returns The JSON representation of the texture
  75156. */
  75157. serialize(): any;
  75158. /**
  75159. * Get the current class name of the texture useful for serialization or dynamic coding.
  75160. * @returns "Texture"
  75161. */
  75162. getClassName(): string;
  75163. /**
  75164. * Dispose the texture and release its associated resources.
  75165. */
  75166. dispose(): void;
  75167. /**
  75168. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75169. * @param parsedTexture Define the JSON representation of the texture
  75170. * @param scene Define the scene the parsed texture should be instantiated in
  75171. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75172. * @returns The parsed texture if successful
  75173. */
  75174. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75175. /**
  75176. * Creates a texture from its base 64 representation.
  75177. * @param data Define the base64 payload without the data: prefix
  75178. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75179. * @param scene Define the scene the texture should belong to
  75180. * @param noMipmap Forces the texture to not create mip map information if true
  75181. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75182. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75183. * @param onLoad define a callback triggered when the texture has been loaded
  75184. * @param onError define a callback triggered when an error occurred during the loading session
  75185. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75186. * @returns the created texture
  75187. */
  75188. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75189. /**
  75190. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75191. * @param data Define the base64 payload without the data: prefix
  75192. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75193. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75194. * @param scene Define the scene the texture should belong to
  75195. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75196. * @param noMipmap Forces the texture to not create mip map information if true
  75197. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75198. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75199. * @param onLoad define a callback triggered when the texture has been loaded
  75200. * @param onError define a callback triggered when an error occurred during the loading session
  75201. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75202. * @returns the created texture
  75203. */
  75204. 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;
  75205. }
  75206. }
  75207. declare module BABYLON {
  75208. /**
  75209. * Raw texture can help creating a texture directly from an array of data.
  75210. * This can be super useful if you either get the data from an uncompressed source or
  75211. * if you wish to create your texture pixel by pixel.
  75212. */
  75213. export class RawTexture extends Texture {
  75214. /**
  75215. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75216. */
  75217. format: number;
  75218. private _engine;
  75219. /**
  75220. * Instantiates a new RawTexture.
  75221. * Raw texture can help creating a texture directly from an array of data.
  75222. * This can be super useful if you either get the data from an uncompressed source or
  75223. * if you wish to create your texture pixel by pixel.
  75224. * @param data define the array of data to use to create the texture
  75225. * @param width define the width of the texture
  75226. * @param height define the height of the texture
  75227. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75228. * @param scene define the scene the texture belongs to
  75229. * @param generateMipMaps define whether mip maps should be generated or not
  75230. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75231. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75232. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75233. */
  75234. constructor(data: ArrayBufferView, width: number, height: number,
  75235. /**
  75236. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75237. */
  75238. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75239. /**
  75240. * Updates the texture underlying data.
  75241. * @param data Define the new data of the texture
  75242. */
  75243. update(data: ArrayBufferView): void;
  75244. /**
  75245. * Creates a luminance texture from some data.
  75246. * @param data Define the texture data
  75247. * @param width Define the width of the texture
  75248. * @param height Define the height of the texture
  75249. * @param scene Define the scene the texture belongs to
  75250. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75251. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75252. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75253. * @returns the luminance texture
  75254. */
  75255. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75256. /**
  75257. * Creates a luminance alpha texture from some data.
  75258. * @param data Define the texture data
  75259. * @param width Define the width of the texture
  75260. * @param height Define the height of the texture
  75261. * @param scene Define the scene the texture belongs to
  75262. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75263. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75264. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75265. * @returns the luminance alpha texture
  75266. */
  75267. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75268. /**
  75269. * Creates an alpha texture from some data.
  75270. * @param data Define the texture data
  75271. * @param width Define the width of the texture
  75272. * @param height Define the height of the texture
  75273. * @param scene Define the scene the texture belongs to
  75274. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75275. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75276. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75277. * @returns the alpha texture
  75278. */
  75279. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75280. /**
  75281. * Creates a RGB texture from some data.
  75282. * @param data Define the texture data
  75283. * @param width Define the width of the texture
  75284. * @param height Define the height of the texture
  75285. * @param scene Define the scene the texture belongs to
  75286. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75287. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75288. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75289. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75290. * @returns the RGB alpha texture
  75291. */
  75292. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75293. /**
  75294. * Creates a RGBA texture from some data.
  75295. * @param data Define the texture data
  75296. * @param width Define the width of the texture
  75297. * @param height Define the height of the texture
  75298. * @param scene Define the scene the texture belongs to
  75299. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75300. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75301. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75302. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75303. * @returns the RGBA texture
  75304. */
  75305. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75306. /**
  75307. * Creates a R texture from some data.
  75308. * @param data Define the texture data
  75309. * @param width Define the width of the texture
  75310. * @param height Define the height of the texture
  75311. * @param scene Define the scene the texture belongs to
  75312. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75313. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75314. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75315. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75316. * @returns the R texture
  75317. */
  75318. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75319. }
  75320. }
  75321. declare module BABYLON {
  75322. /**
  75323. * Defines a runtime animation
  75324. */
  75325. export class RuntimeAnimation {
  75326. private _events;
  75327. /**
  75328. * The current frame of the runtime animation
  75329. */
  75330. private _currentFrame;
  75331. /**
  75332. * The animation used by the runtime animation
  75333. */
  75334. private _animation;
  75335. /**
  75336. * The target of the runtime animation
  75337. */
  75338. private _target;
  75339. /**
  75340. * The initiating animatable
  75341. */
  75342. private _host;
  75343. /**
  75344. * The original value of the runtime animation
  75345. */
  75346. private _originalValue;
  75347. /**
  75348. * The original blend value of the runtime animation
  75349. */
  75350. private _originalBlendValue;
  75351. /**
  75352. * The offsets cache of the runtime animation
  75353. */
  75354. private _offsetsCache;
  75355. /**
  75356. * The high limits cache of the runtime animation
  75357. */
  75358. private _highLimitsCache;
  75359. /**
  75360. * Specifies if the runtime animation has been stopped
  75361. */
  75362. private _stopped;
  75363. /**
  75364. * The blending factor of the runtime animation
  75365. */
  75366. private _blendingFactor;
  75367. /**
  75368. * The BabylonJS scene
  75369. */
  75370. private _scene;
  75371. /**
  75372. * The current value of the runtime animation
  75373. */
  75374. private _currentValue;
  75375. /** @hidden */
  75376. _workValue: any;
  75377. /**
  75378. * The active target of the runtime animation
  75379. */
  75380. private _activeTarget;
  75381. /**
  75382. * The target path of the runtime animation
  75383. */
  75384. private _targetPath;
  75385. /**
  75386. * The weight of the runtime animation
  75387. */
  75388. private _weight;
  75389. /**
  75390. * The ratio offset of the runtime animation
  75391. */
  75392. private _ratioOffset;
  75393. /**
  75394. * The previous delay of the runtime animation
  75395. */
  75396. private _previousDelay;
  75397. /**
  75398. * The previous ratio of the runtime animation
  75399. */
  75400. private _previousRatio;
  75401. /**
  75402. * Gets the current frame of the runtime animation
  75403. */
  75404. readonly currentFrame: number;
  75405. /**
  75406. * Gets the weight of the runtime animation
  75407. */
  75408. readonly weight: number;
  75409. /**
  75410. * Gets the current value of the runtime animation
  75411. */
  75412. readonly currentValue: any;
  75413. /**
  75414. * Gets the target path of the runtime animation
  75415. */
  75416. readonly targetPath: string;
  75417. /**
  75418. * Gets the actual target of the runtime animation
  75419. */
  75420. readonly target: any;
  75421. /**
  75422. * Create a new RuntimeAnimation object
  75423. * @param target defines the target of the animation
  75424. * @param animation defines the source animation object
  75425. * @param scene defines the hosting scene
  75426. * @param host defines the initiating Animatable
  75427. */
  75428. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75429. /**
  75430. * Gets the animation from the runtime animation
  75431. */
  75432. readonly animation: Animation;
  75433. /**
  75434. * Resets the runtime animation to the beginning
  75435. * @param restoreOriginal defines whether to restore the target property to the original value
  75436. */
  75437. reset(restoreOriginal?: boolean): void;
  75438. /**
  75439. * Specifies if the runtime animation is stopped
  75440. * @returns Boolean specifying if the runtime animation is stopped
  75441. */
  75442. isStopped(): boolean;
  75443. /**
  75444. * Disposes of the runtime animation
  75445. */
  75446. dispose(): void;
  75447. /**
  75448. * Interpolates the animation from the current frame
  75449. * @param currentFrame The frame to interpolate the animation to
  75450. * @param repeatCount The number of times that the animation should loop
  75451. * @param loopMode The type of looping mode to use
  75452. * @param offsetValue Animation offset value
  75453. * @param highLimitValue The high limit value
  75454. * @returns The interpolated value
  75455. */
  75456. private _interpolate;
  75457. /**
  75458. * Apply the interpolated value to the target
  75459. * @param currentValue defines the value computed by the animation
  75460. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75461. */
  75462. setValue(currentValue: any, weight?: number): void;
  75463. private _setValue;
  75464. /**
  75465. * Gets the loop pmode of the runtime animation
  75466. * @returns Loop Mode
  75467. */
  75468. private _getCorrectLoopMode;
  75469. /**
  75470. * Move the current animation to a given frame
  75471. * @param frame defines the frame to move to
  75472. */
  75473. goToFrame(frame: number): void;
  75474. /**
  75475. * @hidden Internal use only
  75476. */
  75477. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75478. /**
  75479. * Execute the current animation
  75480. * @param delay defines the delay to add to the current frame
  75481. * @param from defines the lower bound of the animation range
  75482. * @param to defines the upper bound of the animation range
  75483. * @param loop defines if the current animation must loop
  75484. * @param speedRatio defines the current speed ratio
  75485. * @param weight defines the weight of the animation (default is -1 so no weight)
  75486. * @param onLoop optional callback called when animation loops
  75487. * @returns a boolean indicating if the animation is running
  75488. */
  75489. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75490. }
  75491. }
  75492. declare module BABYLON {
  75493. /**
  75494. * Class used to store an actual running animation
  75495. */
  75496. export class Animatable {
  75497. /** defines the target object */
  75498. target: any;
  75499. /** defines the starting frame number (default is 0) */
  75500. fromFrame: number;
  75501. /** defines the ending frame number (default is 100) */
  75502. toFrame: number;
  75503. /** defines if the animation must loop (default is false) */
  75504. loopAnimation: boolean;
  75505. /** defines a callback to call when animation ends if it is not looping */
  75506. onAnimationEnd?: (() => void) | null | undefined;
  75507. /** defines a callback to call when animation loops */
  75508. onAnimationLoop?: (() => void) | null | undefined;
  75509. private _localDelayOffset;
  75510. private _pausedDelay;
  75511. private _runtimeAnimations;
  75512. private _paused;
  75513. private _scene;
  75514. private _speedRatio;
  75515. private _weight;
  75516. private _syncRoot;
  75517. /**
  75518. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75519. * This will only apply for non looping animation (default is true)
  75520. */
  75521. disposeOnEnd: boolean;
  75522. /**
  75523. * Gets a boolean indicating if the animation has started
  75524. */
  75525. animationStarted: boolean;
  75526. /**
  75527. * Observer raised when the animation ends
  75528. */
  75529. onAnimationEndObservable: Observable<Animatable>;
  75530. /**
  75531. * Observer raised when the animation loops
  75532. */
  75533. onAnimationLoopObservable: Observable<Animatable>;
  75534. /**
  75535. * Gets the root Animatable used to synchronize and normalize animations
  75536. */
  75537. readonly syncRoot: Animatable;
  75538. /**
  75539. * Gets the current frame of the first RuntimeAnimation
  75540. * Used to synchronize Animatables
  75541. */
  75542. readonly masterFrame: number;
  75543. /**
  75544. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75545. */
  75546. weight: number;
  75547. /**
  75548. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75549. */
  75550. speedRatio: number;
  75551. /**
  75552. * Creates a new Animatable
  75553. * @param scene defines the hosting scene
  75554. * @param target defines the target object
  75555. * @param fromFrame defines the starting frame number (default is 0)
  75556. * @param toFrame defines the ending frame number (default is 100)
  75557. * @param loopAnimation defines if the animation must loop (default is false)
  75558. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75559. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75560. * @param animations defines a group of animation to add to the new Animatable
  75561. * @param onAnimationLoop defines a callback to call when animation loops
  75562. */
  75563. constructor(scene: Scene,
  75564. /** defines the target object */
  75565. target: any,
  75566. /** defines the starting frame number (default is 0) */
  75567. fromFrame?: number,
  75568. /** defines the ending frame number (default is 100) */
  75569. toFrame?: number,
  75570. /** defines if the animation must loop (default is false) */
  75571. loopAnimation?: boolean, speedRatio?: number,
  75572. /** defines a callback to call when animation ends if it is not looping */
  75573. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75574. /** defines a callback to call when animation loops */
  75575. onAnimationLoop?: (() => void) | null | undefined);
  75576. /**
  75577. * Synchronize and normalize current Animatable with a source Animatable
  75578. * This is useful when using animation weights and when animations are not of the same length
  75579. * @param root defines the root Animatable to synchronize with
  75580. * @returns the current Animatable
  75581. */
  75582. syncWith(root: Animatable): Animatable;
  75583. /**
  75584. * Gets the list of runtime animations
  75585. * @returns an array of RuntimeAnimation
  75586. */
  75587. getAnimations(): RuntimeAnimation[];
  75588. /**
  75589. * Adds more animations to the current animatable
  75590. * @param target defines the target of the animations
  75591. * @param animations defines the new animations to add
  75592. */
  75593. appendAnimations(target: any, animations: Animation[]): void;
  75594. /**
  75595. * Gets the source animation for a specific property
  75596. * @param property defines the propertyu to look for
  75597. * @returns null or the source animation for the given property
  75598. */
  75599. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75600. /**
  75601. * Gets the runtime animation for a specific property
  75602. * @param property defines the propertyu to look for
  75603. * @returns null or the runtime animation for the given property
  75604. */
  75605. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75606. /**
  75607. * Resets the animatable to its original state
  75608. */
  75609. reset(): void;
  75610. /**
  75611. * Allows the animatable to blend with current running animations
  75612. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75613. * @param blendingSpeed defines the blending speed to use
  75614. */
  75615. enableBlending(blendingSpeed: number): void;
  75616. /**
  75617. * Disable animation blending
  75618. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75619. */
  75620. disableBlending(): void;
  75621. /**
  75622. * Jump directly to a given frame
  75623. * @param frame defines the frame to jump to
  75624. */
  75625. goToFrame(frame: number): void;
  75626. /**
  75627. * Pause the animation
  75628. */
  75629. pause(): void;
  75630. /**
  75631. * Restart the animation
  75632. */
  75633. restart(): void;
  75634. private _raiseOnAnimationEnd;
  75635. /**
  75636. * Stop and delete the current animation
  75637. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75638. * @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)
  75639. */
  75640. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75641. /**
  75642. * Wait asynchronously for the animation to end
  75643. * @returns a promise which will be fullfilled when the animation ends
  75644. */
  75645. waitAsync(): Promise<Animatable>;
  75646. /** @hidden */
  75647. _animate(delay: number): boolean;
  75648. }
  75649. interface Scene {
  75650. /** @hidden */
  75651. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75652. /** @hidden */
  75653. _processLateAnimationBindingsForMatrices(holder: {
  75654. totalWeight: number;
  75655. animations: RuntimeAnimation[];
  75656. originalValue: Matrix;
  75657. }): any;
  75658. /** @hidden */
  75659. _processLateAnimationBindingsForQuaternions(holder: {
  75660. totalWeight: number;
  75661. animations: RuntimeAnimation[];
  75662. originalValue: Quaternion;
  75663. }, refQuaternion: Quaternion): Quaternion;
  75664. /** @hidden */
  75665. _processLateAnimationBindings(): void;
  75666. /**
  75667. * Will start the animation sequence of a given target
  75668. * @param target defines the target
  75669. * @param from defines from which frame should animation start
  75670. * @param to defines until which frame should animation run.
  75671. * @param weight defines the weight to apply to the animation (1.0 by default)
  75672. * @param loop defines if the animation loops
  75673. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75674. * @param onAnimationEnd defines the function to be executed when the animation ends
  75675. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75676. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75677. * @param onAnimationLoop defines the callback to call when an animation loops
  75678. * @returns the animatable object created for this animation
  75679. */
  75680. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75681. /**
  75682. * Will start the animation sequence of a given target
  75683. * @param target defines the target
  75684. * @param from defines from which frame should animation start
  75685. * @param to defines until which frame should animation run.
  75686. * @param loop defines if the animation loops
  75687. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75688. * @param onAnimationEnd defines the function to be executed when the animation ends
  75689. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75690. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75691. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75692. * @param onAnimationLoop defines the callback to call when an animation loops
  75693. * @returns the animatable object created for this animation
  75694. */
  75695. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75696. /**
  75697. * Will start the animation sequence of a given target and its hierarchy
  75698. * @param target defines the target
  75699. * @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.
  75700. * @param from defines from which frame should animation start
  75701. * @param to defines until which frame should animation run.
  75702. * @param loop defines if the animation loops
  75703. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75704. * @param onAnimationEnd defines the function to be executed when the animation ends
  75705. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75706. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75707. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75708. * @param onAnimationLoop defines the callback to call when an animation loops
  75709. * @returns the list of created animatables
  75710. */
  75711. 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[];
  75712. /**
  75713. * Begin a new animation on a given node
  75714. * @param target defines the target where the animation will take place
  75715. * @param animations defines the list of animations to start
  75716. * @param from defines the initial value
  75717. * @param to defines the final value
  75718. * @param loop defines if you want animation to loop (off by default)
  75719. * @param speedRatio defines the speed ratio to apply to all animations
  75720. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75721. * @param onAnimationLoop defines the callback to call when an animation loops
  75722. * @returns the list of created animatables
  75723. */
  75724. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  75725. /**
  75726. * Begin a new animation on a given node and its hierarchy
  75727. * @param target defines the root node where the animation will take place
  75728. * @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.
  75729. * @param animations defines the list of animations to start
  75730. * @param from defines the initial value
  75731. * @param to defines the final value
  75732. * @param loop defines if you want animation to loop (off by default)
  75733. * @param speedRatio defines the speed ratio to apply to all animations
  75734. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75735. * @param onAnimationLoop defines the callback to call when an animation loops
  75736. * @returns the list of animatables created for all nodes
  75737. */
  75738. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  75739. /**
  75740. * Gets the animatable associated with a specific target
  75741. * @param target defines the target of the animatable
  75742. * @returns the required animatable if found
  75743. */
  75744. getAnimatableByTarget(target: any): Nullable<Animatable>;
  75745. /**
  75746. * Gets all animatables associated with a given target
  75747. * @param target defines the target to look animatables for
  75748. * @returns an array of Animatables
  75749. */
  75750. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  75751. /**
  75752. * Will stop the animation of the given target
  75753. * @param target - the target
  75754. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  75755. * @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)
  75756. */
  75757. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  75758. /**
  75759. * Stops and removes all animations that have been applied to the scene
  75760. */
  75761. stopAllAnimations(): void;
  75762. }
  75763. interface Bone {
  75764. /**
  75765. * Copy an animation range from another bone
  75766. * @param source defines the source bone
  75767. * @param rangeName defines the range name to copy
  75768. * @param frameOffset defines the frame offset
  75769. * @param rescaleAsRequired defines if rescaling must be applied if required
  75770. * @param skelDimensionsRatio defines the scaling ratio
  75771. * @returns true if operation was successful
  75772. */
  75773. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  75774. }
  75775. }
  75776. declare module BABYLON {
  75777. /**
  75778. * Class used to handle skinning animations
  75779. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  75780. */
  75781. export class Skeleton implements IAnimatable {
  75782. /** defines the skeleton name */
  75783. name: string;
  75784. /** defines the skeleton Id */
  75785. id: string;
  75786. /**
  75787. * Defines the list of child bones
  75788. */
  75789. bones: Bone[];
  75790. /**
  75791. * Defines an estimate of the dimension of the skeleton at rest
  75792. */
  75793. dimensionsAtRest: Vector3;
  75794. /**
  75795. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  75796. */
  75797. needInitialSkinMatrix: boolean;
  75798. /**
  75799. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  75800. */
  75801. overrideMesh: Nullable<AbstractMesh>;
  75802. /**
  75803. * Gets the list of animations attached to this skeleton
  75804. */
  75805. animations: Array<Animation>;
  75806. private _scene;
  75807. private _isDirty;
  75808. private _transformMatrices;
  75809. private _transformMatrixTexture;
  75810. private _meshesWithPoseMatrix;
  75811. private _animatables;
  75812. private _identity;
  75813. private _synchronizedWithMesh;
  75814. private _ranges;
  75815. private _lastAbsoluteTransformsUpdateId;
  75816. private _canUseTextureForBones;
  75817. /** @hidden */
  75818. _numBonesWithLinkedTransformNode: number;
  75819. /**
  75820. * Specifies if the skeleton should be serialized
  75821. */
  75822. doNotSerialize: boolean;
  75823. /**
  75824. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  75825. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  75826. */
  75827. useTextureToStoreBoneMatrices: boolean;
  75828. private _animationPropertiesOverride;
  75829. /**
  75830. * Gets or sets the animation properties override
  75831. */
  75832. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75833. /**
  75834. * An observable triggered before computing the skeleton's matrices
  75835. */
  75836. onBeforeComputeObservable: Observable<Skeleton>;
  75837. /**
  75838. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  75839. */
  75840. readonly isUsingTextureForMatrices: boolean;
  75841. /**
  75842. * Creates a new skeleton
  75843. * @param name defines the skeleton name
  75844. * @param id defines the skeleton Id
  75845. * @param scene defines the hosting scene
  75846. */
  75847. constructor(
  75848. /** defines the skeleton name */
  75849. name: string,
  75850. /** defines the skeleton Id */
  75851. id: string, scene: Scene);
  75852. /**
  75853. * Gets the current object class name.
  75854. * @return the class name
  75855. */
  75856. getClassName(): string;
  75857. /**
  75858. * Returns an array containing the root bones
  75859. * @returns an array containing the root bones
  75860. */
  75861. getChildren(): Array<Bone>;
  75862. /**
  75863. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  75864. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  75865. * @returns a Float32Array containing matrices data
  75866. */
  75867. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  75868. /**
  75869. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  75870. * @returns a raw texture containing the data
  75871. */
  75872. getTransformMatrixTexture(): Nullable<RawTexture>;
  75873. /**
  75874. * Gets the current hosting scene
  75875. * @returns a scene object
  75876. */
  75877. getScene(): Scene;
  75878. /**
  75879. * Gets a string representing the current skeleton data
  75880. * @param fullDetails defines a boolean indicating if we want a verbose version
  75881. * @returns a string representing the current skeleton data
  75882. */
  75883. toString(fullDetails?: boolean): string;
  75884. /**
  75885. * Get bone's index searching by name
  75886. * @param name defines bone's name to search for
  75887. * @return the indice of the bone. Returns -1 if not found
  75888. */
  75889. getBoneIndexByName(name: string): number;
  75890. /**
  75891. * Creater a new animation range
  75892. * @param name defines the name of the range
  75893. * @param from defines the start key
  75894. * @param to defines the end key
  75895. */
  75896. createAnimationRange(name: string, from: number, to: number): void;
  75897. /**
  75898. * Delete a specific animation range
  75899. * @param name defines the name of the range
  75900. * @param deleteFrames defines if frames must be removed as well
  75901. */
  75902. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  75903. /**
  75904. * Gets a specific animation range
  75905. * @param name defines the name of the range to look for
  75906. * @returns the requested animation range or null if not found
  75907. */
  75908. getAnimationRange(name: string): Nullable<AnimationRange>;
  75909. /**
  75910. * Gets the list of all animation ranges defined on this skeleton
  75911. * @returns an array
  75912. */
  75913. getAnimationRanges(): Nullable<AnimationRange>[];
  75914. /**
  75915. * Copy animation range from a source skeleton.
  75916. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  75917. * @param source defines the source skeleton
  75918. * @param name defines the name of the range to copy
  75919. * @param rescaleAsRequired defines if rescaling must be applied if required
  75920. * @returns true if operation was successful
  75921. */
  75922. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  75923. /**
  75924. * Forces the skeleton to go to rest pose
  75925. */
  75926. returnToRest(): void;
  75927. private _getHighestAnimationFrame;
  75928. /**
  75929. * Begin a specific animation range
  75930. * @param name defines the name of the range to start
  75931. * @param loop defines if looping must be turned on (false by default)
  75932. * @param speedRatio defines the speed ratio to apply (1 by default)
  75933. * @param onAnimationEnd defines a callback which will be called when animation will end
  75934. * @returns a new animatable
  75935. */
  75936. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  75937. /** @hidden */
  75938. _markAsDirty(): void;
  75939. /** @hidden */
  75940. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75941. /** @hidden */
  75942. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75943. private _computeTransformMatrices;
  75944. /**
  75945. * Build all resources required to render a skeleton
  75946. */
  75947. prepare(): void;
  75948. /**
  75949. * Gets the list of animatables currently running for this skeleton
  75950. * @returns an array of animatables
  75951. */
  75952. getAnimatables(): IAnimatable[];
  75953. /**
  75954. * Clone the current skeleton
  75955. * @param name defines the name of the new skeleton
  75956. * @param id defines the id of the enw skeleton
  75957. * @returns the new skeleton
  75958. */
  75959. clone(name: string, id: string): Skeleton;
  75960. /**
  75961. * Enable animation blending for this skeleton
  75962. * @param blendingSpeed defines the blending speed to apply
  75963. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75964. */
  75965. enableBlending(blendingSpeed?: number): void;
  75966. /**
  75967. * Releases all resources associated with the current skeleton
  75968. */
  75969. dispose(): void;
  75970. /**
  75971. * Serialize the skeleton in a JSON object
  75972. * @returns a JSON object
  75973. */
  75974. serialize(): any;
  75975. /**
  75976. * Creates a new skeleton from serialized data
  75977. * @param parsedSkeleton defines the serialized data
  75978. * @param scene defines the hosting scene
  75979. * @returns a new skeleton
  75980. */
  75981. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  75982. /**
  75983. * Compute all node absolute transforms
  75984. * @param forceUpdate defines if computation must be done even if cache is up to date
  75985. */
  75986. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  75987. /**
  75988. * Gets the root pose matrix
  75989. * @returns a matrix
  75990. */
  75991. getPoseMatrix(): Nullable<Matrix>;
  75992. /**
  75993. * Sorts bones per internal index
  75994. */
  75995. sortBones(): void;
  75996. private _sortBones;
  75997. }
  75998. }
  75999. declare module BABYLON {
  76000. /**
  76001. * Defines a target to use with MorphTargetManager
  76002. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76003. */
  76004. export class MorphTarget implements IAnimatable {
  76005. /** defines the name of the target */
  76006. name: string;
  76007. /**
  76008. * Gets or sets the list of animations
  76009. */
  76010. animations: Animation[];
  76011. private _scene;
  76012. private _positions;
  76013. private _normals;
  76014. private _tangents;
  76015. private _influence;
  76016. /**
  76017. * Observable raised when the influence changes
  76018. */
  76019. onInfluenceChanged: Observable<boolean>;
  76020. /** @hidden */
  76021. _onDataLayoutChanged: Observable<void>;
  76022. /**
  76023. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76024. */
  76025. influence: number;
  76026. /**
  76027. * Gets or sets the id of the morph Target
  76028. */
  76029. id: string;
  76030. private _animationPropertiesOverride;
  76031. /**
  76032. * Gets or sets the animation properties override
  76033. */
  76034. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76035. /**
  76036. * Creates a new MorphTarget
  76037. * @param name defines the name of the target
  76038. * @param influence defines the influence to use
  76039. * @param scene defines the scene the morphtarget belongs to
  76040. */
  76041. constructor(
  76042. /** defines the name of the target */
  76043. name: string, influence?: number, scene?: Nullable<Scene>);
  76044. /**
  76045. * Gets a boolean defining if the target contains position data
  76046. */
  76047. readonly hasPositions: boolean;
  76048. /**
  76049. * Gets a boolean defining if the target contains normal data
  76050. */
  76051. readonly hasNormals: boolean;
  76052. /**
  76053. * Gets a boolean defining if the target contains tangent data
  76054. */
  76055. readonly hasTangents: boolean;
  76056. /**
  76057. * Affects position data to this target
  76058. * @param data defines the position data to use
  76059. */
  76060. setPositions(data: Nullable<FloatArray>): void;
  76061. /**
  76062. * Gets the position data stored in this target
  76063. * @returns a FloatArray containing the position data (or null if not present)
  76064. */
  76065. getPositions(): Nullable<FloatArray>;
  76066. /**
  76067. * Affects normal data to this target
  76068. * @param data defines the normal data to use
  76069. */
  76070. setNormals(data: Nullable<FloatArray>): void;
  76071. /**
  76072. * Gets the normal data stored in this target
  76073. * @returns a FloatArray containing the normal data (or null if not present)
  76074. */
  76075. getNormals(): Nullable<FloatArray>;
  76076. /**
  76077. * Affects tangent data to this target
  76078. * @param data defines the tangent data to use
  76079. */
  76080. setTangents(data: Nullable<FloatArray>): void;
  76081. /**
  76082. * Gets the tangent data stored in this target
  76083. * @returns a FloatArray containing the tangent data (or null if not present)
  76084. */
  76085. getTangents(): Nullable<FloatArray>;
  76086. /**
  76087. * Serializes the current target into a Serialization object
  76088. * @returns the serialized object
  76089. */
  76090. serialize(): any;
  76091. /**
  76092. * Returns the string "MorphTarget"
  76093. * @returns "MorphTarget"
  76094. */
  76095. getClassName(): string;
  76096. /**
  76097. * Creates a new target from serialized data
  76098. * @param serializationObject defines the serialized data to use
  76099. * @returns a new MorphTarget
  76100. */
  76101. static Parse(serializationObject: any): MorphTarget;
  76102. /**
  76103. * Creates a MorphTarget from mesh data
  76104. * @param mesh defines the source mesh
  76105. * @param name defines the name to use for the new target
  76106. * @param influence defines the influence to attach to the target
  76107. * @returns a new MorphTarget
  76108. */
  76109. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76110. }
  76111. }
  76112. declare module BABYLON {
  76113. /**
  76114. * This class is used to deform meshes using morphing between different targets
  76115. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76116. */
  76117. export class MorphTargetManager {
  76118. private _targets;
  76119. private _targetInfluenceChangedObservers;
  76120. private _targetDataLayoutChangedObservers;
  76121. private _activeTargets;
  76122. private _scene;
  76123. private _influences;
  76124. private _supportsNormals;
  76125. private _supportsTangents;
  76126. private _vertexCount;
  76127. private _uniqueId;
  76128. private _tempInfluences;
  76129. /**
  76130. * Creates a new MorphTargetManager
  76131. * @param scene defines the current scene
  76132. */
  76133. constructor(scene?: Nullable<Scene>);
  76134. /**
  76135. * Gets the unique ID of this manager
  76136. */
  76137. readonly uniqueId: number;
  76138. /**
  76139. * Gets the number of vertices handled by this manager
  76140. */
  76141. readonly vertexCount: number;
  76142. /**
  76143. * Gets a boolean indicating if this manager supports morphing of normals
  76144. */
  76145. readonly supportsNormals: boolean;
  76146. /**
  76147. * Gets a boolean indicating if this manager supports morphing of tangents
  76148. */
  76149. readonly supportsTangents: boolean;
  76150. /**
  76151. * Gets the number of targets stored in this manager
  76152. */
  76153. readonly numTargets: number;
  76154. /**
  76155. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76156. */
  76157. readonly numInfluencers: number;
  76158. /**
  76159. * Gets the list of influences (one per target)
  76160. */
  76161. readonly influences: Float32Array;
  76162. /**
  76163. * Gets the active target at specified index. An active target is a target with an influence > 0
  76164. * @param index defines the index to check
  76165. * @returns the requested target
  76166. */
  76167. getActiveTarget(index: number): MorphTarget;
  76168. /**
  76169. * Gets the target at specified index
  76170. * @param index defines the index to check
  76171. * @returns the requested target
  76172. */
  76173. getTarget(index: number): MorphTarget;
  76174. /**
  76175. * Add a new target to this manager
  76176. * @param target defines the target to add
  76177. */
  76178. addTarget(target: MorphTarget): void;
  76179. /**
  76180. * Removes a target from the manager
  76181. * @param target defines the target to remove
  76182. */
  76183. removeTarget(target: MorphTarget): void;
  76184. /**
  76185. * Serializes the current manager into a Serialization object
  76186. * @returns the serialized object
  76187. */
  76188. serialize(): any;
  76189. private _syncActiveTargets;
  76190. /**
  76191. * Syncrhonize the targets with all the meshes using this morph target manager
  76192. */
  76193. synchronize(): void;
  76194. /**
  76195. * Creates a new MorphTargetManager from serialized data
  76196. * @param serializationObject defines the serialized data
  76197. * @param scene defines the hosting scene
  76198. * @returns the new MorphTargetManager
  76199. */
  76200. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76201. }
  76202. }
  76203. declare module BABYLON {
  76204. /**
  76205. * Mesh representing the gorund
  76206. */
  76207. export class GroundMesh extends Mesh {
  76208. /** If octree should be generated */
  76209. generateOctree: boolean;
  76210. private _heightQuads;
  76211. /** @hidden */
  76212. _subdivisionsX: number;
  76213. /** @hidden */
  76214. _subdivisionsY: number;
  76215. /** @hidden */
  76216. _width: number;
  76217. /** @hidden */
  76218. _height: number;
  76219. /** @hidden */
  76220. _minX: number;
  76221. /** @hidden */
  76222. _maxX: number;
  76223. /** @hidden */
  76224. _minZ: number;
  76225. /** @hidden */
  76226. _maxZ: number;
  76227. constructor(name: string, scene: Scene);
  76228. /**
  76229. * "GroundMesh"
  76230. * @returns "GroundMesh"
  76231. */
  76232. getClassName(): string;
  76233. /**
  76234. * The minimum of x and y subdivisions
  76235. */
  76236. readonly subdivisions: number;
  76237. /**
  76238. * X subdivisions
  76239. */
  76240. readonly subdivisionsX: number;
  76241. /**
  76242. * Y subdivisions
  76243. */
  76244. readonly subdivisionsY: number;
  76245. /**
  76246. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76247. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76248. * @param chunksCount the number of subdivisions for x and y
  76249. * @param octreeBlocksSize (Default: 32)
  76250. */
  76251. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76252. /**
  76253. * Returns a height (y) value in the Worl system :
  76254. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76255. * @param x x coordinate
  76256. * @param z z coordinate
  76257. * @returns the ground y position if (x, z) are outside the ground surface.
  76258. */
  76259. getHeightAtCoordinates(x: number, z: number): number;
  76260. /**
  76261. * Returns a normalized vector (Vector3) orthogonal to the ground
  76262. * at the ground coordinates (x, z) expressed in the World system.
  76263. * @param x x coordinate
  76264. * @param z z coordinate
  76265. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76266. */
  76267. getNormalAtCoordinates(x: number, z: number): Vector3;
  76268. /**
  76269. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76270. * at the ground coordinates (x, z) expressed in the World system.
  76271. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76272. * @param x x coordinate
  76273. * @param z z coordinate
  76274. * @param ref vector to store the result
  76275. * @returns the GroundMesh.
  76276. */
  76277. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76278. /**
  76279. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76280. * if the ground has been updated.
  76281. * This can be used in the render loop.
  76282. * @returns the GroundMesh.
  76283. */
  76284. updateCoordinateHeights(): GroundMesh;
  76285. private _getFacetAt;
  76286. private _initHeightQuads;
  76287. private _computeHeightQuads;
  76288. /**
  76289. * Serializes this ground mesh
  76290. * @param serializationObject object to write serialization to
  76291. */
  76292. serialize(serializationObject: any): void;
  76293. /**
  76294. * Parses a serialized ground mesh
  76295. * @param parsedMesh the serialized mesh
  76296. * @param scene the scene to create the ground mesh in
  76297. * @returns the created ground mesh
  76298. */
  76299. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76300. }
  76301. }
  76302. declare module BABYLON {
  76303. /**
  76304. * Interface for Physics-Joint data
  76305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76306. */
  76307. export interface PhysicsJointData {
  76308. /**
  76309. * The main pivot of the joint
  76310. */
  76311. mainPivot?: Vector3;
  76312. /**
  76313. * The connected pivot of the joint
  76314. */
  76315. connectedPivot?: Vector3;
  76316. /**
  76317. * The main axis of the joint
  76318. */
  76319. mainAxis?: Vector3;
  76320. /**
  76321. * The connected axis of the joint
  76322. */
  76323. connectedAxis?: Vector3;
  76324. /**
  76325. * The collision of the joint
  76326. */
  76327. collision?: boolean;
  76328. /**
  76329. * Native Oimo/Cannon/Energy data
  76330. */
  76331. nativeParams?: any;
  76332. }
  76333. /**
  76334. * This is a holder class for the physics joint created by the physics plugin
  76335. * It holds a set of functions to control the underlying joint
  76336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76337. */
  76338. export class PhysicsJoint {
  76339. /**
  76340. * The type of the physics joint
  76341. */
  76342. type: number;
  76343. /**
  76344. * The data for the physics joint
  76345. */
  76346. jointData: PhysicsJointData;
  76347. private _physicsJoint;
  76348. protected _physicsPlugin: IPhysicsEnginePlugin;
  76349. /**
  76350. * Initializes the physics joint
  76351. * @param type The type of the physics joint
  76352. * @param jointData The data for the physics joint
  76353. */
  76354. constructor(
  76355. /**
  76356. * The type of the physics joint
  76357. */
  76358. type: number,
  76359. /**
  76360. * The data for the physics joint
  76361. */
  76362. jointData: PhysicsJointData);
  76363. /**
  76364. * Gets the physics joint
  76365. */
  76366. /**
  76367. * Sets the physics joint
  76368. */
  76369. physicsJoint: any;
  76370. /**
  76371. * Sets the physics plugin
  76372. */
  76373. physicsPlugin: IPhysicsEnginePlugin;
  76374. /**
  76375. * Execute a function that is physics-plugin specific.
  76376. * @param {Function} func the function that will be executed.
  76377. * It accepts two parameters: the physics world and the physics joint
  76378. */
  76379. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76380. /**
  76381. * Distance-Joint type
  76382. */
  76383. static DistanceJoint: number;
  76384. /**
  76385. * Hinge-Joint type
  76386. */
  76387. static HingeJoint: number;
  76388. /**
  76389. * Ball-and-Socket joint type
  76390. */
  76391. static BallAndSocketJoint: number;
  76392. /**
  76393. * Wheel-Joint type
  76394. */
  76395. static WheelJoint: number;
  76396. /**
  76397. * Slider-Joint type
  76398. */
  76399. static SliderJoint: number;
  76400. /**
  76401. * Prismatic-Joint type
  76402. */
  76403. static PrismaticJoint: number;
  76404. /**
  76405. * Universal-Joint type
  76406. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76407. */
  76408. static UniversalJoint: number;
  76409. /**
  76410. * Hinge-Joint 2 type
  76411. */
  76412. static Hinge2Joint: number;
  76413. /**
  76414. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76415. */
  76416. static PointToPointJoint: number;
  76417. /**
  76418. * Spring-Joint type
  76419. */
  76420. static SpringJoint: number;
  76421. /**
  76422. * Lock-Joint type
  76423. */
  76424. static LockJoint: number;
  76425. }
  76426. /**
  76427. * A class representing a physics distance joint
  76428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76429. */
  76430. export class DistanceJoint extends PhysicsJoint {
  76431. /**
  76432. *
  76433. * @param jointData The data for the Distance-Joint
  76434. */
  76435. constructor(jointData: DistanceJointData);
  76436. /**
  76437. * Update the predefined distance.
  76438. * @param maxDistance The maximum preferred distance
  76439. * @param minDistance The minimum preferred distance
  76440. */
  76441. updateDistance(maxDistance: number, minDistance?: number): void;
  76442. }
  76443. /**
  76444. * Represents a Motor-Enabled Joint
  76445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76446. */
  76447. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76448. /**
  76449. * Initializes the Motor-Enabled Joint
  76450. * @param type The type of the joint
  76451. * @param jointData The physica joint data for the joint
  76452. */
  76453. constructor(type: number, jointData: PhysicsJointData);
  76454. /**
  76455. * Set the motor values.
  76456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76457. * @param force the force to apply
  76458. * @param maxForce max force for this motor.
  76459. */
  76460. setMotor(force?: number, maxForce?: number): void;
  76461. /**
  76462. * Set the motor's limits.
  76463. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76464. * @param upperLimit The upper limit of the motor
  76465. * @param lowerLimit The lower limit of the motor
  76466. */
  76467. setLimit(upperLimit: number, lowerLimit?: number): void;
  76468. }
  76469. /**
  76470. * This class represents a single physics Hinge-Joint
  76471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76472. */
  76473. export class HingeJoint extends MotorEnabledJoint {
  76474. /**
  76475. * Initializes the Hinge-Joint
  76476. * @param jointData The joint data for the Hinge-Joint
  76477. */
  76478. constructor(jointData: PhysicsJointData);
  76479. /**
  76480. * Set the motor values.
  76481. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76482. * @param {number} force the force to apply
  76483. * @param {number} maxForce max force for this motor.
  76484. */
  76485. setMotor(force?: number, maxForce?: number): void;
  76486. /**
  76487. * Set the motor's limits.
  76488. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76489. * @param upperLimit The upper limit of the motor
  76490. * @param lowerLimit The lower limit of the motor
  76491. */
  76492. setLimit(upperLimit: number, lowerLimit?: number): void;
  76493. }
  76494. /**
  76495. * This class represents a dual hinge physics joint (same as wheel joint)
  76496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76497. */
  76498. export class Hinge2Joint extends MotorEnabledJoint {
  76499. /**
  76500. * Initializes the Hinge2-Joint
  76501. * @param jointData The joint data for the Hinge2-Joint
  76502. */
  76503. constructor(jointData: PhysicsJointData);
  76504. /**
  76505. * Set the motor values.
  76506. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76507. * @param {number} targetSpeed the speed the motor is to reach
  76508. * @param {number} maxForce max force for this motor.
  76509. * @param {motorIndex} the motor's index, 0 or 1.
  76510. */
  76511. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76512. /**
  76513. * Set the motor limits.
  76514. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76515. * @param {number} upperLimit the upper limit
  76516. * @param {number} lowerLimit lower limit
  76517. * @param {motorIndex} the motor's index, 0 or 1.
  76518. */
  76519. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76520. }
  76521. /**
  76522. * Interface for a motor enabled joint
  76523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76524. */
  76525. export interface IMotorEnabledJoint {
  76526. /**
  76527. * Physics joint
  76528. */
  76529. physicsJoint: any;
  76530. /**
  76531. * Sets the motor of the motor-enabled joint
  76532. * @param force The force of the motor
  76533. * @param maxForce The maximum force of the motor
  76534. * @param motorIndex The index of the motor
  76535. */
  76536. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76537. /**
  76538. * Sets the limit of the motor
  76539. * @param upperLimit The upper limit of the motor
  76540. * @param lowerLimit The lower limit of the motor
  76541. * @param motorIndex The index of the motor
  76542. */
  76543. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76544. }
  76545. /**
  76546. * Joint data for a Distance-Joint
  76547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76548. */
  76549. export interface DistanceJointData extends PhysicsJointData {
  76550. /**
  76551. * Max distance the 2 joint objects can be apart
  76552. */
  76553. maxDistance: number;
  76554. }
  76555. /**
  76556. * Joint data from a spring joint
  76557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76558. */
  76559. export interface SpringJointData extends PhysicsJointData {
  76560. /**
  76561. * Length of the spring
  76562. */
  76563. length: number;
  76564. /**
  76565. * Stiffness of the spring
  76566. */
  76567. stiffness: number;
  76568. /**
  76569. * Damping of the spring
  76570. */
  76571. damping: number;
  76572. /** this callback will be called when applying the force to the impostors. */
  76573. forceApplicationCallback: () => void;
  76574. }
  76575. }
  76576. declare module BABYLON {
  76577. /**
  76578. * Interface used to describe a physics joint
  76579. */
  76580. export interface PhysicsImpostorJoint {
  76581. /** Defines the main impostor to which the joint is linked */
  76582. mainImpostor: PhysicsImpostor;
  76583. /** Defines the impostor that is connected to the main impostor using this joint */
  76584. connectedImpostor: PhysicsImpostor;
  76585. /** Defines the joint itself */
  76586. joint: PhysicsJoint;
  76587. }
  76588. /** @hidden */
  76589. export interface IPhysicsEnginePlugin {
  76590. world: any;
  76591. name: string;
  76592. setGravity(gravity: Vector3): void;
  76593. setTimeStep(timeStep: number): void;
  76594. getTimeStep(): number;
  76595. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76596. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76597. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76598. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76599. removePhysicsBody(impostor: PhysicsImpostor): void;
  76600. generateJoint(joint: PhysicsImpostorJoint): void;
  76601. removeJoint(joint: PhysicsImpostorJoint): void;
  76602. isSupported(): boolean;
  76603. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76604. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76605. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76606. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76607. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76608. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76609. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76610. getBodyMass(impostor: PhysicsImpostor): number;
  76611. getBodyFriction(impostor: PhysicsImpostor): number;
  76612. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76613. getBodyRestitution(impostor: PhysicsImpostor): number;
  76614. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76615. sleepBody(impostor: PhysicsImpostor): void;
  76616. wakeUpBody(impostor: PhysicsImpostor): void;
  76617. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76618. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76619. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76620. getRadius(impostor: PhysicsImpostor): number;
  76621. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76622. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76623. dispose(): void;
  76624. }
  76625. /**
  76626. * Interface used to define a physics engine
  76627. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76628. */
  76629. export interface IPhysicsEngine {
  76630. /**
  76631. * Gets the gravity vector used by the simulation
  76632. */
  76633. gravity: Vector3;
  76634. /**
  76635. * Sets the gravity vector used by the simulation
  76636. * @param gravity defines the gravity vector to use
  76637. */
  76638. setGravity(gravity: Vector3): void;
  76639. /**
  76640. * Set the time step of the physics engine.
  76641. * Default is 1/60.
  76642. * To slow it down, enter 1/600 for example.
  76643. * To speed it up, 1/30
  76644. * @param newTimeStep the new timestep to apply to this world.
  76645. */
  76646. setTimeStep(newTimeStep: number): void;
  76647. /**
  76648. * Get the time step of the physics engine.
  76649. * @returns the current time step
  76650. */
  76651. getTimeStep(): number;
  76652. /**
  76653. * Release all resources
  76654. */
  76655. dispose(): void;
  76656. /**
  76657. * Gets the name of the current physics plugin
  76658. * @returns the name of the plugin
  76659. */
  76660. getPhysicsPluginName(): string;
  76661. /**
  76662. * Adding a new impostor for the impostor tracking.
  76663. * This will be done by the impostor itself.
  76664. * @param impostor the impostor to add
  76665. */
  76666. addImpostor(impostor: PhysicsImpostor): void;
  76667. /**
  76668. * Remove an impostor from the engine.
  76669. * This impostor and its mesh will not longer be updated by the physics engine.
  76670. * @param impostor the impostor to remove
  76671. */
  76672. removeImpostor(impostor: PhysicsImpostor): void;
  76673. /**
  76674. * Add a joint to the physics engine
  76675. * @param mainImpostor defines the main impostor to which the joint is added.
  76676. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76677. * @param joint defines the joint that will connect both impostors.
  76678. */
  76679. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76680. /**
  76681. * Removes a joint from the simulation
  76682. * @param mainImpostor defines the impostor used with the joint
  76683. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76684. * @param joint defines the joint to remove
  76685. */
  76686. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76687. /**
  76688. * Gets the current plugin used to run the simulation
  76689. * @returns current plugin
  76690. */
  76691. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76692. /**
  76693. * Gets the list of physic impostors
  76694. * @returns an array of PhysicsImpostor
  76695. */
  76696. getImpostors(): Array<PhysicsImpostor>;
  76697. /**
  76698. * Gets the impostor for a physics enabled object
  76699. * @param object defines the object impersonated by the impostor
  76700. * @returns the PhysicsImpostor or null if not found
  76701. */
  76702. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76703. /**
  76704. * Gets the impostor for a physics body object
  76705. * @param body defines physics body used by the impostor
  76706. * @returns the PhysicsImpostor or null if not found
  76707. */
  76708. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76709. /**
  76710. * Called by the scene. No need to call it.
  76711. * @param delta defines the timespam between frames
  76712. */
  76713. _step(delta: number): void;
  76714. }
  76715. }
  76716. declare module BABYLON {
  76717. /**
  76718. * The interface for the physics imposter parameters
  76719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76720. */
  76721. export interface PhysicsImpostorParameters {
  76722. /**
  76723. * The mass of the physics imposter
  76724. */
  76725. mass: number;
  76726. /**
  76727. * The friction of the physics imposter
  76728. */
  76729. friction?: number;
  76730. /**
  76731. * The coefficient of restitution of the physics imposter
  76732. */
  76733. restitution?: number;
  76734. /**
  76735. * The native options of the physics imposter
  76736. */
  76737. nativeOptions?: any;
  76738. /**
  76739. * Specifies if the parent should be ignored
  76740. */
  76741. ignoreParent?: boolean;
  76742. /**
  76743. * Specifies if bi-directional transformations should be disabled
  76744. */
  76745. disableBidirectionalTransformation?: boolean;
  76746. }
  76747. /**
  76748. * Interface for a physics-enabled object
  76749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76750. */
  76751. export interface IPhysicsEnabledObject {
  76752. /**
  76753. * The position of the physics-enabled object
  76754. */
  76755. position: Vector3;
  76756. /**
  76757. * The rotation of the physics-enabled object
  76758. */
  76759. rotationQuaternion: Nullable<Quaternion>;
  76760. /**
  76761. * The scale of the physics-enabled object
  76762. */
  76763. scaling: Vector3;
  76764. /**
  76765. * The rotation of the physics-enabled object
  76766. */
  76767. rotation?: Vector3;
  76768. /**
  76769. * The parent of the physics-enabled object
  76770. */
  76771. parent?: any;
  76772. /**
  76773. * The bounding info of the physics-enabled object
  76774. * @returns The bounding info of the physics-enabled object
  76775. */
  76776. getBoundingInfo(): BoundingInfo;
  76777. /**
  76778. * Computes the world matrix
  76779. * @param force Specifies if the world matrix should be computed by force
  76780. * @returns A world matrix
  76781. */
  76782. computeWorldMatrix(force: boolean): Matrix;
  76783. /**
  76784. * Gets the world matrix
  76785. * @returns A world matrix
  76786. */
  76787. getWorldMatrix?(): Matrix;
  76788. /**
  76789. * Gets the child meshes
  76790. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76791. * @returns An array of abstract meshes
  76792. */
  76793. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76794. /**
  76795. * Gets the vertex data
  76796. * @param kind The type of vertex data
  76797. * @returns A nullable array of numbers, or a float32 array
  76798. */
  76799. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76800. /**
  76801. * Gets the indices from the mesh
  76802. * @returns A nullable array of index arrays
  76803. */
  76804. getIndices?(): Nullable<IndicesArray>;
  76805. /**
  76806. * Gets the scene from the mesh
  76807. * @returns the indices array or null
  76808. */
  76809. getScene?(): Scene;
  76810. /**
  76811. * Gets the absolute position from the mesh
  76812. * @returns the absolute position
  76813. */
  76814. getAbsolutePosition(): Vector3;
  76815. /**
  76816. * Gets the absolute pivot point from the mesh
  76817. * @returns the absolute pivot point
  76818. */
  76819. getAbsolutePivotPoint(): Vector3;
  76820. /**
  76821. * Rotates the mesh
  76822. * @param axis The axis of rotation
  76823. * @param amount The amount of rotation
  76824. * @param space The space of the rotation
  76825. * @returns The rotation transform node
  76826. */
  76827. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76828. /**
  76829. * Translates the mesh
  76830. * @param axis The axis of translation
  76831. * @param distance The distance of translation
  76832. * @param space The space of the translation
  76833. * @returns The transform node
  76834. */
  76835. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76836. /**
  76837. * Sets the absolute position of the mesh
  76838. * @param absolutePosition The absolute position of the mesh
  76839. * @returns The transform node
  76840. */
  76841. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76842. /**
  76843. * Gets the class name of the mesh
  76844. * @returns The class name
  76845. */
  76846. getClassName(): string;
  76847. }
  76848. /**
  76849. * Represents a physics imposter
  76850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76851. */
  76852. export class PhysicsImpostor {
  76853. /**
  76854. * The physics-enabled object used as the physics imposter
  76855. */
  76856. object: IPhysicsEnabledObject;
  76857. /**
  76858. * The type of the physics imposter
  76859. */
  76860. type: number;
  76861. private _options;
  76862. private _scene?;
  76863. /**
  76864. * The default object size of the imposter
  76865. */
  76866. static DEFAULT_OBJECT_SIZE: Vector3;
  76867. /**
  76868. * The identity quaternion of the imposter
  76869. */
  76870. static IDENTITY_QUATERNION: Quaternion;
  76871. /** @hidden */
  76872. _pluginData: any;
  76873. private _physicsEngine;
  76874. private _physicsBody;
  76875. private _bodyUpdateRequired;
  76876. private _onBeforePhysicsStepCallbacks;
  76877. private _onAfterPhysicsStepCallbacks;
  76878. /** @hidden */
  76879. _onPhysicsCollideCallbacks: Array<{
  76880. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76881. otherImpostors: Array<PhysicsImpostor>;
  76882. }>;
  76883. private _deltaPosition;
  76884. private _deltaRotation;
  76885. private _deltaRotationConjugated;
  76886. private _parent;
  76887. private _isDisposed;
  76888. private static _tmpVecs;
  76889. private static _tmpQuat;
  76890. /**
  76891. * Specifies if the physics imposter is disposed
  76892. */
  76893. readonly isDisposed: boolean;
  76894. /**
  76895. * Gets the mass of the physics imposter
  76896. */
  76897. mass: number;
  76898. /**
  76899. * Gets the coefficient of friction
  76900. */
  76901. /**
  76902. * Sets the coefficient of friction
  76903. */
  76904. friction: number;
  76905. /**
  76906. * Gets the coefficient of restitution
  76907. */
  76908. /**
  76909. * Sets the coefficient of restitution
  76910. */
  76911. restitution: number;
  76912. /**
  76913. * The unique id of the physics imposter
  76914. * set by the physics engine when adding this impostor to the array
  76915. */
  76916. uniqueId: number;
  76917. private _joints;
  76918. /**
  76919. * Initializes the physics imposter
  76920. * @param object The physics-enabled object used as the physics imposter
  76921. * @param type The type of the physics imposter
  76922. * @param _options The options for the physics imposter
  76923. * @param _scene The Babylon scene
  76924. */
  76925. constructor(
  76926. /**
  76927. * The physics-enabled object used as the physics imposter
  76928. */
  76929. object: IPhysicsEnabledObject,
  76930. /**
  76931. * The type of the physics imposter
  76932. */
  76933. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76934. /**
  76935. * This function will completly initialize this impostor.
  76936. * It will create a new body - but only if this mesh has no parent.
  76937. * If it has, this impostor will not be used other than to define the impostor
  76938. * of the child mesh.
  76939. * @hidden
  76940. */
  76941. _init(): void;
  76942. private _getPhysicsParent;
  76943. /**
  76944. * Should a new body be generated.
  76945. * @returns boolean specifying if body initialization is required
  76946. */
  76947. isBodyInitRequired(): boolean;
  76948. /**
  76949. * Sets the updated scaling
  76950. * @param updated Specifies if the scaling is updated
  76951. */
  76952. setScalingUpdated(): void;
  76953. /**
  76954. * Force a regeneration of this or the parent's impostor's body.
  76955. * Use under cautious - This will remove all joints already implemented.
  76956. */
  76957. forceUpdate(): void;
  76958. /**
  76959. * Gets the body that holds this impostor. Either its own, or its parent.
  76960. */
  76961. /**
  76962. * Set the physics body. Used mainly by the physics engine/plugin
  76963. */
  76964. physicsBody: any;
  76965. /**
  76966. * Get the parent of the physics imposter
  76967. * @returns Physics imposter or null
  76968. */
  76969. /**
  76970. * Sets the parent of the physics imposter
  76971. */
  76972. parent: Nullable<PhysicsImpostor>;
  76973. /**
  76974. * Resets the update flags
  76975. */
  76976. resetUpdateFlags(): void;
  76977. /**
  76978. * Gets the object extend size
  76979. * @returns the object extend size
  76980. */
  76981. getObjectExtendSize(): Vector3;
  76982. /**
  76983. * Gets the object center
  76984. * @returns The object center
  76985. */
  76986. getObjectCenter(): Vector3;
  76987. /**
  76988. * Get a specific parametes from the options parameter
  76989. * @param paramName The object parameter name
  76990. * @returns The object parameter
  76991. */
  76992. getParam(paramName: string): any;
  76993. /**
  76994. * Sets a specific parameter in the options given to the physics plugin
  76995. * @param paramName The parameter name
  76996. * @param value The value of the parameter
  76997. */
  76998. setParam(paramName: string, value: number): void;
  76999. /**
  77000. * Specifically change the body's mass option. Won't recreate the physics body object
  77001. * @param mass The mass of the physics imposter
  77002. */
  77003. setMass(mass: number): void;
  77004. /**
  77005. * Gets the linear velocity
  77006. * @returns linear velocity or null
  77007. */
  77008. getLinearVelocity(): Nullable<Vector3>;
  77009. /**
  77010. * Sets the linear velocity
  77011. * @param velocity linear velocity or null
  77012. */
  77013. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77014. /**
  77015. * Gets the angular velocity
  77016. * @returns angular velocity or null
  77017. */
  77018. getAngularVelocity(): Nullable<Vector3>;
  77019. /**
  77020. * Sets the angular velocity
  77021. * @param velocity The velocity or null
  77022. */
  77023. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77024. /**
  77025. * Execute a function with the physics plugin native code
  77026. * Provide a function the will have two variables - the world object and the physics body object
  77027. * @param func The function to execute with the physics plugin native code
  77028. */
  77029. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77030. /**
  77031. * Register a function that will be executed before the physics world is stepping forward
  77032. * @param func The function to execute before the physics world is stepped forward
  77033. */
  77034. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77035. /**
  77036. * Unregister a function that will be executed before the physics world is stepping forward
  77037. * @param func The function to execute before the physics world is stepped forward
  77038. */
  77039. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77040. /**
  77041. * Register a function that will be executed after the physics step
  77042. * @param func The function to execute after physics step
  77043. */
  77044. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77045. /**
  77046. * Unregisters a function that will be executed after the physics step
  77047. * @param func The function to execute after physics step
  77048. */
  77049. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77050. /**
  77051. * register a function that will be executed when this impostor collides against a different body
  77052. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77053. * @param func Callback that is executed on collision
  77054. */
  77055. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77056. /**
  77057. * Unregisters the physics imposter on contact
  77058. * @param collideAgainst The physics object to collide against
  77059. * @param func Callback to execute on collision
  77060. */
  77061. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77062. private _tmpQuat;
  77063. private _tmpQuat2;
  77064. /**
  77065. * Get the parent rotation
  77066. * @returns The parent rotation
  77067. */
  77068. getParentsRotation(): Quaternion;
  77069. /**
  77070. * this function is executed by the physics engine.
  77071. */
  77072. beforeStep: () => void;
  77073. /**
  77074. * this function is executed by the physics engine
  77075. */
  77076. afterStep: () => void;
  77077. /**
  77078. * Legacy collision detection event support
  77079. */
  77080. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77081. /**
  77082. * event and body object due to cannon's event-based architecture.
  77083. */
  77084. onCollide: (e: {
  77085. body: any;
  77086. }) => void;
  77087. /**
  77088. * Apply a force
  77089. * @param force The force to apply
  77090. * @param contactPoint The contact point for the force
  77091. * @returns The physics imposter
  77092. */
  77093. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77094. /**
  77095. * Apply an impulse
  77096. * @param force The impulse force
  77097. * @param contactPoint The contact point for the impulse force
  77098. * @returns The physics imposter
  77099. */
  77100. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77101. /**
  77102. * A help function to create a joint
  77103. * @param otherImpostor A physics imposter used to create a joint
  77104. * @param jointType The type of joint
  77105. * @param jointData The data for the joint
  77106. * @returns The physics imposter
  77107. */
  77108. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77109. /**
  77110. * Add a joint to this impostor with a different impostor
  77111. * @param otherImpostor A physics imposter used to add a joint
  77112. * @param joint The joint to add
  77113. * @returns The physics imposter
  77114. */
  77115. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77116. /**
  77117. * Will keep this body still, in a sleep mode.
  77118. * @returns the physics imposter
  77119. */
  77120. sleep(): PhysicsImpostor;
  77121. /**
  77122. * Wake the body up.
  77123. * @returns The physics imposter
  77124. */
  77125. wakeUp(): PhysicsImpostor;
  77126. /**
  77127. * Clones the physics imposter
  77128. * @param newObject The physics imposter clones to this physics-enabled object
  77129. * @returns A nullable physics imposter
  77130. */
  77131. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77132. /**
  77133. * Disposes the physics imposter
  77134. */
  77135. dispose(): void;
  77136. /**
  77137. * Sets the delta position
  77138. * @param position The delta position amount
  77139. */
  77140. setDeltaPosition(position: Vector3): void;
  77141. /**
  77142. * Sets the delta rotation
  77143. * @param rotation The delta rotation amount
  77144. */
  77145. setDeltaRotation(rotation: Quaternion): void;
  77146. /**
  77147. * Gets the box size of the physics imposter and stores the result in the input parameter
  77148. * @param result Stores the box size
  77149. * @returns The physics imposter
  77150. */
  77151. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77152. /**
  77153. * Gets the radius of the physics imposter
  77154. * @returns Radius of the physics imposter
  77155. */
  77156. getRadius(): number;
  77157. /**
  77158. * Sync a bone with this impostor
  77159. * @param bone The bone to sync to the impostor.
  77160. * @param boneMesh The mesh that the bone is influencing.
  77161. * @param jointPivot The pivot of the joint / bone in local space.
  77162. * @param distToJoint Optional distance from the impostor to the joint.
  77163. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77164. */
  77165. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77166. /**
  77167. * Sync impostor to a bone
  77168. * @param bone The bone that the impostor will be synced to.
  77169. * @param boneMesh The mesh that the bone is influencing.
  77170. * @param jointPivot The pivot of the joint / bone in local space.
  77171. * @param distToJoint Optional distance from the impostor to the joint.
  77172. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77173. * @param boneAxis Optional vector3 axis the bone is aligned with
  77174. */
  77175. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77176. /**
  77177. * No-Imposter type
  77178. */
  77179. static NoImpostor: number;
  77180. /**
  77181. * Sphere-Imposter type
  77182. */
  77183. static SphereImpostor: number;
  77184. /**
  77185. * Box-Imposter type
  77186. */
  77187. static BoxImpostor: number;
  77188. /**
  77189. * Plane-Imposter type
  77190. */
  77191. static PlaneImpostor: number;
  77192. /**
  77193. * Mesh-imposter type
  77194. */
  77195. static MeshImpostor: number;
  77196. /**
  77197. * Cylinder-Imposter type
  77198. */
  77199. static CylinderImpostor: number;
  77200. /**
  77201. * Particle-Imposter type
  77202. */
  77203. static ParticleImpostor: number;
  77204. /**
  77205. * Heightmap-Imposter type
  77206. */
  77207. static HeightmapImpostor: number;
  77208. }
  77209. }
  77210. declare module BABYLON {
  77211. /**
  77212. * Class used to represent a specific level of detail of a mesh
  77213. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77214. */
  77215. export class MeshLODLevel {
  77216. /** Defines the distance where this level should star being displayed */
  77217. distance: number;
  77218. /** Defines the mesh to use to render this level */
  77219. mesh: Nullable<Mesh>;
  77220. /**
  77221. * Creates a new LOD level
  77222. * @param distance defines the distance where this level should star being displayed
  77223. * @param mesh defines the mesh to use to render this level
  77224. */
  77225. constructor(
  77226. /** Defines the distance where this level should star being displayed */
  77227. distance: number,
  77228. /** Defines the mesh to use to render this level */
  77229. mesh: Nullable<Mesh>);
  77230. }
  77231. /**
  77232. * @hidden
  77233. **/
  77234. export class _CreationDataStorage {
  77235. closePath?: boolean;
  77236. closeArray?: boolean;
  77237. idx: number[];
  77238. dashSize: number;
  77239. gapSize: number;
  77240. path3D: Path3D;
  77241. pathArray: Vector3[][];
  77242. arc: number;
  77243. radius: number;
  77244. cap: number;
  77245. tessellation: number;
  77246. }
  77247. /**
  77248. * @hidden
  77249. **/
  77250. class _InstanceDataStorage {
  77251. visibleInstances: any;
  77252. renderIdForInstances: number[];
  77253. batchCache: _InstancesBatch;
  77254. instancesBufferSize: number;
  77255. instancesBuffer: Nullable<Buffer>;
  77256. instancesData: Float32Array;
  77257. overridenInstanceCount: number;
  77258. }
  77259. /**
  77260. * @hidden
  77261. **/
  77262. export class _InstancesBatch {
  77263. mustReturn: boolean;
  77264. visibleInstances: Nullable<InstancedMesh[]>[];
  77265. renderSelf: boolean[];
  77266. }
  77267. /**
  77268. * Class used to represent renderable models
  77269. */
  77270. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77271. /**
  77272. * Mesh side orientation : usually the external or front surface
  77273. */
  77274. static readonly FRONTSIDE: number;
  77275. /**
  77276. * Mesh side orientation : usually the internal or back surface
  77277. */
  77278. static readonly BACKSIDE: number;
  77279. /**
  77280. * Mesh side orientation : both internal and external or front and back surfaces
  77281. */
  77282. static readonly DOUBLESIDE: number;
  77283. /**
  77284. * Mesh side orientation : by default, `FRONTSIDE`
  77285. */
  77286. static readonly DEFAULTSIDE: number;
  77287. /**
  77288. * Mesh cap setting : no cap
  77289. */
  77290. static readonly NO_CAP: number;
  77291. /**
  77292. * Mesh cap setting : one cap at the beginning of the mesh
  77293. */
  77294. static readonly CAP_START: number;
  77295. /**
  77296. * Mesh cap setting : one cap at the end of the mesh
  77297. */
  77298. static readonly CAP_END: number;
  77299. /**
  77300. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77301. */
  77302. static readonly CAP_ALL: number;
  77303. /**
  77304. * Gets the default side orientation.
  77305. * @param orientation the orientation to value to attempt to get
  77306. * @returns the default orientation
  77307. * @hidden
  77308. */
  77309. static _GetDefaultSideOrientation(orientation?: number): number;
  77310. private _onBeforeRenderObservable;
  77311. private _onBeforeBindObservable;
  77312. private _onAfterRenderObservable;
  77313. private _onBeforeDrawObservable;
  77314. /**
  77315. * An event triggered before rendering the mesh
  77316. */
  77317. readonly onBeforeRenderObservable: Observable<Mesh>;
  77318. /**
  77319. * An event triggered before binding the mesh
  77320. */
  77321. readonly onBeforeBindObservable: Observable<Mesh>;
  77322. /**
  77323. * An event triggered after rendering the mesh
  77324. */
  77325. readonly onAfterRenderObservable: Observable<Mesh>;
  77326. /**
  77327. * An event triggered before drawing the mesh
  77328. */
  77329. readonly onBeforeDrawObservable: Observable<Mesh>;
  77330. private _onBeforeDrawObserver;
  77331. /**
  77332. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77333. */
  77334. onBeforeDraw: () => void;
  77335. /**
  77336. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77337. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77338. */
  77339. delayLoadState: number;
  77340. /**
  77341. * Gets the list of instances created from this mesh
  77342. * it is not supposed to be modified manually.
  77343. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77344. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77345. */
  77346. instances: InstancedMesh[];
  77347. /**
  77348. * Gets the file containing delay loading data for this mesh
  77349. */
  77350. delayLoadingFile: string;
  77351. /** @hidden */
  77352. _binaryInfo: any;
  77353. private _LODLevels;
  77354. /**
  77355. * User defined function used to change how LOD level selection is done
  77356. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77357. */
  77358. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77359. private _morphTargetManager;
  77360. /**
  77361. * Gets or sets the morph target manager
  77362. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77363. */
  77364. morphTargetManager: Nullable<MorphTargetManager>;
  77365. /** @hidden */
  77366. _creationDataStorage: Nullable<_CreationDataStorage>;
  77367. /** @hidden */
  77368. _geometry: Nullable<Geometry>;
  77369. /** @hidden */
  77370. _delayInfo: Array<string>;
  77371. /** @hidden */
  77372. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77373. /** @hidden */
  77374. _instanceDataStorage: _InstanceDataStorage;
  77375. private _effectiveMaterial;
  77376. /** @hidden */
  77377. _shouldGenerateFlatShading: boolean;
  77378. private _preActivateId;
  77379. /** @hidden */
  77380. _originalBuilderSideOrientation: number;
  77381. /**
  77382. * Use this property to change the original side orientation defined at construction time
  77383. */
  77384. overrideMaterialSideOrientation: Nullable<number>;
  77385. private _areNormalsFrozen;
  77386. private _sourcePositions;
  77387. private _sourceNormals;
  77388. private _source;
  77389. private meshMap;
  77390. /**
  77391. * Gets the source mesh (the one used to clone this one from)
  77392. */
  77393. readonly source: Nullable<Mesh>;
  77394. /**
  77395. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77396. */
  77397. isUnIndexed: boolean;
  77398. /**
  77399. * @constructor
  77400. * @param name The value used by scene.getMeshByName() to do a lookup.
  77401. * @param scene The scene to add this mesh to.
  77402. * @param parent The parent of this mesh, if it has one
  77403. * @param source An optional Mesh from which geometry is shared, cloned.
  77404. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77405. * When false, achieved by calling a clone(), also passing False.
  77406. * This will make creation of children, recursive.
  77407. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77408. */
  77409. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77410. /**
  77411. * Gets the class name
  77412. * @returns the string "Mesh".
  77413. */
  77414. getClassName(): string;
  77415. /** @hidden */
  77416. readonly _isMesh: boolean;
  77417. /**
  77418. * Returns a description of this mesh
  77419. * @param fullDetails define if full details about this mesh must be used
  77420. * @returns a descriptive string representing this mesh
  77421. */
  77422. toString(fullDetails?: boolean): string;
  77423. /** @hidden */
  77424. _unBindEffect(): void;
  77425. /**
  77426. * Gets a boolean indicating if this mesh has LOD
  77427. */
  77428. readonly hasLODLevels: boolean;
  77429. /**
  77430. * Gets the list of MeshLODLevel associated with the current mesh
  77431. * @returns an array of MeshLODLevel
  77432. */
  77433. getLODLevels(): MeshLODLevel[];
  77434. private _sortLODLevels;
  77435. /**
  77436. * Add a mesh as LOD level triggered at the given distance.
  77437. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77438. * @param distance The distance from the center of the object to show this level
  77439. * @param mesh The mesh to be added as LOD level (can be null)
  77440. * @return This mesh (for chaining)
  77441. */
  77442. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77443. /**
  77444. * Returns the LOD level mesh at the passed distance or null if not found.
  77445. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77446. * @param distance The distance from the center of the object to show this level
  77447. * @returns a Mesh or `null`
  77448. */
  77449. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77450. /**
  77451. * Remove a mesh from the LOD array
  77452. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77453. * @param mesh defines the mesh to be removed
  77454. * @return This mesh (for chaining)
  77455. */
  77456. removeLODLevel(mesh: Mesh): Mesh;
  77457. /**
  77458. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77459. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77460. * @param camera defines the camera to use to compute distance
  77461. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77462. * @return This mesh (for chaining)
  77463. */
  77464. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77465. /**
  77466. * Gets the mesh internal Geometry object
  77467. */
  77468. readonly geometry: Nullable<Geometry>;
  77469. /**
  77470. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77471. * @returns the total number of vertices
  77472. */
  77473. getTotalVertices(): number;
  77474. /**
  77475. * Returns the content of an associated vertex buffer
  77476. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77477. * - VertexBuffer.PositionKind
  77478. * - VertexBuffer.UVKind
  77479. * - VertexBuffer.UV2Kind
  77480. * - VertexBuffer.UV3Kind
  77481. * - VertexBuffer.UV4Kind
  77482. * - VertexBuffer.UV5Kind
  77483. * - VertexBuffer.UV6Kind
  77484. * - VertexBuffer.ColorKind
  77485. * - VertexBuffer.MatricesIndicesKind
  77486. * - VertexBuffer.MatricesIndicesExtraKind
  77487. * - VertexBuffer.MatricesWeightsKind
  77488. * - VertexBuffer.MatricesWeightsExtraKind
  77489. * @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
  77490. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77491. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77492. */
  77493. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77494. /**
  77495. * Returns the mesh VertexBuffer object from the requested `kind`
  77496. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77497. * - VertexBuffer.PositionKind
  77498. * - VertexBuffer.UVKind
  77499. * - VertexBuffer.UV2Kind
  77500. * - VertexBuffer.UV3Kind
  77501. * - VertexBuffer.UV4Kind
  77502. * - VertexBuffer.UV5Kind
  77503. * - VertexBuffer.UV6Kind
  77504. * - VertexBuffer.ColorKind
  77505. * - VertexBuffer.MatricesIndicesKind
  77506. * - VertexBuffer.MatricesIndicesExtraKind
  77507. * - VertexBuffer.MatricesWeightsKind
  77508. * - VertexBuffer.MatricesWeightsExtraKind
  77509. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77510. */
  77511. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77512. /**
  77513. * Tests if a specific vertex buffer is associated with this mesh
  77514. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77515. * - VertexBuffer.PositionKind
  77516. * - VertexBuffer.UVKind
  77517. * - VertexBuffer.UV2Kind
  77518. * - VertexBuffer.UV3Kind
  77519. * - VertexBuffer.UV4Kind
  77520. * - VertexBuffer.UV5Kind
  77521. * - VertexBuffer.UV6Kind
  77522. * - VertexBuffer.ColorKind
  77523. * - VertexBuffer.MatricesIndicesKind
  77524. * - VertexBuffer.MatricesIndicesExtraKind
  77525. * - VertexBuffer.MatricesWeightsKind
  77526. * - VertexBuffer.MatricesWeightsExtraKind
  77527. * @returns a boolean
  77528. */
  77529. isVerticesDataPresent(kind: string): boolean;
  77530. /**
  77531. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77532. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77533. * - VertexBuffer.PositionKind
  77534. * - VertexBuffer.UVKind
  77535. * - VertexBuffer.UV2Kind
  77536. * - VertexBuffer.UV3Kind
  77537. * - VertexBuffer.UV4Kind
  77538. * - VertexBuffer.UV5Kind
  77539. * - VertexBuffer.UV6Kind
  77540. * - VertexBuffer.ColorKind
  77541. * - VertexBuffer.MatricesIndicesKind
  77542. * - VertexBuffer.MatricesIndicesExtraKind
  77543. * - VertexBuffer.MatricesWeightsKind
  77544. * - VertexBuffer.MatricesWeightsExtraKind
  77545. * @returns a boolean
  77546. */
  77547. isVertexBufferUpdatable(kind: string): boolean;
  77548. /**
  77549. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77550. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77551. * - VertexBuffer.PositionKind
  77552. * - VertexBuffer.UVKind
  77553. * - VertexBuffer.UV2Kind
  77554. * - VertexBuffer.UV3Kind
  77555. * - VertexBuffer.UV4Kind
  77556. * - VertexBuffer.UV5Kind
  77557. * - VertexBuffer.UV6Kind
  77558. * - VertexBuffer.ColorKind
  77559. * - VertexBuffer.MatricesIndicesKind
  77560. * - VertexBuffer.MatricesIndicesExtraKind
  77561. * - VertexBuffer.MatricesWeightsKind
  77562. * - VertexBuffer.MatricesWeightsExtraKind
  77563. * @returns an array of strings
  77564. */
  77565. getVerticesDataKinds(): string[];
  77566. /**
  77567. * Returns a positive integer : the total number of indices in this mesh geometry.
  77568. * @returns the numner of indices or zero if the mesh has no geometry.
  77569. */
  77570. getTotalIndices(): number;
  77571. /**
  77572. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77573. * @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.
  77574. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77575. * @returns the indices array or an empty array if the mesh has no geometry
  77576. */
  77577. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77578. readonly isBlocked: boolean;
  77579. /**
  77580. * Determine if the current mesh is ready to be rendered
  77581. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77582. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77583. * @returns true if all associated assets are ready (material, textures, shaders)
  77584. */
  77585. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77586. /**
  77587. * 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.
  77588. */
  77589. readonly areNormalsFrozen: boolean;
  77590. /**
  77591. * 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.
  77592. * @returns the current mesh
  77593. */
  77594. freezeNormals(): Mesh;
  77595. /**
  77596. * 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
  77597. * @returns the current mesh
  77598. */
  77599. unfreezeNormals(): Mesh;
  77600. /**
  77601. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77602. */
  77603. overridenInstanceCount: number;
  77604. /** @hidden */
  77605. _preActivate(): Mesh;
  77606. /** @hidden */
  77607. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77608. /** @hidden */
  77609. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77610. /**
  77611. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77612. * This means the mesh underlying bounding box and sphere are recomputed.
  77613. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77614. * @returns the current mesh
  77615. */
  77616. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77617. /** @hidden */
  77618. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77619. /**
  77620. * This function will subdivide the mesh into multiple submeshes
  77621. * @param count defines the expected number of submeshes
  77622. */
  77623. subdivide(count: number): void;
  77624. /**
  77625. * Copy a FloatArray into a specific associated vertex buffer
  77626. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77627. * - VertexBuffer.PositionKind
  77628. * - VertexBuffer.UVKind
  77629. * - VertexBuffer.UV2Kind
  77630. * - VertexBuffer.UV3Kind
  77631. * - VertexBuffer.UV4Kind
  77632. * - VertexBuffer.UV5Kind
  77633. * - VertexBuffer.UV6Kind
  77634. * - VertexBuffer.ColorKind
  77635. * - VertexBuffer.MatricesIndicesKind
  77636. * - VertexBuffer.MatricesIndicesExtraKind
  77637. * - VertexBuffer.MatricesWeightsKind
  77638. * - VertexBuffer.MatricesWeightsExtraKind
  77639. * @param data defines the data source
  77640. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77641. * @param stride defines the data stride size (can be null)
  77642. * @returns the current mesh
  77643. */
  77644. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77645. /**
  77646. * Flags an associated vertex buffer as updatable
  77647. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77648. * - VertexBuffer.PositionKind
  77649. * - VertexBuffer.UVKind
  77650. * - VertexBuffer.UV2Kind
  77651. * - VertexBuffer.UV3Kind
  77652. * - VertexBuffer.UV4Kind
  77653. * - VertexBuffer.UV5Kind
  77654. * - VertexBuffer.UV6Kind
  77655. * - VertexBuffer.ColorKind
  77656. * - VertexBuffer.MatricesIndicesKind
  77657. * - VertexBuffer.MatricesIndicesExtraKind
  77658. * - VertexBuffer.MatricesWeightsKind
  77659. * - VertexBuffer.MatricesWeightsExtraKind
  77660. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77661. */
  77662. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77663. /**
  77664. * Sets the mesh global Vertex Buffer
  77665. * @param buffer defines the buffer to use
  77666. * @returns the current mesh
  77667. */
  77668. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77669. /**
  77670. * Update a specific associated vertex buffer
  77671. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77672. * - VertexBuffer.PositionKind
  77673. * - VertexBuffer.UVKind
  77674. * - VertexBuffer.UV2Kind
  77675. * - VertexBuffer.UV3Kind
  77676. * - VertexBuffer.UV4Kind
  77677. * - VertexBuffer.UV5Kind
  77678. * - VertexBuffer.UV6Kind
  77679. * - VertexBuffer.ColorKind
  77680. * - VertexBuffer.MatricesIndicesKind
  77681. * - VertexBuffer.MatricesIndicesExtraKind
  77682. * - VertexBuffer.MatricesWeightsKind
  77683. * - VertexBuffer.MatricesWeightsExtraKind
  77684. * @param data defines the data source
  77685. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77686. * @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)
  77687. * @returns the current mesh
  77688. */
  77689. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77690. /**
  77691. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77692. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77693. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77694. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77695. * @returns the current mesh
  77696. */
  77697. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77698. /**
  77699. * Creates a un-shared specific occurence of the geometry for the mesh.
  77700. * @returns the current mesh
  77701. */
  77702. makeGeometryUnique(): Mesh;
  77703. /**
  77704. * Set the index buffer of this mesh
  77705. * @param indices defines the source data
  77706. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77707. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77708. * @returns the current mesh
  77709. */
  77710. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77711. /**
  77712. * Update the current index buffer
  77713. * @param indices defines the source data
  77714. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77715. * @returns the current mesh
  77716. */
  77717. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  77718. /**
  77719. * Invert the geometry to move from a right handed system to a left handed one.
  77720. * @returns the current mesh
  77721. */
  77722. toLeftHanded(): Mesh;
  77723. /** @hidden */
  77724. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77725. /** @hidden */
  77726. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  77727. /**
  77728. * Registers for this mesh a javascript function called just before the rendering process
  77729. * @param func defines the function to call before rendering this mesh
  77730. * @returns the current mesh
  77731. */
  77732. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77733. /**
  77734. * Disposes a previously registered javascript function called before the rendering
  77735. * @param func defines the function to remove
  77736. * @returns the current mesh
  77737. */
  77738. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77739. /**
  77740. * Registers for this mesh a javascript function called just after the rendering is complete
  77741. * @param func defines the function to call after rendering this mesh
  77742. * @returns the current mesh
  77743. */
  77744. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77745. /**
  77746. * Disposes a previously registered javascript function called after the rendering.
  77747. * @param func defines the function to remove
  77748. * @returns the current mesh
  77749. */
  77750. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77751. /** @hidden */
  77752. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77753. /** @hidden */
  77754. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77755. /** @hidden */
  77756. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77757. /**
  77758. * 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
  77759. * @param subMesh defines the subMesh to render
  77760. * @param enableAlphaMode defines if alpha mode can be changed
  77761. * @returns the current mesh
  77762. */
  77763. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77764. private _onBeforeDraw;
  77765. /**
  77766. * Renormalize the mesh and patch it up if there are no weights
  77767. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77768. * However in the case of zero weights then we set just a single influence to 1.
  77769. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77770. */
  77771. cleanMatrixWeights(): void;
  77772. private normalizeSkinFourWeights;
  77773. private normalizeSkinWeightsAndExtra;
  77774. /**
  77775. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77776. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77777. * the user know there was an issue with importing the mesh
  77778. * @returns a validation object with skinned, valid and report string
  77779. */
  77780. validateSkinning(): {
  77781. skinned: boolean;
  77782. valid: boolean;
  77783. report: string;
  77784. };
  77785. /** @hidden */
  77786. _checkDelayState(): Mesh;
  77787. private _queueLoad;
  77788. /**
  77789. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77790. * A mesh is in the frustum if its bounding box intersects the frustum
  77791. * @param frustumPlanes defines the frustum to test
  77792. * @returns true if the mesh is in the frustum planes
  77793. */
  77794. isInFrustum(frustumPlanes: Plane[]): boolean;
  77795. /**
  77796. * Sets the mesh material by the material or multiMaterial `id` property
  77797. * @param id is a string identifying the material or the multiMaterial
  77798. * @returns the current mesh
  77799. */
  77800. setMaterialByID(id: string): Mesh;
  77801. /**
  77802. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77803. * @returns an array of IAnimatable
  77804. */
  77805. getAnimatables(): IAnimatable[];
  77806. /**
  77807. * Modifies the mesh geometry according to the passed transformation matrix.
  77808. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77809. * The mesh normals are modified using the same transformation.
  77810. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77811. * @param transform defines the transform matrix to use
  77812. * @see http://doc.babylonjs.com/resources/baking_transformations
  77813. * @returns the current mesh
  77814. */
  77815. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77816. /**
  77817. * Modifies the mesh geometry according to its own current World Matrix.
  77818. * The mesh World Matrix is then reset.
  77819. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77820. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77821. * @see http://doc.babylonjs.com/resources/baking_transformations
  77822. * @returns the current mesh
  77823. */
  77824. bakeCurrentTransformIntoVertices(): Mesh;
  77825. /** @hidden */
  77826. readonly _positions: Nullable<Vector3[]>;
  77827. /** @hidden */
  77828. _resetPointsArrayCache(): Mesh;
  77829. /** @hidden */
  77830. _generatePointsArray(): boolean;
  77831. /**
  77832. * Returns a new Mesh object generated from the current mesh properties.
  77833. * This method must not get confused with createInstance()
  77834. * @param name is a string, the name given to the new mesh
  77835. * @param newParent can be any Node object (default `null`)
  77836. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77837. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77838. * @returns a new mesh
  77839. */
  77840. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77841. /**
  77842. * Releases resources associated with this mesh.
  77843. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77844. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77845. */
  77846. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77847. /**
  77848. * Modifies the mesh geometry according to a displacement map.
  77849. * 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.
  77850. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77851. * @param url is a string, the URL from the image file is to be downloaded.
  77852. * @param minHeight is the lower limit of the displacement.
  77853. * @param maxHeight is the upper limit of the displacement.
  77854. * @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.
  77855. * @param uvOffset is an optional vector2 used to offset UV.
  77856. * @param uvScale is an optional vector2 used to scale UV.
  77857. * @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.
  77858. * @returns the Mesh.
  77859. */
  77860. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77861. /**
  77862. * Modifies the mesh geometry according to a displacementMap buffer.
  77863. * 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.
  77864. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77865. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77866. * @param heightMapWidth is the width of the buffer image.
  77867. * @param heightMapHeight is the height of the buffer image.
  77868. * @param minHeight is the lower limit of the displacement.
  77869. * @param maxHeight is the upper limit of the displacement.
  77870. * @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.
  77871. * @param uvOffset is an optional vector2 used to offset UV.
  77872. * @param uvScale is an optional vector2 used to scale UV.
  77873. * @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.
  77874. * @returns the Mesh.
  77875. */
  77876. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77877. /**
  77878. * Modify the mesh to get a flat shading rendering.
  77879. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77880. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77881. * @returns current mesh
  77882. */
  77883. convertToFlatShadedMesh(): Mesh;
  77884. /**
  77885. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77886. * In other words, more vertices, no more indices and a single bigger VBO.
  77887. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77888. * @returns current mesh
  77889. */
  77890. convertToUnIndexedMesh(): Mesh;
  77891. /**
  77892. * Inverses facet orientations.
  77893. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77894. * @param flipNormals will also inverts the normals
  77895. * @returns current mesh
  77896. */
  77897. flipFaces(flipNormals?: boolean): Mesh;
  77898. /** @hidden */
  77899. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77900. /** @hidden */
  77901. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77902. /**
  77903. * Creates a new InstancedMesh object from the mesh model.
  77904. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77905. * @param name defines the name of the new instance
  77906. * @returns a new InstancedMesh
  77907. */
  77908. createInstance(name: string): InstancedMesh;
  77909. /**
  77910. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77911. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77912. * @returns the current mesh
  77913. */
  77914. synchronizeInstances(): Mesh;
  77915. /**
  77916. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77917. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77918. * This should be used together with the simplification to avoid disappearing triangles.
  77919. * @param successCallback an optional success callback to be called after the optimization finished.
  77920. * @returns the current mesh
  77921. */
  77922. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77923. /**
  77924. * Serialize current mesh
  77925. * @param serializationObject defines the object which will receive the serialization data
  77926. */
  77927. serialize(serializationObject: any): void;
  77928. /** @hidden */
  77929. _syncGeometryWithMorphTargetManager(): void;
  77930. /** @hidden */
  77931. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77932. /**
  77933. * Returns a new Mesh object parsed from the source provided.
  77934. * @param parsedMesh is the source
  77935. * @param scene defines the hosting scene
  77936. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77937. * @returns a new Mesh
  77938. */
  77939. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77940. /**
  77941. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77942. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77943. * @param name defines the name of the mesh to create
  77944. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77945. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77946. * @param closePath creates a seam between the first and the last points of each path of the path array
  77947. * @param offset is taken in account only if the `pathArray` is containing a single path
  77948. * @param scene defines the hosting scene
  77949. * @param updatable defines if the mesh must be flagged as updatable
  77950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77951. * @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)
  77952. * @returns a new Mesh
  77953. */
  77954. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77955. /**
  77956. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77957. * @param name defines the name of the mesh to create
  77958. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77959. * @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
  77960. * @param scene defines the hosting scene
  77961. * @param updatable defines if the mesh must be flagged as updatable
  77962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77963. * @returns a new Mesh
  77964. */
  77965. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77966. /**
  77967. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77968. * @param name defines the name of the mesh to create
  77969. * @param size sets the size (float) of each box side (default 1)
  77970. * @param scene defines the hosting scene
  77971. * @param updatable defines if the mesh must be flagged as updatable
  77972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77973. * @returns a new Mesh
  77974. */
  77975. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77976. /**
  77977. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77978. * @param name defines the name of the mesh to create
  77979. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77980. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77981. * @param scene defines the hosting scene
  77982. * @param updatable defines if the mesh must be flagged as updatable
  77983. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77984. * @returns a new Mesh
  77985. */
  77986. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77987. /**
  77988. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77989. * @param name defines the name of the mesh to create
  77990. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77991. * @param diameterTop set the top cap diameter (floats, default 1)
  77992. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77993. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77994. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77995. * @param scene defines the hosting scene
  77996. * @param updatable defines if the mesh must be flagged as updatable
  77997. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77998. * @returns a new Mesh
  77999. */
  78000. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78001. /**
  78002. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78003. * @param name defines the name of the mesh to create
  78004. * @param diameter sets the diameter size (float) of the torus (default 1)
  78005. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78006. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78007. * @param scene defines the hosting scene
  78008. * @param updatable defines if the mesh must be flagged as updatable
  78009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78010. * @returns a new Mesh
  78011. */
  78012. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78013. /**
  78014. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78015. * @param name defines the name of the mesh to create
  78016. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78017. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78018. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78019. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78020. * @param p the number of windings on X axis (positive integers, default 2)
  78021. * @param q the number of windings on Y axis (positive integers, default 3)
  78022. * @param scene defines the hosting scene
  78023. * @param updatable defines if the mesh must be flagged as updatable
  78024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78025. * @returns a new Mesh
  78026. */
  78027. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78028. /**
  78029. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78030. * @param name defines the name of the mesh to create
  78031. * @param points is an array successive Vector3
  78032. * @param scene defines the hosting scene
  78033. * @param updatable defines if the mesh must be flagged as updatable
  78034. * @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).
  78035. * @returns a new Mesh
  78036. */
  78037. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78038. /**
  78039. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78040. * @param name defines the name of the mesh to create
  78041. * @param points is an array successive Vector3
  78042. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78043. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78044. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78045. * @param scene defines the hosting scene
  78046. * @param updatable defines if the mesh must be flagged as updatable
  78047. * @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)
  78048. * @returns a new Mesh
  78049. */
  78050. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78051. /**
  78052. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78053. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78054. * 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.
  78055. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78056. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78057. * Remember you can only change the shape positions, not their number when updating a polygon.
  78058. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78059. * @param name defines the name of the mesh to create
  78060. * @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
  78061. * @param scene defines the hosting scene
  78062. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78063. * @param updatable defines if the mesh must be flagged as updatable
  78064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78065. * @param earcutInjection can be used to inject your own earcut reference
  78066. * @returns a new Mesh
  78067. */
  78068. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78069. /**
  78070. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78071. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78072. * @param name defines the name of the mesh to create
  78073. * @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
  78074. * @param depth defines the height of extrusion
  78075. * @param scene defines the hosting scene
  78076. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78077. * @param updatable defines if the mesh must be flagged as updatable
  78078. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78079. * @param earcutInjection can be used to inject your own earcut reference
  78080. * @returns a new Mesh
  78081. */
  78082. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78083. /**
  78084. * Creates an extruded shape mesh.
  78085. * 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
  78086. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78087. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78088. * @param name defines the name of the mesh to create
  78089. * @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
  78090. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78091. * @param scale is the value to scale the shape
  78092. * @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
  78093. * @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
  78094. * @param scene defines the hosting scene
  78095. * @param updatable defines if the mesh must be flagged as updatable
  78096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78097. * @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)
  78098. * @returns a new Mesh
  78099. */
  78100. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78101. /**
  78102. * Creates an custom extruded shape mesh.
  78103. * The custom extrusion is a parametric shape.
  78104. * It has no predefined shape. Its final shape will depend on the input parameters.
  78105. * Please consider using the same method from the MeshBuilder class instead
  78106. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78107. * @param name defines the name of the mesh to create
  78108. * @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
  78109. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78110. * @param scaleFunction is a custom Javascript function called on each path point
  78111. * @param rotationFunction is a custom Javascript function called on each path point
  78112. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78113. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78114. * @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
  78115. * @param scene defines the hosting scene
  78116. * @param updatable defines if the mesh must be flagged as updatable
  78117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78118. * @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)
  78119. * @returns a new Mesh
  78120. */
  78121. 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;
  78122. /**
  78123. * Creates lathe mesh.
  78124. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78125. * Please consider using the same method from the MeshBuilder class instead
  78126. * @param name defines the name of the mesh to create
  78127. * @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
  78128. * @param radius is the radius value of the lathe
  78129. * @param tessellation is the side number of the lathe.
  78130. * @param scene defines the hosting scene
  78131. * @param updatable defines if the mesh must be flagged as updatable
  78132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78133. * @returns a new Mesh
  78134. */
  78135. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78136. /**
  78137. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78138. * @param name defines the name of the mesh to create
  78139. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78140. * @param scene defines the hosting scene
  78141. * @param updatable defines if the mesh must be flagged as updatable
  78142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78143. * @returns a new Mesh
  78144. */
  78145. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78146. /**
  78147. * Creates a ground mesh.
  78148. * Please consider using the same method from the MeshBuilder class instead
  78149. * @param name defines the name of the mesh to create
  78150. * @param width set the width of the ground
  78151. * @param height set the height of the ground
  78152. * @param subdivisions sets the number of subdivisions per side
  78153. * @param scene defines the hosting scene
  78154. * @param updatable defines if the mesh must be flagged as updatable
  78155. * @returns a new Mesh
  78156. */
  78157. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78158. /**
  78159. * Creates a tiled ground mesh.
  78160. * Please consider using the same method from the MeshBuilder class instead
  78161. * @param name defines the name of the mesh to create
  78162. * @param xmin set the ground minimum X coordinate
  78163. * @param zmin set the ground minimum Y coordinate
  78164. * @param xmax set the ground maximum X coordinate
  78165. * @param zmax set the ground maximum Z coordinate
  78166. * @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
  78167. * @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
  78168. * @param scene defines the hosting scene
  78169. * @param updatable defines if the mesh must be flagged as updatable
  78170. * @returns a new Mesh
  78171. */
  78172. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78173. w: number;
  78174. h: number;
  78175. }, precision: {
  78176. w: number;
  78177. h: number;
  78178. }, scene: Scene, updatable?: boolean): Mesh;
  78179. /**
  78180. * Creates a ground mesh from a height map.
  78181. * Please consider using the same method from the MeshBuilder class instead
  78182. * @see http://doc.babylonjs.com/babylon101/height_map
  78183. * @param name defines the name of the mesh to create
  78184. * @param url sets the URL of the height map image resource
  78185. * @param width set the ground width size
  78186. * @param height set the ground height size
  78187. * @param subdivisions sets the number of subdivision per side
  78188. * @param minHeight is the minimum altitude on the ground
  78189. * @param maxHeight is the maximum altitude on the ground
  78190. * @param scene defines the hosting scene
  78191. * @param updatable defines if the mesh must be flagged as updatable
  78192. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78193. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78194. * @returns a new Mesh
  78195. */
  78196. 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;
  78197. /**
  78198. * Creates a tube mesh.
  78199. * The tube is a parametric shape.
  78200. * It has no predefined shape. Its final shape will depend on the input parameters.
  78201. * Please consider using the same method from the MeshBuilder class instead
  78202. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78203. * @param name defines the name of the mesh to create
  78204. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78205. * @param radius sets the tube radius size
  78206. * @param tessellation is the number of sides on the tubular surface
  78207. * @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
  78208. * @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
  78209. * @param scene defines the hosting scene
  78210. * @param updatable defines if the mesh must be flagged as updatable
  78211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78212. * @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)
  78213. * @returns a new Mesh
  78214. */
  78215. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78216. (i: number, distance: number): number;
  78217. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78218. /**
  78219. * Creates a polyhedron mesh.
  78220. * Please consider using the same method from the MeshBuilder class instead.
  78221. * * 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
  78222. * * The parameter `size` (positive float, default 1) sets the polygon size
  78223. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78224. * * 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`
  78225. * * 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
  78226. * * 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)`)
  78227. * * 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
  78228. * * 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
  78229. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78230. * * If you create a double-sided mesh, you can choose what parts of 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
  78231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78232. * @param name defines the name of the mesh to create
  78233. * @param options defines the options used to create the mesh
  78234. * @param scene defines the hosting scene
  78235. * @returns a new Mesh
  78236. */
  78237. static CreatePolyhedron(name: string, options: {
  78238. type?: number;
  78239. size?: number;
  78240. sizeX?: number;
  78241. sizeY?: number;
  78242. sizeZ?: number;
  78243. custom?: any;
  78244. faceUV?: Vector4[];
  78245. faceColors?: Color4[];
  78246. updatable?: boolean;
  78247. sideOrientation?: number;
  78248. }, scene: Scene): Mesh;
  78249. /**
  78250. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78251. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78252. * * 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`)
  78253. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78254. * * 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
  78255. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78256. * * If you create a double-sided mesh, you can choose what parts of 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
  78257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78258. * @param name defines the name of the mesh
  78259. * @param options defines the options used to create the mesh
  78260. * @param scene defines the hosting scene
  78261. * @returns a new Mesh
  78262. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78263. */
  78264. static CreateIcoSphere(name: string, options: {
  78265. radius?: number;
  78266. flat?: boolean;
  78267. subdivisions?: number;
  78268. sideOrientation?: number;
  78269. updatable?: boolean;
  78270. }, scene: Scene): Mesh;
  78271. /**
  78272. * Creates a decal mesh.
  78273. * Please consider using the same method from the MeshBuilder class instead.
  78274. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78275. * @param name defines the name of the mesh
  78276. * @param sourceMesh defines the mesh receiving the decal
  78277. * @param position sets the position of the decal in world coordinates
  78278. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78279. * @param size sets the decal scaling
  78280. * @param angle sets the angle to rotate the decal
  78281. * @returns a new Mesh
  78282. */
  78283. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78284. /**
  78285. * Prepare internal position array for software CPU skinning
  78286. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78287. */
  78288. setPositionsForCPUSkinning(): Float32Array;
  78289. /**
  78290. * Prepare internal normal array for software CPU skinning
  78291. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78292. */
  78293. setNormalsForCPUSkinning(): Float32Array;
  78294. /**
  78295. * Updates the vertex buffer by applying transformation from the bones
  78296. * @param skeleton defines the skeleton to apply to current mesh
  78297. * @returns the current mesh
  78298. */
  78299. applySkeleton(skeleton: Skeleton): Mesh;
  78300. /**
  78301. * 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
  78302. * @param meshes defines the list of meshes to scan
  78303. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78304. */
  78305. static MinMax(meshes: AbstractMesh[]): {
  78306. min: Vector3;
  78307. max: Vector3;
  78308. };
  78309. /**
  78310. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78311. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78312. * @returns a vector3
  78313. */
  78314. static Center(meshesOrMinMaxVector: {
  78315. min: Vector3;
  78316. max: Vector3;
  78317. } | AbstractMesh[]): Vector3;
  78318. /**
  78319. * Merge the array of meshes into a single mesh for performance reasons.
  78320. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78321. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78322. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78323. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78324. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78325. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78326. * @returns a new mesh
  78327. */
  78328. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78329. /** @hidden */
  78330. addInstance(instance: InstancedMesh): void;
  78331. /** @hidden */
  78332. removeInstance(instance: InstancedMesh): void;
  78333. }
  78334. }
  78335. declare module BABYLON {
  78336. /**
  78337. * Base class for the main features of a material in Babylon.js
  78338. */
  78339. export class Material implements IAnimatable {
  78340. /**
  78341. * Returns the triangle fill mode
  78342. */
  78343. static readonly TriangleFillMode: number;
  78344. /**
  78345. * Returns the wireframe mode
  78346. */
  78347. static readonly WireFrameFillMode: number;
  78348. /**
  78349. * Returns the point fill mode
  78350. */
  78351. static readonly PointFillMode: number;
  78352. /**
  78353. * Returns the point list draw mode
  78354. */
  78355. static readonly PointListDrawMode: number;
  78356. /**
  78357. * Returns the line list draw mode
  78358. */
  78359. static readonly LineListDrawMode: number;
  78360. /**
  78361. * Returns the line loop draw mode
  78362. */
  78363. static readonly LineLoopDrawMode: number;
  78364. /**
  78365. * Returns the line strip draw mode
  78366. */
  78367. static readonly LineStripDrawMode: number;
  78368. /**
  78369. * Returns the triangle strip draw mode
  78370. */
  78371. static readonly TriangleStripDrawMode: number;
  78372. /**
  78373. * Returns the triangle fan draw mode
  78374. */
  78375. static readonly TriangleFanDrawMode: number;
  78376. /**
  78377. * Stores the clock-wise side orientation
  78378. */
  78379. static readonly ClockWiseSideOrientation: number;
  78380. /**
  78381. * Stores the counter clock-wise side orientation
  78382. */
  78383. static readonly CounterClockWiseSideOrientation: number;
  78384. /**
  78385. * The dirty texture flag value
  78386. */
  78387. static readonly TextureDirtyFlag: number;
  78388. /**
  78389. * The dirty light flag value
  78390. */
  78391. static readonly LightDirtyFlag: number;
  78392. /**
  78393. * The dirty fresnel flag value
  78394. */
  78395. static readonly FresnelDirtyFlag: number;
  78396. /**
  78397. * The dirty attribute flag value
  78398. */
  78399. static readonly AttributesDirtyFlag: number;
  78400. /**
  78401. * The dirty misc flag value
  78402. */
  78403. static readonly MiscDirtyFlag: number;
  78404. /**
  78405. * The all dirty flag value
  78406. */
  78407. static readonly AllDirtyFlag: number;
  78408. /**
  78409. * The ID of the material
  78410. */
  78411. id: string;
  78412. /**
  78413. * Gets or sets the unique id of the material
  78414. */
  78415. uniqueId: number;
  78416. /**
  78417. * The name of the material
  78418. */
  78419. name: string;
  78420. /**
  78421. * Gets or sets user defined metadata
  78422. */
  78423. metadata: any;
  78424. /**
  78425. * For internal use only. Please do not use.
  78426. */
  78427. reservedDataStore: any;
  78428. /**
  78429. * Specifies if the ready state should be checked on each call
  78430. */
  78431. checkReadyOnEveryCall: boolean;
  78432. /**
  78433. * Specifies if the ready state should be checked once
  78434. */
  78435. checkReadyOnlyOnce: boolean;
  78436. /**
  78437. * The state of the material
  78438. */
  78439. state: string;
  78440. /**
  78441. * The alpha value of the material
  78442. */
  78443. protected _alpha: number;
  78444. /**
  78445. * Sets the alpha value of the material
  78446. */
  78447. /**
  78448. * Gets the alpha value of the material
  78449. */
  78450. alpha: number;
  78451. /**
  78452. * Specifies if back face culling is enabled
  78453. */
  78454. protected _backFaceCulling: boolean;
  78455. /**
  78456. * Sets the back-face culling state
  78457. */
  78458. /**
  78459. * Gets the back-face culling state
  78460. */
  78461. backFaceCulling: boolean;
  78462. /**
  78463. * Stores the value for side orientation
  78464. */
  78465. sideOrientation: number;
  78466. /**
  78467. * Callback triggered when the material is compiled
  78468. */
  78469. onCompiled: (effect: Effect) => void;
  78470. /**
  78471. * Callback triggered when an error occurs
  78472. */
  78473. onError: (effect: Effect, errors: string) => void;
  78474. /**
  78475. * Callback triggered to get the render target textures
  78476. */
  78477. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78478. /**
  78479. * Gets a boolean indicating that current material needs to register RTT
  78480. */
  78481. readonly hasRenderTargetTextures: boolean;
  78482. /**
  78483. * Specifies if the material should be serialized
  78484. */
  78485. doNotSerialize: boolean;
  78486. /**
  78487. * @hidden
  78488. */
  78489. _storeEffectOnSubMeshes: boolean;
  78490. /**
  78491. * Stores the animations for the material
  78492. */
  78493. animations: Array<Animation>;
  78494. /**
  78495. * An event triggered when the material is disposed
  78496. */
  78497. onDisposeObservable: Observable<Material>;
  78498. /**
  78499. * An observer which watches for dispose events
  78500. */
  78501. private _onDisposeObserver;
  78502. private _onUnBindObservable;
  78503. /**
  78504. * Called during a dispose event
  78505. */
  78506. onDispose: () => void;
  78507. private _onBindObservable;
  78508. /**
  78509. * An event triggered when the material is bound
  78510. */
  78511. readonly onBindObservable: Observable<AbstractMesh>;
  78512. /**
  78513. * An observer which watches for bind events
  78514. */
  78515. private _onBindObserver;
  78516. /**
  78517. * Called during a bind event
  78518. */
  78519. onBind: (Mesh: AbstractMesh) => void;
  78520. /**
  78521. * An event triggered when the material is unbound
  78522. */
  78523. readonly onUnBindObservable: Observable<Material>;
  78524. /**
  78525. * Stores the value of the alpha mode
  78526. */
  78527. private _alphaMode;
  78528. /**
  78529. * Sets the value of the alpha mode.
  78530. *
  78531. * | Value | Type | Description |
  78532. * | --- | --- | --- |
  78533. * | 0 | ALPHA_DISABLE | |
  78534. * | 1 | ALPHA_ADD | |
  78535. * | 2 | ALPHA_COMBINE | |
  78536. * | 3 | ALPHA_SUBTRACT | |
  78537. * | 4 | ALPHA_MULTIPLY | |
  78538. * | 5 | ALPHA_MAXIMIZED | |
  78539. * | 6 | ALPHA_ONEONE | |
  78540. * | 7 | ALPHA_PREMULTIPLIED | |
  78541. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78542. * | 9 | ALPHA_INTERPOLATE | |
  78543. * | 10 | ALPHA_SCREENMODE | |
  78544. *
  78545. */
  78546. /**
  78547. * Gets the value of the alpha mode
  78548. */
  78549. alphaMode: number;
  78550. /**
  78551. * Stores the state of the need depth pre-pass value
  78552. */
  78553. private _needDepthPrePass;
  78554. /**
  78555. * Sets the need depth pre-pass value
  78556. */
  78557. /**
  78558. * Gets the depth pre-pass value
  78559. */
  78560. needDepthPrePass: boolean;
  78561. /**
  78562. * Specifies if depth writing should be disabled
  78563. */
  78564. disableDepthWrite: boolean;
  78565. /**
  78566. * Specifies if depth writing should be forced
  78567. */
  78568. forceDepthWrite: boolean;
  78569. /**
  78570. * Specifies if there should be a separate pass for culling
  78571. */
  78572. separateCullingPass: boolean;
  78573. /**
  78574. * Stores the state specifing if fog should be enabled
  78575. */
  78576. private _fogEnabled;
  78577. /**
  78578. * Sets the state for enabling fog
  78579. */
  78580. /**
  78581. * Gets the value of the fog enabled state
  78582. */
  78583. fogEnabled: boolean;
  78584. /**
  78585. * Stores the size of points
  78586. */
  78587. pointSize: number;
  78588. /**
  78589. * Stores the z offset value
  78590. */
  78591. zOffset: number;
  78592. /**
  78593. * Gets a value specifying if wireframe mode is enabled
  78594. */
  78595. /**
  78596. * Sets the state of wireframe mode
  78597. */
  78598. wireframe: boolean;
  78599. /**
  78600. * Gets the value specifying if point clouds are enabled
  78601. */
  78602. /**
  78603. * Sets the state of point cloud mode
  78604. */
  78605. pointsCloud: boolean;
  78606. /**
  78607. * Gets the material fill mode
  78608. */
  78609. /**
  78610. * Sets the material fill mode
  78611. */
  78612. fillMode: number;
  78613. /**
  78614. * @hidden
  78615. * Stores the effects for the material
  78616. */
  78617. _effect: Nullable<Effect>;
  78618. /**
  78619. * @hidden
  78620. * Specifies if the material was previously ready
  78621. */
  78622. _wasPreviouslyReady: boolean;
  78623. /**
  78624. * Specifies if uniform buffers should be used
  78625. */
  78626. private _useUBO;
  78627. /**
  78628. * Stores a reference to the scene
  78629. */
  78630. private _scene;
  78631. /**
  78632. * Stores the fill mode state
  78633. */
  78634. private _fillMode;
  78635. /**
  78636. * Specifies if the depth write state should be cached
  78637. */
  78638. private _cachedDepthWriteState;
  78639. /**
  78640. * Stores the uniform buffer
  78641. */
  78642. protected _uniformBuffer: UniformBuffer;
  78643. /** @hidden */
  78644. _indexInSceneMaterialArray: number;
  78645. /** @hidden */
  78646. meshMap: Nullable<{
  78647. [id: string]: AbstractMesh | undefined;
  78648. }>;
  78649. /**
  78650. * Creates a material instance
  78651. * @param name defines the name of the material
  78652. * @param scene defines the scene to reference
  78653. * @param doNotAdd specifies if the material should be added to the scene
  78654. */
  78655. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78656. /**
  78657. * Returns a string representation of the current material
  78658. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78659. * @returns a string with material information
  78660. */
  78661. toString(fullDetails?: boolean): string;
  78662. /**
  78663. * Gets the class name of the material
  78664. * @returns a string with the class name of the material
  78665. */
  78666. getClassName(): string;
  78667. /**
  78668. * Specifies if updates for the material been locked
  78669. */
  78670. readonly isFrozen: boolean;
  78671. /**
  78672. * Locks updates for the material
  78673. */
  78674. freeze(): void;
  78675. /**
  78676. * Unlocks updates for the material
  78677. */
  78678. unfreeze(): void;
  78679. /**
  78680. * Specifies if the material is ready to be used
  78681. * @param mesh defines the mesh to check
  78682. * @param useInstances specifies if instances should be used
  78683. * @returns a boolean indicating if the material is ready to be used
  78684. */
  78685. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78686. /**
  78687. * Specifies that the submesh is ready to be used
  78688. * @param mesh defines the mesh to check
  78689. * @param subMesh defines which submesh to check
  78690. * @param useInstances specifies that instances should be used
  78691. * @returns a boolean indicating that the submesh is ready or not
  78692. */
  78693. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78694. /**
  78695. * Returns the material effect
  78696. * @returns the effect associated with the material
  78697. */
  78698. getEffect(): Nullable<Effect>;
  78699. /**
  78700. * Returns the current scene
  78701. * @returns a Scene
  78702. */
  78703. getScene(): Scene;
  78704. /**
  78705. * Specifies if the material will require alpha blending
  78706. * @returns a boolean specifying if alpha blending is needed
  78707. */
  78708. needAlphaBlending(): boolean;
  78709. /**
  78710. * Specifies if the mesh will require alpha blending
  78711. * @param mesh defines the mesh to check
  78712. * @returns a boolean specifying if alpha blending is needed for the mesh
  78713. */
  78714. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78715. /**
  78716. * Specifies if this material should be rendered in alpha test mode
  78717. * @returns a boolean specifying if an alpha test is needed.
  78718. */
  78719. needAlphaTesting(): boolean;
  78720. /**
  78721. * Gets the texture used for the alpha test
  78722. * @returns the texture to use for alpha testing
  78723. */
  78724. getAlphaTestTexture(): Nullable<BaseTexture>;
  78725. /**
  78726. * Marks the material to indicate that it needs to be re-calculated
  78727. */
  78728. markDirty(): void;
  78729. /** @hidden */
  78730. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  78731. /**
  78732. * Binds the material to the mesh
  78733. * @param world defines the world transformation matrix
  78734. * @param mesh defines the mesh to bind the material to
  78735. */
  78736. bind(world: Matrix, mesh?: Mesh): void;
  78737. /**
  78738. * Binds the submesh to the material
  78739. * @param world defines the world transformation matrix
  78740. * @param mesh defines the mesh containing the submesh
  78741. * @param subMesh defines the submesh to bind the material to
  78742. */
  78743. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  78744. /**
  78745. * Binds the world matrix to the material
  78746. * @param world defines the world transformation matrix
  78747. */
  78748. bindOnlyWorldMatrix(world: Matrix): void;
  78749. /**
  78750. * Binds the scene's uniform buffer to the effect.
  78751. * @param effect defines the effect to bind to the scene uniform buffer
  78752. * @param sceneUbo defines the uniform buffer storing scene data
  78753. */
  78754. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  78755. /**
  78756. * Binds the view matrix to the effect
  78757. * @param effect defines the effect to bind the view matrix to
  78758. */
  78759. bindView(effect: Effect): void;
  78760. /**
  78761. * Binds the view projection matrix to the effect
  78762. * @param effect defines the effect to bind the view projection matrix to
  78763. */
  78764. bindViewProjection(effect: Effect): void;
  78765. /**
  78766. * Specifies if material alpha testing should be turned on for the mesh
  78767. * @param mesh defines the mesh to check
  78768. */
  78769. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  78770. /**
  78771. * Processes to execute after binding the material to a mesh
  78772. * @param mesh defines the rendered mesh
  78773. */
  78774. protected _afterBind(mesh?: Mesh): void;
  78775. /**
  78776. * Unbinds the material from the mesh
  78777. */
  78778. unbind(): void;
  78779. /**
  78780. * Gets the active textures from the material
  78781. * @returns an array of textures
  78782. */
  78783. getActiveTextures(): BaseTexture[];
  78784. /**
  78785. * Specifies if the material uses a texture
  78786. * @param texture defines the texture to check against the material
  78787. * @returns a boolean specifying if the material uses the texture
  78788. */
  78789. hasTexture(texture: BaseTexture): boolean;
  78790. /**
  78791. * Makes a duplicate of the material, and gives it a new name
  78792. * @param name defines the new name for the duplicated material
  78793. * @returns the cloned material
  78794. */
  78795. clone(name: string): Nullable<Material>;
  78796. /**
  78797. * Gets the meshes bound to the material
  78798. * @returns an array of meshes bound to the material
  78799. */
  78800. getBindedMeshes(): AbstractMesh[];
  78801. /**
  78802. * Force shader compilation
  78803. * @param mesh defines the mesh associated with this material
  78804. * @param onCompiled defines a function to execute once the material is compiled
  78805. * @param options defines the options to configure the compilation
  78806. */
  78807. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  78808. clipPlane: boolean;
  78809. }>): void;
  78810. /**
  78811. * Force shader compilation
  78812. * @param mesh defines the mesh that will use this material
  78813. * @param options defines additional options for compiling the shaders
  78814. * @returns a promise that resolves when the compilation completes
  78815. */
  78816. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  78817. clipPlane: boolean;
  78818. }>): Promise<void>;
  78819. private static readonly _ImageProcessingDirtyCallBack;
  78820. private static readonly _TextureDirtyCallBack;
  78821. private static readonly _FresnelDirtyCallBack;
  78822. private static readonly _MiscDirtyCallBack;
  78823. private static readonly _LightsDirtyCallBack;
  78824. private static readonly _AttributeDirtyCallBack;
  78825. private static _FresnelAndMiscDirtyCallBack;
  78826. private static _TextureAndMiscDirtyCallBack;
  78827. private static readonly _DirtyCallbackArray;
  78828. private static readonly _RunDirtyCallBacks;
  78829. /**
  78830. * Marks a define in the material to indicate that it needs to be re-computed
  78831. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  78832. */
  78833. markAsDirty(flag: number): void;
  78834. /**
  78835. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  78836. * @param func defines a function which checks material defines against the submeshes
  78837. */
  78838. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  78839. /**
  78840. * Indicates that image processing needs to be re-calculated for all submeshes
  78841. */
  78842. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  78843. /**
  78844. * Indicates that textures need to be re-calculated for all submeshes
  78845. */
  78846. protected _markAllSubMeshesAsTexturesDirty(): void;
  78847. /**
  78848. * Indicates that fresnel needs to be re-calculated for all submeshes
  78849. */
  78850. protected _markAllSubMeshesAsFresnelDirty(): void;
  78851. /**
  78852. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  78853. */
  78854. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  78855. /**
  78856. * Indicates that lights need to be re-calculated for all submeshes
  78857. */
  78858. protected _markAllSubMeshesAsLightsDirty(): void;
  78859. /**
  78860. * Indicates that attributes need to be re-calculated for all submeshes
  78861. */
  78862. protected _markAllSubMeshesAsAttributesDirty(): void;
  78863. /**
  78864. * Indicates that misc needs to be re-calculated for all submeshes
  78865. */
  78866. protected _markAllSubMeshesAsMiscDirty(): void;
  78867. /**
  78868. * Indicates that textures and misc need to be re-calculated for all submeshes
  78869. */
  78870. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  78871. /**
  78872. * Disposes the material
  78873. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78874. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  78875. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  78876. */
  78877. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  78878. /** @hidden */
  78879. private releaseVertexArrayObject;
  78880. /**
  78881. * Serializes this material
  78882. * @returns the serialized material object
  78883. */
  78884. serialize(): any;
  78885. /**
  78886. * Creates a material from parsed material data
  78887. * @param parsedMaterial defines parsed material data
  78888. * @param scene defines the hosting scene
  78889. * @param rootUrl defines the root URL to use to load textures
  78890. * @returns a new material
  78891. */
  78892. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  78893. }
  78894. }
  78895. declare module BABYLON {
  78896. /**
  78897. * Base class for submeshes
  78898. */
  78899. export class BaseSubMesh {
  78900. /** @hidden */
  78901. _materialDefines: Nullable<MaterialDefines>;
  78902. /** @hidden */
  78903. _materialEffect: Nullable<Effect>;
  78904. /**
  78905. * Gets associated effect
  78906. */
  78907. readonly effect: Nullable<Effect>;
  78908. /**
  78909. * Sets associated effect (effect used to render this submesh)
  78910. * @param effect defines the effect to associate with
  78911. * @param defines defines the set of defines used to compile this effect
  78912. */
  78913. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  78914. }
  78915. /**
  78916. * Defines a subdivision inside a mesh
  78917. */
  78918. export class SubMesh extends BaseSubMesh implements ICullable {
  78919. /** the material index to use */
  78920. materialIndex: number;
  78921. /** vertex index start */
  78922. verticesStart: number;
  78923. /** vertices count */
  78924. verticesCount: number;
  78925. /** index start */
  78926. indexStart: number;
  78927. /** indices count */
  78928. indexCount: number;
  78929. /** @hidden */
  78930. _linesIndexCount: number;
  78931. private _mesh;
  78932. private _renderingMesh;
  78933. private _boundingInfo;
  78934. private _linesIndexBuffer;
  78935. /** @hidden */
  78936. _lastColliderWorldVertices: Nullable<Vector3[]>;
  78937. /** @hidden */
  78938. _trianglePlanes: Plane[];
  78939. /** @hidden */
  78940. _lastColliderTransformMatrix: Matrix;
  78941. /** @hidden */
  78942. _renderId: number;
  78943. /** @hidden */
  78944. _alphaIndex: number;
  78945. /** @hidden */
  78946. _distanceToCamera: number;
  78947. /** @hidden */
  78948. _id: number;
  78949. private _currentMaterial;
  78950. /**
  78951. * Add a new submesh to a mesh
  78952. * @param materialIndex defines the material index to use
  78953. * @param verticesStart defines vertex index start
  78954. * @param verticesCount defines vertices count
  78955. * @param indexStart defines index start
  78956. * @param indexCount defines indices count
  78957. * @param mesh defines the parent mesh
  78958. * @param renderingMesh defines an optional rendering mesh
  78959. * @param createBoundingBox defines if bounding box should be created for this submesh
  78960. * @returns the new submesh
  78961. */
  78962. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  78963. /**
  78964. * Creates a new submesh
  78965. * @param materialIndex defines the material index to use
  78966. * @param verticesStart defines vertex index start
  78967. * @param verticesCount defines vertices count
  78968. * @param indexStart defines index start
  78969. * @param indexCount defines indices count
  78970. * @param mesh defines the parent mesh
  78971. * @param renderingMesh defines an optional rendering mesh
  78972. * @param createBoundingBox defines if bounding box should be created for this submesh
  78973. */
  78974. constructor(
  78975. /** the material index to use */
  78976. materialIndex: number,
  78977. /** vertex index start */
  78978. verticesStart: number,
  78979. /** vertices count */
  78980. verticesCount: number,
  78981. /** index start */
  78982. indexStart: number,
  78983. /** indices count */
  78984. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  78985. /**
  78986. * Returns true if this submesh covers the entire parent mesh
  78987. * @ignorenaming
  78988. */
  78989. readonly IsGlobal: boolean;
  78990. /**
  78991. * Returns the submesh BoudingInfo object
  78992. * @returns current bounding info (or mesh's one if the submesh is global)
  78993. */
  78994. getBoundingInfo(): BoundingInfo;
  78995. /**
  78996. * Sets the submesh BoundingInfo
  78997. * @param boundingInfo defines the new bounding info to use
  78998. * @returns the SubMesh
  78999. */
  79000. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79001. /**
  79002. * Returns the mesh of the current submesh
  79003. * @return the parent mesh
  79004. */
  79005. getMesh(): AbstractMesh;
  79006. /**
  79007. * Returns the rendering mesh of the submesh
  79008. * @returns the rendering mesh (could be different from parent mesh)
  79009. */
  79010. getRenderingMesh(): Mesh;
  79011. /**
  79012. * Returns the submesh material
  79013. * @returns null or the current material
  79014. */
  79015. getMaterial(): Nullable<Material>;
  79016. /**
  79017. * Sets a new updated BoundingInfo object to the submesh
  79018. * @returns the SubMesh
  79019. */
  79020. refreshBoundingInfo(): SubMesh;
  79021. /** @hidden */
  79022. _checkCollision(collider: Collider): boolean;
  79023. /**
  79024. * Updates the submesh BoundingInfo
  79025. * @param world defines the world matrix to use to update the bounding info
  79026. * @returns the submesh
  79027. */
  79028. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79029. /**
  79030. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79031. * @param frustumPlanes defines the frustum planes
  79032. * @returns true if the submesh is intersecting with the frustum
  79033. */
  79034. isInFrustum(frustumPlanes: Plane[]): boolean;
  79035. /**
  79036. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79037. * @param frustumPlanes defines the frustum planes
  79038. * @returns true if the submesh is inside the frustum
  79039. */
  79040. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79041. /**
  79042. * Renders the submesh
  79043. * @param enableAlphaMode defines if alpha needs to be used
  79044. * @returns the submesh
  79045. */
  79046. render(enableAlphaMode: boolean): SubMesh;
  79047. /**
  79048. * @hidden
  79049. */
  79050. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79051. /**
  79052. * Checks if the submesh intersects with a ray
  79053. * @param ray defines the ray to test
  79054. * @returns true is the passed ray intersects the submesh bounding box
  79055. */
  79056. canIntersects(ray: Ray): boolean;
  79057. /**
  79058. * Intersects current submesh with a ray
  79059. * @param ray defines the ray to test
  79060. * @param positions defines mesh's positions array
  79061. * @param indices defines mesh's indices array
  79062. * @param fastCheck defines if only bounding info should be used
  79063. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79064. * @returns intersection info or null if no intersection
  79065. */
  79066. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79067. /** @hidden */
  79068. private _intersectLines;
  79069. /** @hidden */
  79070. private _intersectTriangles;
  79071. /** @hidden */
  79072. _rebuild(): void;
  79073. /**
  79074. * Creates a new submesh from the passed mesh
  79075. * @param newMesh defines the new hosting mesh
  79076. * @param newRenderingMesh defines an optional rendering mesh
  79077. * @returns the new submesh
  79078. */
  79079. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79080. /**
  79081. * Release associated resources
  79082. */
  79083. dispose(): void;
  79084. /**
  79085. * Gets the class name
  79086. * @returns the string "SubMesh".
  79087. */
  79088. getClassName(): string;
  79089. /**
  79090. * Creates a new submesh from indices data
  79091. * @param materialIndex the index of the main mesh material
  79092. * @param startIndex the index where to start the copy in the mesh indices array
  79093. * @param indexCount the number of indices to copy then from the startIndex
  79094. * @param mesh the main mesh to create the submesh from
  79095. * @param renderingMesh the optional rendering mesh
  79096. * @returns a new submesh
  79097. */
  79098. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79099. }
  79100. }
  79101. declare module BABYLON {
  79102. /**
  79103. * Class used to store geometry data (vertex buffers + index buffer)
  79104. */
  79105. export class Geometry implements IGetSetVerticesData {
  79106. /**
  79107. * Gets or sets the ID of the geometry
  79108. */
  79109. id: string;
  79110. /**
  79111. * Gets or sets the unique ID of the geometry
  79112. */
  79113. uniqueId: number;
  79114. /**
  79115. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79116. */
  79117. delayLoadState: number;
  79118. /**
  79119. * Gets the file containing the data to load when running in delay load state
  79120. */
  79121. delayLoadingFile: Nullable<string>;
  79122. /**
  79123. * Callback called when the geometry is updated
  79124. */
  79125. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79126. private _scene;
  79127. private _engine;
  79128. private _meshes;
  79129. private _totalVertices;
  79130. /** @hidden */
  79131. _indices: IndicesArray;
  79132. /** @hidden */
  79133. _vertexBuffers: {
  79134. [key: string]: VertexBuffer;
  79135. };
  79136. private _isDisposed;
  79137. private _extend;
  79138. private _boundingBias;
  79139. /** @hidden */
  79140. _delayInfo: Array<string>;
  79141. private _indexBuffer;
  79142. private _indexBufferIsUpdatable;
  79143. /** @hidden */
  79144. _boundingInfo: Nullable<BoundingInfo>;
  79145. /** @hidden */
  79146. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79147. /** @hidden */
  79148. _softwareSkinningFrameId: number;
  79149. private _vertexArrayObjects;
  79150. private _updatable;
  79151. /** @hidden */
  79152. _positions: Nullable<Vector3[]>;
  79153. /**
  79154. * 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
  79155. */
  79156. /**
  79157. * 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
  79158. */
  79159. boundingBias: Vector2;
  79160. /**
  79161. * Static function used to attach a new empty geometry to a mesh
  79162. * @param mesh defines the mesh to attach the geometry to
  79163. * @returns the new Geometry
  79164. */
  79165. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79166. /**
  79167. * Creates a new geometry
  79168. * @param id defines the unique ID
  79169. * @param scene defines the hosting scene
  79170. * @param vertexData defines the VertexData used to get geometry data
  79171. * @param updatable defines if geometry must be updatable (false by default)
  79172. * @param mesh defines the mesh that will be associated with the geometry
  79173. */
  79174. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79175. /**
  79176. * Gets the current extend of the geometry
  79177. */
  79178. readonly extend: {
  79179. minimum: Vector3;
  79180. maximum: Vector3;
  79181. };
  79182. /**
  79183. * Gets the hosting scene
  79184. * @returns the hosting Scene
  79185. */
  79186. getScene(): Scene;
  79187. /**
  79188. * Gets the hosting engine
  79189. * @returns the hosting Engine
  79190. */
  79191. getEngine(): Engine;
  79192. /**
  79193. * Defines if the geometry is ready to use
  79194. * @returns true if the geometry is ready to be used
  79195. */
  79196. isReady(): boolean;
  79197. /**
  79198. * Gets a value indicating that the geometry should not be serialized
  79199. */
  79200. readonly doNotSerialize: boolean;
  79201. /** @hidden */
  79202. _rebuild(): void;
  79203. /**
  79204. * Affects all geometry data in one call
  79205. * @param vertexData defines the geometry data
  79206. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79207. */
  79208. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79209. /**
  79210. * Set specific vertex data
  79211. * @param kind defines the data kind (Position, normal, etc...)
  79212. * @param data defines the vertex data to use
  79213. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79214. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79215. */
  79216. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79217. /**
  79218. * Removes a specific vertex data
  79219. * @param kind defines the data kind (Position, normal, etc...)
  79220. */
  79221. removeVerticesData(kind: string): void;
  79222. /**
  79223. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79224. * @param buffer defines the vertex buffer to use
  79225. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79226. */
  79227. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79228. /**
  79229. * Update a specific vertex buffer
  79230. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79231. * It will do nothing if the buffer is not updatable
  79232. * @param kind defines the data kind (Position, normal, etc...)
  79233. * @param data defines the data to use
  79234. * @param offset defines the offset in the target buffer where to store the data
  79235. * @param useBytes set to true if the offset is in bytes
  79236. */
  79237. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79238. /**
  79239. * Update a specific vertex buffer
  79240. * This function will create a new buffer if the current one is not updatable
  79241. * @param kind defines the data kind (Position, normal, etc...)
  79242. * @param data defines the data to use
  79243. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79244. */
  79245. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79246. private _updateBoundingInfo;
  79247. /** @hidden */
  79248. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79249. /**
  79250. * Gets total number of vertices
  79251. * @returns the total number of vertices
  79252. */
  79253. getTotalVertices(): number;
  79254. /**
  79255. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79256. * @param kind defines the data kind (Position, normal, etc...)
  79257. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79258. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79259. * @returns a float array containing vertex data
  79260. */
  79261. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79262. /**
  79263. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79264. * @param kind defines the data kind (Position, normal, etc...)
  79265. * @returns true if the vertex buffer with the specified kind is updatable
  79266. */
  79267. isVertexBufferUpdatable(kind: string): boolean;
  79268. /**
  79269. * Gets a specific vertex buffer
  79270. * @param kind defines the data kind (Position, normal, etc...)
  79271. * @returns a VertexBuffer
  79272. */
  79273. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79274. /**
  79275. * Returns all vertex buffers
  79276. * @return an object holding all vertex buffers indexed by kind
  79277. */
  79278. getVertexBuffers(): Nullable<{
  79279. [key: string]: VertexBuffer;
  79280. }>;
  79281. /**
  79282. * Gets a boolean indicating if specific vertex buffer is present
  79283. * @param kind defines the data kind (Position, normal, etc...)
  79284. * @returns true if data is present
  79285. */
  79286. isVerticesDataPresent(kind: string): boolean;
  79287. /**
  79288. * Gets a list of all attached data kinds (Position, normal, etc...)
  79289. * @returns a list of string containing all kinds
  79290. */
  79291. getVerticesDataKinds(): string[];
  79292. /**
  79293. * Update index buffer
  79294. * @param indices defines the indices to store in the index buffer
  79295. * @param offset defines the offset in the target buffer where to store the data
  79296. */
  79297. updateIndices(indices: IndicesArray, offset?: number): void;
  79298. /**
  79299. * Creates a new index buffer
  79300. * @param indices defines the indices to store in the index buffer
  79301. * @param totalVertices defines the total number of vertices (could be null)
  79302. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79303. */
  79304. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79305. /**
  79306. * Return the total number of indices
  79307. * @returns the total number of indices
  79308. */
  79309. getTotalIndices(): number;
  79310. /**
  79311. * Gets the index buffer array
  79312. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79313. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79314. * @returns the index buffer array
  79315. */
  79316. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79317. /**
  79318. * Gets the index buffer
  79319. * @return the index buffer
  79320. */
  79321. getIndexBuffer(): Nullable<WebGLBuffer>;
  79322. /** @hidden */
  79323. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79324. /**
  79325. * Release the associated resources for a specific mesh
  79326. * @param mesh defines the source mesh
  79327. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79328. */
  79329. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79330. /**
  79331. * Apply current geometry to a given mesh
  79332. * @param mesh defines the mesh to apply geometry to
  79333. */
  79334. applyToMesh(mesh: Mesh): void;
  79335. private _updateExtend;
  79336. private _applyToMesh;
  79337. private notifyUpdate;
  79338. /**
  79339. * Load the geometry if it was flagged as delay loaded
  79340. * @param scene defines the hosting scene
  79341. * @param onLoaded defines a callback called when the geometry is loaded
  79342. */
  79343. load(scene: Scene, onLoaded?: () => void): void;
  79344. private _queueLoad;
  79345. /**
  79346. * Invert the geometry to move from a right handed system to a left handed one.
  79347. */
  79348. toLeftHanded(): void;
  79349. /** @hidden */
  79350. _resetPointsArrayCache(): void;
  79351. /** @hidden */
  79352. _generatePointsArray(): boolean;
  79353. /**
  79354. * Gets a value indicating if the geometry is disposed
  79355. * @returns true if the geometry was disposed
  79356. */
  79357. isDisposed(): boolean;
  79358. private _disposeVertexArrayObjects;
  79359. /**
  79360. * Free all associated resources
  79361. */
  79362. dispose(): void;
  79363. /**
  79364. * Clone the current geometry into a new geometry
  79365. * @param id defines the unique ID of the new geometry
  79366. * @returns a new geometry object
  79367. */
  79368. copy(id: string): Geometry;
  79369. /**
  79370. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79371. * @return a JSON representation of the current geometry data (without the vertices data)
  79372. */
  79373. serialize(): any;
  79374. private toNumberArray;
  79375. /**
  79376. * Serialize all vertices data into a JSON oject
  79377. * @returns a JSON representation of the current geometry data
  79378. */
  79379. serializeVerticeData(): any;
  79380. /**
  79381. * Extracts a clone of a mesh geometry
  79382. * @param mesh defines the source mesh
  79383. * @param id defines the unique ID of the new geometry object
  79384. * @returns the new geometry object
  79385. */
  79386. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79387. /**
  79388. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79389. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79390. * Be aware Math.random() could cause collisions, but:
  79391. * "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"
  79392. * @returns a string containing a new GUID
  79393. */
  79394. static RandomId(): string;
  79395. /** @hidden */
  79396. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79397. private static _CleanMatricesWeights;
  79398. /**
  79399. * Create a new geometry from persisted data (Using .babylon file format)
  79400. * @param parsedVertexData defines the persisted data
  79401. * @param scene defines the hosting scene
  79402. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79403. * @returns the new geometry object
  79404. */
  79405. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79406. }
  79407. }
  79408. declare module BABYLON {
  79409. /**
  79410. * Define an interface for all classes that will get and set the data on vertices
  79411. */
  79412. export interface IGetSetVerticesData {
  79413. /**
  79414. * Gets a boolean indicating if specific vertex data is present
  79415. * @param kind defines the vertex data kind to use
  79416. * @returns true is data kind is present
  79417. */
  79418. isVerticesDataPresent(kind: string): boolean;
  79419. /**
  79420. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79421. * @param kind defines the data kind (Position, normal, etc...)
  79422. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79423. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79424. * @returns a float array containing vertex data
  79425. */
  79426. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79427. /**
  79428. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79429. * @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.
  79430. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79431. * @returns the indices array or an empty array if the mesh has no geometry
  79432. */
  79433. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79434. /**
  79435. * Set specific vertex data
  79436. * @param kind defines the data kind (Position, normal, etc...)
  79437. * @param data defines the vertex data to use
  79438. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79439. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79440. */
  79441. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79442. /**
  79443. * Update a specific associated vertex buffer
  79444. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79445. * - VertexBuffer.PositionKind
  79446. * - VertexBuffer.UVKind
  79447. * - VertexBuffer.UV2Kind
  79448. * - VertexBuffer.UV3Kind
  79449. * - VertexBuffer.UV4Kind
  79450. * - VertexBuffer.UV5Kind
  79451. * - VertexBuffer.UV6Kind
  79452. * - VertexBuffer.ColorKind
  79453. * - VertexBuffer.MatricesIndicesKind
  79454. * - VertexBuffer.MatricesIndicesExtraKind
  79455. * - VertexBuffer.MatricesWeightsKind
  79456. * - VertexBuffer.MatricesWeightsExtraKind
  79457. * @param data defines the data source
  79458. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79459. * @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)
  79460. */
  79461. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79462. /**
  79463. * Creates a new index buffer
  79464. * @param indices defines the indices to store in the index buffer
  79465. * @param totalVertices defines the total number of vertices (could be null)
  79466. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79467. */
  79468. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79469. }
  79470. /**
  79471. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79472. */
  79473. export class VertexData {
  79474. /**
  79475. * Mesh side orientation : usually the external or front surface
  79476. */
  79477. static readonly FRONTSIDE: number;
  79478. /**
  79479. * Mesh side orientation : usually the internal or back surface
  79480. */
  79481. static readonly BACKSIDE: number;
  79482. /**
  79483. * Mesh side orientation : both internal and external or front and back surfaces
  79484. */
  79485. static readonly DOUBLESIDE: number;
  79486. /**
  79487. * Mesh side orientation : by default, `FRONTSIDE`
  79488. */
  79489. static readonly DEFAULTSIDE: number;
  79490. /**
  79491. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79492. */
  79493. positions: Nullable<FloatArray>;
  79494. /**
  79495. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79496. */
  79497. normals: Nullable<FloatArray>;
  79498. /**
  79499. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79500. */
  79501. tangents: Nullable<FloatArray>;
  79502. /**
  79503. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79504. */
  79505. uvs: Nullable<FloatArray>;
  79506. /**
  79507. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79508. */
  79509. uvs2: Nullable<FloatArray>;
  79510. /**
  79511. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79512. */
  79513. uvs3: Nullable<FloatArray>;
  79514. /**
  79515. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79516. */
  79517. uvs4: Nullable<FloatArray>;
  79518. /**
  79519. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79520. */
  79521. uvs5: Nullable<FloatArray>;
  79522. /**
  79523. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79524. */
  79525. uvs6: Nullable<FloatArray>;
  79526. /**
  79527. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79528. */
  79529. colors: Nullable<FloatArray>;
  79530. /**
  79531. * 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).
  79532. */
  79533. matricesIndices: Nullable<FloatArray>;
  79534. /**
  79535. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79536. */
  79537. matricesWeights: Nullable<FloatArray>;
  79538. /**
  79539. * An array extending the number of possible indices
  79540. */
  79541. matricesIndicesExtra: Nullable<FloatArray>;
  79542. /**
  79543. * An array extending the number of possible weights when the number of indices is extended
  79544. */
  79545. matricesWeightsExtra: Nullable<FloatArray>;
  79546. /**
  79547. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79548. */
  79549. indices: Nullable<IndicesArray>;
  79550. /**
  79551. * Uses the passed data array to set the set the values for the specified kind of data
  79552. * @param data a linear array of floating numbers
  79553. * @param kind the type of data that is being set, eg positions, colors etc
  79554. */
  79555. set(data: FloatArray, kind: string): void;
  79556. /**
  79557. * Associates the vertexData to the passed Mesh.
  79558. * Sets it as updatable or not (default `false`)
  79559. * @param mesh the mesh the vertexData is applied to
  79560. * @param updatable when used and having the value true allows new data to update the vertexData
  79561. * @returns the VertexData
  79562. */
  79563. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79564. /**
  79565. * Associates the vertexData to the passed Geometry.
  79566. * Sets it as updatable or not (default `false`)
  79567. * @param geometry the geometry the vertexData is applied to
  79568. * @param updatable when used and having the value true allows new data to update the vertexData
  79569. * @returns VertexData
  79570. */
  79571. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79572. /**
  79573. * Updates the associated mesh
  79574. * @param mesh the mesh to be updated
  79575. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79576. * @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
  79577. * @returns VertexData
  79578. */
  79579. updateMesh(mesh: Mesh): VertexData;
  79580. /**
  79581. * Updates the associated geometry
  79582. * @param geometry the geometry to be updated
  79583. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79584. * @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
  79585. * @returns VertexData.
  79586. */
  79587. updateGeometry(geometry: Geometry): VertexData;
  79588. private _applyTo;
  79589. private _update;
  79590. /**
  79591. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79592. * @param matrix the transforming matrix
  79593. * @returns the VertexData
  79594. */
  79595. transform(matrix: Matrix): VertexData;
  79596. /**
  79597. * Merges the passed VertexData into the current one
  79598. * @param other the VertexData to be merged into the current one
  79599. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79600. * @returns the modified VertexData
  79601. */
  79602. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79603. private _mergeElement;
  79604. private _validate;
  79605. /**
  79606. * Serializes the VertexData
  79607. * @returns a serialized object
  79608. */
  79609. serialize(): any;
  79610. /**
  79611. * Extracts the vertexData from a mesh
  79612. * @param mesh the mesh from which to extract the VertexData
  79613. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  79614. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79615. * @returns the object VertexData associated to the passed mesh
  79616. */
  79617. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79618. /**
  79619. * Extracts the vertexData from the geometry
  79620. * @param geometry the geometry from which to extract the VertexData
  79621. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79622. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79623. * @returns the object VertexData associated to the passed mesh
  79624. */
  79625. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79626. private static _ExtractFrom;
  79627. /**
  79628. * Creates the VertexData for a Ribbon
  79629. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79630. * * pathArray array of paths, each of which an array of successive Vector3
  79631. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79632. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79633. * * 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
  79634. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79635. * * 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)
  79636. * * 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)
  79637. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79638. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79639. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79640. * @returns the VertexData of the ribbon
  79641. */
  79642. static CreateRibbon(options: {
  79643. pathArray: Vector3[][];
  79644. closeArray?: boolean;
  79645. closePath?: boolean;
  79646. offset?: number;
  79647. sideOrientation?: number;
  79648. frontUVs?: Vector4;
  79649. backUVs?: Vector4;
  79650. invertUV?: boolean;
  79651. uvs?: Vector2[];
  79652. colors?: Color4[];
  79653. }): VertexData;
  79654. /**
  79655. * Creates the VertexData for a box
  79656. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79657. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79658. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79659. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79660. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79661. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79662. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79663. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79664. * * 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)
  79665. * * 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)
  79666. * @returns the VertexData of the box
  79667. */
  79668. static CreateBox(options: {
  79669. size?: number;
  79670. width?: number;
  79671. height?: number;
  79672. depth?: number;
  79673. faceUV?: Vector4[];
  79674. faceColors?: Color4[];
  79675. sideOrientation?: number;
  79676. frontUVs?: Vector4;
  79677. backUVs?: Vector4;
  79678. }): VertexData;
  79679. /**
  79680. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79681. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79682. * * segments sets the number of horizontal strips optional, default 32
  79683. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79684. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79685. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79686. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79687. * * 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
  79688. * * 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
  79689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79690. * * 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)
  79691. * * 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)
  79692. * @returns the VertexData of the ellipsoid
  79693. */
  79694. static CreateSphere(options: {
  79695. segments?: number;
  79696. diameter?: number;
  79697. diameterX?: number;
  79698. diameterY?: number;
  79699. diameterZ?: number;
  79700. arc?: number;
  79701. slice?: number;
  79702. sideOrientation?: number;
  79703. frontUVs?: Vector4;
  79704. backUVs?: Vector4;
  79705. }): VertexData;
  79706. /**
  79707. * Creates the VertexData for a cylinder, cone or prism
  79708. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79709. * * height sets the height (y direction) of the cylinder, optional, default 2
  79710. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79711. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79712. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79713. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79714. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  79715. * * 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
  79716. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79717. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79718. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  79719. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  79720. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79721. * * 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)
  79722. * * 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)
  79723. * @returns the VertexData of the cylinder, cone or prism
  79724. */
  79725. static CreateCylinder(options: {
  79726. height?: number;
  79727. diameterTop?: number;
  79728. diameterBottom?: number;
  79729. diameter?: number;
  79730. tessellation?: number;
  79731. subdivisions?: number;
  79732. arc?: number;
  79733. faceColors?: Color4[];
  79734. faceUV?: Vector4[];
  79735. hasRings?: boolean;
  79736. enclose?: boolean;
  79737. sideOrientation?: number;
  79738. frontUVs?: Vector4;
  79739. backUVs?: Vector4;
  79740. }): VertexData;
  79741. /**
  79742. * Creates the VertexData for a torus
  79743. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79744. * * diameter the diameter of the torus, optional default 1
  79745. * * thickness the diameter of the tube forming the torus, optional default 0.5
  79746. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79748. * * 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)
  79749. * * 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)
  79750. * @returns the VertexData of the torus
  79751. */
  79752. static CreateTorus(options: {
  79753. diameter?: number;
  79754. thickness?: number;
  79755. tessellation?: number;
  79756. sideOrientation?: number;
  79757. frontUVs?: Vector4;
  79758. backUVs?: Vector4;
  79759. }): VertexData;
  79760. /**
  79761. * Creates the VertexData of the LineSystem
  79762. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  79763. * - lines an array of lines, each line being an array of successive Vector3
  79764. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  79765. * @returns the VertexData of the LineSystem
  79766. */
  79767. static CreateLineSystem(options: {
  79768. lines: Vector3[][];
  79769. colors?: Nullable<Color4[][]>;
  79770. }): VertexData;
  79771. /**
  79772. * Create the VertexData for a DashedLines
  79773. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  79774. * - points an array successive Vector3
  79775. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  79776. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  79777. * - dashNb the intended total number of dashes, optional, default 200
  79778. * @returns the VertexData for the DashedLines
  79779. */
  79780. static CreateDashedLines(options: {
  79781. points: Vector3[];
  79782. dashSize?: number;
  79783. gapSize?: number;
  79784. dashNb?: number;
  79785. }): VertexData;
  79786. /**
  79787. * Creates the VertexData for a Ground
  79788. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79789. * - width the width (x direction) of the ground, optional, default 1
  79790. * - height the height (z direction) of the ground, optional, default 1
  79791. * - subdivisions the number of subdivisions per side, optional, default 1
  79792. * @returns the VertexData of the Ground
  79793. */
  79794. static CreateGround(options: {
  79795. width?: number;
  79796. height?: number;
  79797. subdivisions?: number;
  79798. subdivisionsX?: number;
  79799. subdivisionsY?: number;
  79800. }): VertexData;
  79801. /**
  79802. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  79803. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79804. * * xmin the ground minimum X coordinate, optional, default -1
  79805. * * zmin the ground minimum Z coordinate, optional, default -1
  79806. * * xmax the ground maximum X coordinate, optional, default 1
  79807. * * zmax the ground maximum Z coordinate, optional, default 1
  79808. * * 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}
  79809. * * 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}
  79810. * @returns the VertexData of the TiledGround
  79811. */
  79812. static CreateTiledGround(options: {
  79813. xmin: number;
  79814. zmin: number;
  79815. xmax: number;
  79816. zmax: number;
  79817. subdivisions?: {
  79818. w: number;
  79819. h: number;
  79820. };
  79821. precision?: {
  79822. w: number;
  79823. h: number;
  79824. };
  79825. }): VertexData;
  79826. /**
  79827. * Creates the VertexData of the Ground designed from a heightmap
  79828. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  79829. * * width the width (x direction) of the ground
  79830. * * height the height (z direction) of the ground
  79831. * * subdivisions the number of subdivisions per side
  79832. * * minHeight the minimum altitude on the ground, optional, default 0
  79833. * * maxHeight the maximum altitude on the ground, optional default 1
  79834. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  79835. * * buffer the array holding the image color data
  79836. * * bufferWidth the width of image
  79837. * * bufferHeight the height of image
  79838. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  79839. * @returns the VertexData of the Ground designed from a heightmap
  79840. */
  79841. static CreateGroundFromHeightMap(options: {
  79842. width: number;
  79843. height: number;
  79844. subdivisions: number;
  79845. minHeight: number;
  79846. maxHeight: number;
  79847. colorFilter: Color3;
  79848. buffer: Uint8Array;
  79849. bufferWidth: number;
  79850. bufferHeight: number;
  79851. alphaFilter: number;
  79852. }): VertexData;
  79853. /**
  79854. * Creates the VertexData for a Plane
  79855. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  79856. * * size sets the width and height of the plane to the value of size, optional default 1
  79857. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  79858. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  79859. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79860. * * 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)
  79861. * * 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)
  79862. * @returns the VertexData of the box
  79863. */
  79864. static CreatePlane(options: {
  79865. size?: number;
  79866. width?: number;
  79867. height?: number;
  79868. sideOrientation?: number;
  79869. frontUVs?: Vector4;
  79870. backUVs?: Vector4;
  79871. }): VertexData;
  79872. /**
  79873. * Creates the VertexData of the Disc or regular Polygon
  79874. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  79875. * * radius the radius of the disc, optional default 0.5
  79876. * * tessellation the number of polygon sides, optional, default 64
  79877. * * 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
  79878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79879. * * 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)
  79880. * * 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)
  79881. * @returns the VertexData of the box
  79882. */
  79883. static CreateDisc(options: {
  79884. radius?: number;
  79885. tessellation?: number;
  79886. arc?: number;
  79887. sideOrientation?: number;
  79888. frontUVs?: Vector4;
  79889. backUVs?: Vector4;
  79890. }): VertexData;
  79891. /**
  79892. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  79893. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  79894. * @param polygon a mesh built from polygonTriangulation.build()
  79895. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79896. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79897. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79898. * @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)
  79899. * @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)
  79900. * @returns the VertexData of the Polygon
  79901. */
  79902. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  79903. /**
  79904. * Creates the VertexData of the IcoSphere
  79905. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  79906. * * radius the radius of the IcoSphere, optional default 1
  79907. * * radiusX allows stretching in the x direction, optional, default radius
  79908. * * radiusY allows stretching in the y direction, optional, default radius
  79909. * * radiusZ allows stretching in the z direction, optional, default radius
  79910. * * flat when true creates a flat shaded mesh, optional, default true
  79911. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79912. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79913. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  79914. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  79915. * @returns the VertexData of the IcoSphere
  79916. */
  79917. static CreateIcoSphere(options: {
  79918. radius?: number;
  79919. radiusX?: number;
  79920. radiusY?: number;
  79921. radiusZ?: number;
  79922. flat?: boolean;
  79923. subdivisions?: number;
  79924. sideOrientation?: number;
  79925. frontUVs?: Vector4;
  79926. backUVs?: Vector4;
  79927. }): VertexData;
  79928. /**
  79929. * Creates the VertexData for a Polyhedron
  79930. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  79931. * * type provided types are:
  79932. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  79933. * * 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)
  79934. * * size the size of the IcoSphere, optional default 1
  79935. * * sizeX allows stretching in the x direction, optional, default size
  79936. * * sizeY allows stretching in the y direction, optional, default size
  79937. * * sizeZ allows stretching in the z direction, optional, default size
  79938. * * 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
  79939. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79940. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79941. * * flat when true creates a flat shaded mesh, optional, default true
  79942. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79943. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79944. * * 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)
  79945. * * 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)
  79946. * @returns the VertexData of the Polyhedron
  79947. */
  79948. static CreatePolyhedron(options: {
  79949. type?: number;
  79950. size?: number;
  79951. sizeX?: number;
  79952. sizeY?: number;
  79953. sizeZ?: number;
  79954. custom?: any;
  79955. faceUV?: Vector4[];
  79956. faceColors?: Color4[];
  79957. flat?: boolean;
  79958. sideOrientation?: number;
  79959. frontUVs?: Vector4;
  79960. backUVs?: Vector4;
  79961. }): VertexData;
  79962. /**
  79963. * Creates the VertexData for a TorusKnot
  79964. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  79965. * * radius the radius of the torus knot, optional, default 2
  79966. * * tube the thickness of the tube, optional, default 0.5
  79967. * * radialSegments the number of sides on each tube segments, optional, default 32
  79968. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  79969. * * p the number of windings around the z axis, optional, default 2
  79970. * * q the number of windings around the x axis, optional, default 3
  79971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79972. * * 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)
  79973. * * 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)
  79974. * @returns the VertexData of the Torus Knot
  79975. */
  79976. static CreateTorusKnot(options: {
  79977. radius?: number;
  79978. tube?: number;
  79979. radialSegments?: number;
  79980. tubularSegments?: number;
  79981. p?: number;
  79982. q?: number;
  79983. sideOrientation?: number;
  79984. frontUVs?: Vector4;
  79985. backUVs?: Vector4;
  79986. }): VertexData;
  79987. /**
  79988. * Compute normals for given positions and indices
  79989. * @param positions an array of vertex positions, [...., x, y, z, ......]
  79990. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  79991. * @param normals an array of vertex normals, [...., x, y, z, ......]
  79992. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  79993. * * facetNormals : optional array of facet normals (vector3)
  79994. * * facetPositions : optional array of facet positions (vector3)
  79995. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  79996. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  79997. * * bInfo : optional bounding info, required for facetPartitioning computation
  79998. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  79999. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80000. * * useRightHandedSystem: optional boolean to for right handed system computation
  80001. * * depthSort : optional boolean to enable the facet depth sort computation
  80002. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80003. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80004. */
  80005. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80006. facetNormals?: any;
  80007. facetPositions?: any;
  80008. facetPartitioning?: any;
  80009. ratio?: number;
  80010. bInfo?: any;
  80011. bbSize?: Vector3;
  80012. subDiv?: any;
  80013. useRightHandedSystem?: boolean;
  80014. depthSort?: boolean;
  80015. distanceTo?: Vector3;
  80016. depthSortedFacets?: any;
  80017. }): void;
  80018. /** @hidden */
  80019. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80020. /**
  80021. * Applies VertexData created from the imported parameters to the geometry
  80022. * @param parsedVertexData the parsed data from an imported file
  80023. * @param geometry the geometry to apply the VertexData to
  80024. */
  80025. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80026. }
  80027. }
  80028. declare module BABYLON {
  80029. /**
  80030. * Class containing static functions to help procedurally build meshes
  80031. */
  80032. export class DiscBuilder {
  80033. /**
  80034. * Creates a plane polygonal mesh. By default, this is a disc
  80035. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80036. * * 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
  80037. * * 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
  80038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80039. * * If you create a double-sided mesh, you can choose what parts of 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
  80040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80041. * @param name defines the name of the mesh
  80042. * @param options defines the options used to create the mesh
  80043. * @param scene defines the hosting scene
  80044. * @returns the plane polygonal mesh
  80045. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80046. */
  80047. static CreateDisc(name: string, options: {
  80048. radius?: number;
  80049. tessellation?: number;
  80050. arc?: number;
  80051. updatable?: boolean;
  80052. sideOrientation?: number;
  80053. frontUVs?: Vector4;
  80054. backUVs?: Vector4;
  80055. }, scene?: Nullable<Scene>): Mesh;
  80056. }
  80057. }
  80058. declare module BABYLON {
  80059. /**
  80060. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80061. *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.
  80062. * The SPS is also a particle system. It provides some methods to manage the particles.
  80063. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80064. *
  80065. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80066. */
  80067. export class SolidParticleSystem implements IDisposable {
  80068. /**
  80069. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80070. * Example : var p = SPS.particles[i];
  80071. */
  80072. particles: SolidParticle[];
  80073. /**
  80074. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80075. */
  80076. nbParticles: number;
  80077. /**
  80078. * If the particles must ever face the camera (default false). Useful for planar particles.
  80079. */
  80080. billboard: boolean;
  80081. /**
  80082. * Recompute normals when adding a shape
  80083. */
  80084. recomputeNormals: boolean;
  80085. /**
  80086. * This a counter ofr your own usage. It's not set by any SPS functions.
  80087. */
  80088. counter: number;
  80089. /**
  80090. * The SPS name. This name is also given to the underlying mesh.
  80091. */
  80092. name: string;
  80093. /**
  80094. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80095. */
  80096. mesh: Mesh;
  80097. /**
  80098. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80099. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80100. */
  80101. vars: any;
  80102. /**
  80103. * This array is populated when the SPS is set as 'pickable'.
  80104. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80105. * Each element of this array is an object `{idx: int, faceId: int}`.
  80106. * `idx` is the picked particle index in the `SPS.particles` array
  80107. * `faceId` is the picked face index counted within this particle.
  80108. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80109. */
  80110. pickedParticles: {
  80111. idx: number;
  80112. faceId: number;
  80113. }[];
  80114. /**
  80115. * This array is populated when `enableDepthSort` is set to true.
  80116. * Each element of this array is an instance of the class DepthSortedParticle.
  80117. */
  80118. depthSortedParticles: DepthSortedParticle[];
  80119. /**
  80120. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80121. * @hidden
  80122. */
  80123. _bSphereOnly: boolean;
  80124. /**
  80125. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80126. * @hidden
  80127. */
  80128. _bSphereRadiusFactor: number;
  80129. private _scene;
  80130. private _positions;
  80131. private _indices;
  80132. private _normals;
  80133. private _colors;
  80134. private _uvs;
  80135. private _indices32;
  80136. private _positions32;
  80137. private _normals32;
  80138. private _fixedNormal32;
  80139. private _colors32;
  80140. private _uvs32;
  80141. private _index;
  80142. private _updatable;
  80143. private _pickable;
  80144. private _isVisibilityBoxLocked;
  80145. private _alwaysVisible;
  80146. private _depthSort;
  80147. private _shapeCounter;
  80148. private _copy;
  80149. private _color;
  80150. private _computeParticleColor;
  80151. private _computeParticleTexture;
  80152. private _computeParticleRotation;
  80153. private _computeParticleVertex;
  80154. private _computeBoundingBox;
  80155. private _depthSortParticles;
  80156. private _camera;
  80157. private _mustUnrotateFixedNormals;
  80158. private _particlesIntersect;
  80159. private _needs32Bits;
  80160. /**
  80161. * Creates a SPS (Solid Particle System) object.
  80162. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80163. * @param scene (Scene) is the scene in which the SPS is added.
  80164. * @param options defines the options of the sps e.g.
  80165. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80166. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80167. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80168. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80169. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80170. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80171. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80172. */
  80173. constructor(name: string, scene: Scene, options?: {
  80174. updatable?: boolean;
  80175. isPickable?: boolean;
  80176. enableDepthSort?: boolean;
  80177. particleIntersection?: boolean;
  80178. boundingSphereOnly?: boolean;
  80179. bSphereRadiusFactor?: number;
  80180. });
  80181. /**
  80182. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80183. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80184. * @returns the created mesh
  80185. */
  80186. buildMesh(): Mesh;
  80187. /**
  80188. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80189. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80190. * Thus the particles generated from `digest()` have their property `position` set yet.
  80191. * @param mesh ( Mesh ) is the mesh to be digested
  80192. * @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
  80193. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80194. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80195. * @returns the current SPS
  80196. */
  80197. digest(mesh: Mesh, options?: {
  80198. facetNb?: number;
  80199. number?: number;
  80200. delta?: number;
  80201. }): SolidParticleSystem;
  80202. private _unrotateFixedNormals;
  80203. private _resetCopy;
  80204. private _meshBuilder;
  80205. private _posToShape;
  80206. private _uvsToShapeUV;
  80207. private _addParticle;
  80208. /**
  80209. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80210. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80211. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80212. * @param nb (positive integer) the number of particles to be created from this model
  80213. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80214. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80215. * @returns the number of shapes in the system
  80216. */
  80217. addShape(mesh: Mesh, nb: number, options?: {
  80218. positionFunction?: any;
  80219. vertexFunction?: any;
  80220. }): number;
  80221. private _rebuildParticle;
  80222. /**
  80223. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80224. * @returns the SPS.
  80225. */
  80226. rebuildMesh(): SolidParticleSystem;
  80227. /**
  80228. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80229. * This method calls `updateParticle()` for each particle of the SPS.
  80230. * For an animated SPS, it is usually called within the render loop.
  80231. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80232. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80233. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80234. * @returns the SPS.
  80235. */
  80236. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80237. /**
  80238. * Disposes the SPS.
  80239. */
  80240. dispose(): void;
  80241. /**
  80242. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80243. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80244. * @returns the SPS.
  80245. */
  80246. refreshVisibleSize(): SolidParticleSystem;
  80247. /**
  80248. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80249. * @param size the size (float) of the visibility box
  80250. * note : this doesn't lock the SPS mesh bounding box.
  80251. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80252. */
  80253. setVisibilityBox(size: number): void;
  80254. /**
  80255. * Gets whether the SPS as always visible or not
  80256. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80257. */
  80258. /**
  80259. * Sets the SPS as always visible or not
  80260. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80261. */
  80262. isAlwaysVisible: boolean;
  80263. /**
  80264. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80265. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80266. */
  80267. /**
  80268. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80269. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80270. */
  80271. isVisibilityBoxLocked: boolean;
  80272. /**
  80273. * Tells to `setParticles()` to compute the particle rotations or not.
  80274. * Default value : true. The SPS is faster when it's set to false.
  80275. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80276. */
  80277. /**
  80278. * Gets if `setParticles()` computes the particle rotations or not.
  80279. * Default value : true. The SPS is faster when it's set to false.
  80280. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80281. */
  80282. computeParticleRotation: boolean;
  80283. /**
  80284. * Tells to `setParticles()` to compute the particle colors or not.
  80285. * Default value : true. The SPS is faster when it's set to false.
  80286. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80287. */
  80288. /**
  80289. * Gets if `setParticles()` computes the particle colors or not.
  80290. * Default value : true. The SPS is faster when it's set to false.
  80291. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80292. */
  80293. computeParticleColor: boolean;
  80294. /**
  80295. * Gets if `setParticles()` computes the particle textures or not.
  80296. * Default value : true. The SPS is faster when it's set to false.
  80297. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80298. */
  80299. computeParticleTexture: boolean;
  80300. /**
  80301. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80302. * Default value : false. The SPS is faster when it's set to false.
  80303. * Note : the particle custom vertex positions aren't stored values.
  80304. */
  80305. /**
  80306. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80307. * Default value : false. The SPS is faster when it's set to false.
  80308. * Note : the particle custom vertex positions aren't stored values.
  80309. */
  80310. computeParticleVertex: boolean;
  80311. /**
  80312. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80313. */
  80314. /**
  80315. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80316. */
  80317. computeBoundingBox: boolean;
  80318. /**
  80319. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80320. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80321. * Default : `true`
  80322. */
  80323. /**
  80324. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80325. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80326. * Default : `true`
  80327. */
  80328. depthSortParticles: boolean;
  80329. /**
  80330. * This function does nothing. It may be overwritten to set all the particle first values.
  80331. * The SPS doesn't call this function, you may have to call it by your own.
  80332. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80333. */
  80334. initParticles(): void;
  80335. /**
  80336. * This function does nothing. It may be overwritten to recycle a particle.
  80337. * The SPS doesn't call this function, you may have to call it by your own.
  80338. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80339. * @param particle The particle to recycle
  80340. * @returns the recycled particle
  80341. */
  80342. recycleParticle(particle: SolidParticle): SolidParticle;
  80343. /**
  80344. * Updates a particle : this function should be overwritten by the user.
  80345. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80346. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80347. * @example : just set a particle position or velocity and recycle conditions
  80348. * @param particle The particle to update
  80349. * @returns the updated particle
  80350. */
  80351. updateParticle(particle: SolidParticle): SolidParticle;
  80352. /**
  80353. * Updates a vertex of a particle : it can be overwritten by the user.
  80354. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80355. * @param particle the current particle
  80356. * @param vertex the current index of the current particle
  80357. * @param pt the index of the current vertex in the particle shape
  80358. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80359. * @example : just set a vertex particle position
  80360. * @returns the updated vertex
  80361. */
  80362. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80363. /**
  80364. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80365. * This does nothing and may be overwritten by the user.
  80366. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80367. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80368. * @param update the boolean update value actually passed to setParticles()
  80369. */
  80370. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80371. /**
  80372. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80373. * This will be passed three parameters.
  80374. * This does nothing and may be overwritten by the user.
  80375. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80376. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80377. * @param update the boolean update value actually passed to setParticles()
  80378. */
  80379. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80380. }
  80381. }
  80382. declare module BABYLON {
  80383. /**
  80384. * Represents one particle of a solid particle system.
  80385. */
  80386. export class SolidParticle {
  80387. /**
  80388. * particle global index
  80389. */
  80390. idx: number;
  80391. /**
  80392. * The color of the particle
  80393. */
  80394. color: Nullable<Color4>;
  80395. /**
  80396. * The world space position of the particle.
  80397. */
  80398. position: Vector3;
  80399. /**
  80400. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80401. */
  80402. rotation: Vector3;
  80403. /**
  80404. * The world space rotation quaternion of the particle.
  80405. */
  80406. rotationQuaternion: Nullable<Quaternion>;
  80407. /**
  80408. * The scaling of the particle.
  80409. */
  80410. scaling: Vector3;
  80411. /**
  80412. * The uvs of the particle.
  80413. */
  80414. uvs: Vector4;
  80415. /**
  80416. * The current speed of the particle.
  80417. */
  80418. velocity: Vector3;
  80419. /**
  80420. * The pivot point in the particle local space.
  80421. */
  80422. pivot: Vector3;
  80423. /**
  80424. * Must the particle be translated from its pivot point in its local space ?
  80425. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80426. * Default : false
  80427. */
  80428. translateFromPivot: boolean;
  80429. /**
  80430. * Is the particle active or not ?
  80431. */
  80432. alive: boolean;
  80433. /**
  80434. * Is the particle visible or not ?
  80435. */
  80436. isVisible: boolean;
  80437. /**
  80438. * Index of this particle in the global "positions" array (Internal use)
  80439. * @hidden
  80440. */
  80441. _pos: number;
  80442. /**
  80443. * @hidden Index of this particle in the global "indices" array (Internal use)
  80444. */
  80445. _ind: number;
  80446. /**
  80447. * @hidden ModelShape of this particle (Internal use)
  80448. */
  80449. _model: ModelShape;
  80450. /**
  80451. * ModelShape id of this particle
  80452. */
  80453. shapeId: number;
  80454. /**
  80455. * Index of the particle in its shape id (Internal use)
  80456. */
  80457. idxInShape: number;
  80458. /**
  80459. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80460. */
  80461. _modelBoundingInfo: BoundingInfo;
  80462. /**
  80463. * @hidden Particle BoundingInfo object (Internal use)
  80464. */
  80465. _boundingInfo: BoundingInfo;
  80466. /**
  80467. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80468. */
  80469. _sps: SolidParticleSystem;
  80470. /**
  80471. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80472. */
  80473. _stillInvisible: boolean;
  80474. /**
  80475. * @hidden Last computed particle rotation matrix
  80476. */
  80477. _rotationMatrix: number[];
  80478. /**
  80479. * Parent particle Id, if any.
  80480. * Default null.
  80481. */
  80482. parentId: Nullable<number>;
  80483. /**
  80484. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80485. * The possible values are :
  80486. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80487. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80488. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80489. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80490. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80491. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80492. * */
  80493. cullingStrategy: number;
  80494. /**
  80495. * @hidden Internal global position in the SPS.
  80496. */
  80497. _globalPosition: Vector3;
  80498. /**
  80499. * Creates a Solid Particle object.
  80500. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80501. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80502. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80503. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80504. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80505. * @param shapeId (integer) is the model shape identifier in the SPS.
  80506. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80507. * @param sps defines the sps it is associated to
  80508. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80509. */
  80510. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80511. /**
  80512. * Legacy support, changed scale to scaling
  80513. */
  80514. /**
  80515. * Legacy support, changed scale to scaling
  80516. */
  80517. scale: Vector3;
  80518. /**
  80519. * Legacy support, changed quaternion to rotationQuaternion
  80520. */
  80521. /**
  80522. * Legacy support, changed quaternion to rotationQuaternion
  80523. */
  80524. quaternion: Nullable<Quaternion>;
  80525. /**
  80526. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80527. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80528. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80529. * @returns true if it intersects
  80530. */
  80531. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80532. /**
  80533. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80534. * A particle is in the frustum if its bounding box intersects the frustum
  80535. * @param frustumPlanes defines the frustum to test
  80536. * @returns true if the particle is in the frustum planes
  80537. */
  80538. isInFrustum(frustumPlanes: Plane[]): boolean;
  80539. /**
  80540. * get the rotation matrix of the particle
  80541. * @hidden
  80542. */
  80543. getRotationMatrix(m: Matrix): void;
  80544. }
  80545. /**
  80546. * Represents the shape of the model used by one particle of a solid particle system.
  80547. * SPS internal tool, don't use it manually.
  80548. */
  80549. export class ModelShape {
  80550. /**
  80551. * The shape id
  80552. * @hidden
  80553. */
  80554. shapeID: number;
  80555. /**
  80556. * flat array of model positions (internal use)
  80557. * @hidden
  80558. */
  80559. _shape: Vector3[];
  80560. /**
  80561. * flat array of model UVs (internal use)
  80562. * @hidden
  80563. */
  80564. _shapeUV: number[];
  80565. /**
  80566. * length of the shape in the model indices array (internal use)
  80567. * @hidden
  80568. */
  80569. _indicesLength: number;
  80570. /**
  80571. * Custom position function (internal use)
  80572. * @hidden
  80573. */
  80574. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80575. /**
  80576. * Custom vertex function (internal use)
  80577. * @hidden
  80578. */
  80579. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80580. /**
  80581. * 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.
  80582. * SPS internal tool, don't use it manually.
  80583. * @hidden
  80584. */
  80585. 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>);
  80586. }
  80587. /**
  80588. * Represents a Depth Sorted Particle in the solid particle system.
  80589. */
  80590. export class DepthSortedParticle {
  80591. /**
  80592. * Index of the particle in the "indices" array
  80593. */
  80594. ind: number;
  80595. /**
  80596. * Length of the particle shape in the "indices" array
  80597. */
  80598. indicesLength: number;
  80599. /**
  80600. * Squared distance from the particle to the camera
  80601. */
  80602. sqDistance: number;
  80603. }
  80604. }
  80605. declare module BABYLON {
  80606. /**
  80607. * Class used to store all common mesh properties
  80608. */
  80609. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80610. /** No occlusion */
  80611. static OCCLUSION_TYPE_NONE: number;
  80612. /** Occlusion set to optimisitic */
  80613. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80614. /** Occlusion set to strict */
  80615. static OCCLUSION_TYPE_STRICT: number;
  80616. /** Use an accurante occlusion algorithm */
  80617. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80618. /** Use a conservative occlusion algorithm */
  80619. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80620. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80621. * Test order :
  80622. * Is the bounding sphere outside the frustum ?
  80623. * If not, are the bounding box vertices outside the frustum ?
  80624. * It not, then the cullable object is in the frustum.
  80625. */
  80626. static readonly CULLINGSTRATEGY_STANDARD: number;
  80627. /** Culling strategy : Bounding Sphere Only.
  80628. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80629. * It's also less accurate than the standard because some not visible objects can still be selected.
  80630. * Test : is the bounding sphere outside the frustum ?
  80631. * If not, then the cullable object is in the frustum.
  80632. */
  80633. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80634. /** Culling strategy : Optimistic Inclusion.
  80635. * This in an inclusion test first, then the standard exclusion test.
  80636. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80637. * 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.
  80638. * Anyway, it's as accurate as the standard strategy.
  80639. * Test :
  80640. * Is the cullable object bounding sphere center in the frustum ?
  80641. * If not, apply the default culling strategy.
  80642. */
  80643. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80644. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80645. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80646. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80647. * 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.
  80648. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80649. * Test :
  80650. * Is the cullable object bounding sphere center in the frustum ?
  80651. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80652. */
  80653. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80654. /**
  80655. * No billboard
  80656. */
  80657. static readonly BILLBOARDMODE_NONE: number;
  80658. /** Billboard on X axis */
  80659. static readonly BILLBOARDMODE_X: number;
  80660. /** Billboard on Y axis */
  80661. static readonly BILLBOARDMODE_Y: number;
  80662. /** Billboard on Z axis */
  80663. static readonly BILLBOARDMODE_Z: number;
  80664. /** Billboard on all axes */
  80665. static readonly BILLBOARDMODE_ALL: number;
  80666. private _facetData;
  80667. /**
  80668. * The culling strategy to use to check whether the mesh must be rendered or not.
  80669. * This value can be changed at any time and will be used on the next render mesh selection.
  80670. * The possible values are :
  80671. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80672. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80673. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80674. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80675. * Please read each static variable documentation to get details about the culling process.
  80676. * */
  80677. cullingStrategy: number;
  80678. /**
  80679. * Gets the number of facets in the mesh
  80680. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80681. */
  80682. readonly facetNb: number;
  80683. /**
  80684. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80686. */
  80687. partitioningSubdivisions: number;
  80688. /**
  80689. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80690. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80691. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80692. */
  80693. partitioningBBoxRatio: number;
  80694. /**
  80695. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80696. * Works only for updatable meshes.
  80697. * Doesn't work with multi-materials
  80698. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80699. */
  80700. mustDepthSortFacets: boolean;
  80701. /**
  80702. * The location (Vector3) where the facet depth sort must be computed from.
  80703. * By default, the active camera position.
  80704. * Used only when facet depth sort is enabled
  80705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80706. */
  80707. facetDepthSortFrom: Vector3;
  80708. /**
  80709. * gets a boolean indicating if facetData is enabled
  80710. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80711. */
  80712. readonly isFacetDataEnabled: boolean;
  80713. /** @hidden */
  80714. _updateNonUniformScalingState(value: boolean): boolean;
  80715. /**
  80716. * An event triggered when this mesh collides with another one
  80717. */
  80718. onCollideObservable: Observable<AbstractMesh>;
  80719. private _onCollideObserver;
  80720. /** Set a function to call when this mesh collides with another one */
  80721. onCollide: () => void;
  80722. /**
  80723. * An event triggered when the collision's position changes
  80724. */
  80725. onCollisionPositionChangeObservable: Observable<Vector3>;
  80726. private _onCollisionPositionChangeObserver;
  80727. /** Set a function to call when the collision's position changes */
  80728. onCollisionPositionChange: () => void;
  80729. /**
  80730. * An event triggered when material is changed
  80731. */
  80732. onMaterialChangedObservable: Observable<AbstractMesh>;
  80733. /**
  80734. * Gets or sets the orientation for POV movement & rotation
  80735. */
  80736. definedFacingForward: boolean;
  80737. /** @hidden */
  80738. _occlusionQuery: Nullable<WebGLQuery>;
  80739. private _visibility;
  80740. /**
  80741. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80742. */
  80743. /**
  80744. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80745. */
  80746. visibility: number;
  80747. /** Gets or sets the alpha index used to sort transparent meshes
  80748. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80749. */
  80750. alphaIndex: number;
  80751. /**
  80752. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80753. */
  80754. isVisible: boolean;
  80755. /**
  80756. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80757. */
  80758. isPickable: boolean;
  80759. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80760. showSubMeshesBoundingBox: boolean;
  80761. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80762. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80763. */
  80764. isBlocker: boolean;
  80765. /**
  80766. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80767. */
  80768. enablePointerMoveEvents: boolean;
  80769. /**
  80770. * Specifies the rendering group id for this mesh (0 by default)
  80771. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80772. */
  80773. renderingGroupId: number;
  80774. private _material;
  80775. /** Gets or sets current material */
  80776. material: Nullable<Material>;
  80777. private _receiveShadows;
  80778. /**
  80779. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80780. * @see http://doc.babylonjs.com/babylon101/shadows
  80781. */
  80782. receiveShadows: boolean;
  80783. /** Defines color to use when rendering outline */
  80784. outlineColor: Color3;
  80785. /** Define width to use when rendering outline */
  80786. outlineWidth: number;
  80787. /** Defines color to use when rendering overlay */
  80788. overlayColor: Color3;
  80789. /** Defines alpha to use when rendering overlay */
  80790. overlayAlpha: number;
  80791. private _hasVertexAlpha;
  80792. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80793. hasVertexAlpha: boolean;
  80794. private _useVertexColors;
  80795. /** 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) */
  80796. useVertexColors: boolean;
  80797. private _computeBonesUsingShaders;
  80798. /**
  80799. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80800. */
  80801. computeBonesUsingShaders: boolean;
  80802. private _numBoneInfluencers;
  80803. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80804. numBoneInfluencers: number;
  80805. private _applyFog;
  80806. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80807. applyFog: boolean;
  80808. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80809. useOctreeForRenderingSelection: boolean;
  80810. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80811. useOctreeForPicking: boolean;
  80812. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80813. useOctreeForCollisions: boolean;
  80814. private _layerMask;
  80815. /**
  80816. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80817. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80818. */
  80819. layerMask: number;
  80820. /**
  80821. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80822. */
  80823. alwaysSelectAsActiveMesh: boolean;
  80824. /**
  80825. * Gets or sets the current action manager
  80826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80827. */
  80828. actionManager: Nullable<AbstractActionManager>;
  80829. private _checkCollisions;
  80830. private _collisionMask;
  80831. private _collisionGroup;
  80832. /**
  80833. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80834. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80835. */
  80836. ellipsoid: Vector3;
  80837. /**
  80838. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80839. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80840. */
  80841. ellipsoidOffset: Vector3;
  80842. private _collider;
  80843. private _oldPositionForCollisions;
  80844. private _diffPositionForCollisions;
  80845. /**
  80846. * Gets or sets a collision mask used to mask collisions (default is -1).
  80847. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80848. */
  80849. collisionMask: number;
  80850. /**
  80851. * Gets or sets the current collision group mask (-1 by default).
  80852. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80853. */
  80854. collisionGroup: number;
  80855. /**
  80856. * Defines edge width used when edgesRenderer is enabled
  80857. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80858. */
  80859. edgesWidth: number;
  80860. /**
  80861. * Defines edge color used when edgesRenderer is enabled
  80862. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80863. */
  80864. edgesColor: Color4;
  80865. /** @hidden */
  80866. _edgesRenderer: Nullable<IEdgesRenderer>;
  80867. /** @hidden */
  80868. _masterMesh: Nullable<AbstractMesh>;
  80869. /** @hidden */
  80870. _boundingInfo: Nullable<BoundingInfo>;
  80871. /** @hidden */
  80872. _renderId: number;
  80873. /**
  80874. * Gets or sets the list of subMeshes
  80875. * @see http://doc.babylonjs.com/how_to/multi_materials
  80876. */
  80877. subMeshes: SubMesh[];
  80878. /** @hidden */
  80879. _intersectionsInProgress: AbstractMesh[];
  80880. /** @hidden */
  80881. _unIndexed: boolean;
  80882. /** @hidden */
  80883. _lightSources: Light[];
  80884. /** @hidden */
  80885. readonly _positions: Nullable<Vector3[]>;
  80886. /** @hidden */
  80887. _waitingActions: any;
  80888. /** @hidden */
  80889. _waitingFreezeWorldMatrix: Nullable<boolean>;
  80890. private _skeleton;
  80891. /** @hidden */
  80892. _bonesTransformMatrices: Nullable<Float32Array>;
  80893. /**
  80894. * Gets or sets a skeleton to apply skining transformations
  80895. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80896. */
  80897. skeleton: Nullable<Skeleton>;
  80898. /**
  80899. * An event triggered when the mesh is rebuilt.
  80900. */
  80901. onRebuildObservable: Observable<AbstractMesh>;
  80902. /**
  80903. * Creates a new AbstractMesh
  80904. * @param name defines the name of the mesh
  80905. * @param scene defines the hosting scene
  80906. */
  80907. constructor(name: string, scene?: Nullable<Scene>);
  80908. /**
  80909. * Returns the string "AbstractMesh"
  80910. * @returns "AbstractMesh"
  80911. */
  80912. getClassName(): string;
  80913. /**
  80914. * Gets a string representation of the current mesh
  80915. * @param fullDetails defines a boolean indicating if full details must be included
  80916. * @returns a string representation of the current mesh
  80917. */
  80918. toString(fullDetails?: boolean): string;
  80919. /** @hidden */
  80920. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  80921. /** @hidden */
  80922. _rebuild(): void;
  80923. /** @hidden */
  80924. _resyncLightSources(): void;
  80925. /** @hidden */
  80926. _resyncLighSource(light: Light): void;
  80927. /** @hidden */
  80928. _unBindEffect(): void;
  80929. /** @hidden */
  80930. _removeLightSource(light: Light): void;
  80931. private _markSubMeshesAsDirty;
  80932. /** @hidden */
  80933. _markSubMeshesAsLightDirty(): void;
  80934. /** @hidden */
  80935. _markSubMeshesAsAttributesDirty(): void;
  80936. /** @hidden */
  80937. _markSubMeshesAsMiscDirty(): void;
  80938. /**
  80939. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  80940. */
  80941. scaling: Vector3;
  80942. /**
  80943. * Returns true if the mesh is blocked. Implemented by child classes
  80944. */
  80945. readonly isBlocked: boolean;
  80946. /**
  80947. * Returns the mesh itself by default. Implemented by child classes
  80948. * @param camera defines the camera to use to pick the right LOD level
  80949. * @returns the currentAbstractMesh
  80950. */
  80951. getLOD(camera: Camera): Nullable<AbstractMesh>;
  80952. /**
  80953. * Returns 0 by default. Implemented by child classes
  80954. * @returns an integer
  80955. */
  80956. getTotalVertices(): number;
  80957. /**
  80958. * Returns a positive integer : the total number of indices in this mesh geometry.
  80959. * @returns the numner of indices or zero if the mesh has no geometry.
  80960. */
  80961. getTotalIndices(): number;
  80962. /**
  80963. * Returns null by default. Implemented by child classes
  80964. * @returns null
  80965. */
  80966. getIndices(): Nullable<IndicesArray>;
  80967. /**
  80968. * Returns the array of the requested vertex data kind. Implemented by child classes
  80969. * @param kind defines the vertex data kind to use
  80970. * @returns null
  80971. */
  80972. getVerticesData(kind: string): Nullable<FloatArray>;
  80973. /**
  80974. * Sets the vertex data of the mesh geometry for the requested `kind`.
  80975. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  80976. * Note that a new underlying VertexBuffer object is created each call.
  80977. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  80978. * @param kind defines vertex data kind:
  80979. * * VertexBuffer.PositionKind
  80980. * * VertexBuffer.UVKind
  80981. * * VertexBuffer.UV2Kind
  80982. * * VertexBuffer.UV3Kind
  80983. * * VertexBuffer.UV4Kind
  80984. * * VertexBuffer.UV5Kind
  80985. * * VertexBuffer.UV6Kind
  80986. * * VertexBuffer.ColorKind
  80987. * * VertexBuffer.MatricesIndicesKind
  80988. * * VertexBuffer.MatricesIndicesExtraKind
  80989. * * VertexBuffer.MatricesWeightsKind
  80990. * * VertexBuffer.MatricesWeightsExtraKind
  80991. * @param data defines the data source
  80992. * @param updatable defines if the data must be flagged as updatable (or static)
  80993. * @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
  80994. * @returns the current mesh
  80995. */
  80996. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  80997. /**
  80998. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  80999. * If the mesh has no geometry, it is simply returned as it is.
  81000. * @param kind defines vertex data kind:
  81001. * * VertexBuffer.PositionKind
  81002. * * VertexBuffer.UVKind
  81003. * * VertexBuffer.UV2Kind
  81004. * * VertexBuffer.UV3Kind
  81005. * * VertexBuffer.UV4Kind
  81006. * * VertexBuffer.UV5Kind
  81007. * * VertexBuffer.UV6Kind
  81008. * * VertexBuffer.ColorKind
  81009. * * VertexBuffer.MatricesIndicesKind
  81010. * * VertexBuffer.MatricesIndicesExtraKind
  81011. * * VertexBuffer.MatricesWeightsKind
  81012. * * VertexBuffer.MatricesWeightsExtraKind
  81013. * @param data defines the data source
  81014. * @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
  81015. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81016. * @returns the current mesh
  81017. */
  81018. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81019. /**
  81020. * Sets the mesh indices,
  81021. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81022. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81023. * @param totalVertices Defines the total number of vertices
  81024. * @returns the current mesh
  81025. */
  81026. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81027. /**
  81028. * Gets a boolean indicating if specific vertex data is present
  81029. * @param kind defines the vertex data kind to use
  81030. * @returns true is data kind is present
  81031. */
  81032. isVerticesDataPresent(kind: string): boolean;
  81033. /**
  81034. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81035. * @returns a BoundingInfo
  81036. */
  81037. getBoundingInfo(): BoundingInfo;
  81038. /**
  81039. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81040. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81041. * @returns the current mesh
  81042. */
  81043. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81044. /**
  81045. * Overwrite the current bounding info
  81046. * @param boundingInfo defines the new bounding info
  81047. * @returns the current mesh
  81048. */
  81049. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81050. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81051. readonly useBones: boolean;
  81052. /** @hidden */
  81053. _preActivate(): void;
  81054. /** @hidden */
  81055. _preActivateForIntermediateRendering(renderId: number): void;
  81056. /** @hidden */
  81057. _activate(renderId: number): void;
  81058. /**
  81059. * Gets the current world matrix
  81060. * @returns a Matrix
  81061. */
  81062. getWorldMatrix(): Matrix;
  81063. /** @hidden */
  81064. _getWorldMatrixDeterminant(): number;
  81065. /**
  81066. * Perform relative position change from the point of view of behind the front of the mesh.
  81067. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81068. * Supports definition of mesh facing forward or backward
  81069. * @param amountRight defines the distance on the right axis
  81070. * @param amountUp defines the distance on the up axis
  81071. * @param amountForward defines the distance on the forward axis
  81072. * @returns the current mesh
  81073. */
  81074. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81075. /**
  81076. * Calculate relative position change from the point of view of behind the front of the mesh.
  81077. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81078. * Supports definition of mesh facing forward or backward
  81079. * @param amountRight defines the distance on the right axis
  81080. * @param amountUp defines the distance on the up axis
  81081. * @param amountForward defines the distance on the forward axis
  81082. * @returns the new displacement vector
  81083. */
  81084. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81085. /**
  81086. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81087. * Supports definition of mesh facing forward or backward
  81088. * @param flipBack defines the flip
  81089. * @param twirlClockwise defines the twirl
  81090. * @param tiltRight defines the tilt
  81091. * @returns the current mesh
  81092. */
  81093. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81094. /**
  81095. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81096. * Supports definition of mesh facing forward or backward.
  81097. * @param flipBack defines the flip
  81098. * @param twirlClockwise defines the twirl
  81099. * @param tiltRight defines the tilt
  81100. * @returns the new rotation vector
  81101. */
  81102. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81103. /**
  81104. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81105. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81106. * @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
  81107. * @returns the new bounding vectors
  81108. */
  81109. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81110. min: Vector3;
  81111. max: Vector3;
  81112. };
  81113. /**
  81114. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81115. * This means the mesh underlying bounding box and sphere are recomputed.
  81116. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81117. * @returns the current mesh
  81118. */
  81119. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81120. /** @hidden */
  81121. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81122. /** @hidden */
  81123. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81124. /** @hidden */
  81125. _updateBoundingInfo(): AbstractMesh;
  81126. /** @hidden */
  81127. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81128. /** @hidden */
  81129. protected _afterComputeWorldMatrix(): void;
  81130. /**
  81131. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81132. * A mesh is in the frustum if its bounding box intersects the frustum
  81133. * @param frustumPlanes defines the frustum to test
  81134. * @returns true if the mesh is in the frustum planes
  81135. */
  81136. isInFrustum(frustumPlanes: Plane[]): boolean;
  81137. /**
  81138. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81139. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81140. * @param frustumPlanes defines the frustum to test
  81141. * @returns true if the mesh is completely in the frustum planes
  81142. */
  81143. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81144. /**
  81145. * True if the mesh intersects another mesh or a SolidParticle object
  81146. * @param mesh defines a target mesh or SolidParticle to test
  81147. * @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)
  81148. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81149. * @returns true if there is an intersection
  81150. */
  81151. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81152. /**
  81153. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81154. * @param point defines the point to test
  81155. * @returns true if there is an intersection
  81156. */
  81157. intersectsPoint(point: Vector3): boolean;
  81158. /**
  81159. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81161. */
  81162. checkCollisions: boolean;
  81163. /**
  81164. * Gets Collider object used to compute collisions (not physics)
  81165. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81166. */
  81167. readonly collider: Collider;
  81168. /**
  81169. * Move the mesh using collision engine
  81170. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81171. * @param displacement defines the requested displacement vector
  81172. * @returns the current mesh
  81173. */
  81174. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81175. private _onCollisionPositionChange;
  81176. /** @hidden */
  81177. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81178. /** @hidden */
  81179. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81180. /** @hidden */
  81181. _checkCollision(collider: Collider): AbstractMesh;
  81182. /** @hidden */
  81183. _generatePointsArray(): boolean;
  81184. /**
  81185. * Checks if the passed Ray intersects with the mesh
  81186. * @param ray defines the ray to use
  81187. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81188. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81189. * @returns the picking info
  81190. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81191. */
  81192. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81193. /**
  81194. * Clones the current mesh
  81195. * @param name defines the mesh name
  81196. * @param newParent defines the new mesh parent
  81197. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81198. * @returns the new mesh
  81199. */
  81200. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81201. /**
  81202. * Disposes all the submeshes of the current meshnp
  81203. * @returns the current mesh
  81204. */
  81205. releaseSubMeshes(): AbstractMesh;
  81206. /**
  81207. * Releases resources associated with this abstract mesh.
  81208. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81209. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81210. */
  81211. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81212. /**
  81213. * Adds the passed mesh as a child to the current mesh
  81214. * @param mesh defines the child mesh
  81215. * @returns the current mesh
  81216. */
  81217. addChild(mesh: AbstractMesh): AbstractMesh;
  81218. /**
  81219. * Removes the passed mesh from the current mesh children list
  81220. * @param mesh defines the child mesh
  81221. * @returns the current mesh
  81222. */
  81223. removeChild(mesh: AbstractMesh): AbstractMesh;
  81224. /** @hidden */
  81225. private _initFacetData;
  81226. /**
  81227. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81228. * This method can be called within the render loop.
  81229. * 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
  81230. * @returns the current mesh
  81231. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81232. */
  81233. updateFacetData(): AbstractMesh;
  81234. /**
  81235. * Returns the facetLocalNormals array.
  81236. * The normals are expressed in the mesh local spac
  81237. * @returns an array of Vector3
  81238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81239. */
  81240. getFacetLocalNormals(): Vector3[];
  81241. /**
  81242. * Returns the facetLocalPositions array.
  81243. * The facet positions are expressed in the mesh local space
  81244. * @returns an array of Vector3
  81245. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81246. */
  81247. getFacetLocalPositions(): Vector3[];
  81248. /**
  81249. * Returns the facetLocalPartioning array
  81250. * @returns an array of array of numbers
  81251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81252. */
  81253. getFacetLocalPartitioning(): number[][];
  81254. /**
  81255. * Returns the i-th facet position in the world system.
  81256. * This method allocates a new Vector3 per call
  81257. * @param i defines the facet index
  81258. * @returns a new Vector3
  81259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81260. */
  81261. getFacetPosition(i: number): Vector3;
  81262. /**
  81263. * Sets the reference Vector3 with the i-th facet position in the world system
  81264. * @param i defines the facet index
  81265. * @param ref defines the target vector
  81266. * @returns the current mesh
  81267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81268. */
  81269. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81270. /**
  81271. * Returns the i-th facet normal in the world system.
  81272. * This method allocates a new Vector3 per call
  81273. * @param i defines the facet index
  81274. * @returns a new Vector3
  81275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81276. */
  81277. getFacetNormal(i: number): Vector3;
  81278. /**
  81279. * Sets the reference Vector3 with the i-th facet normal in the world system
  81280. * @param i defines the facet index
  81281. * @param ref defines the target vector
  81282. * @returns the current mesh
  81283. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81284. */
  81285. getFacetNormalToRef(i: number, ref: Vector3): this;
  81286. /**
  81287. * 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)
  81288. * @param x defines x coordinate
  81289. * @param y defines y coordinate
  81290. * @param z defines z coordinate
  81291. * @returns the array of facet indexes
  81292. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81293. */
  81294. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81295. /**
  81296. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81297. * @param projected sets as the (x,y,z) world projection on the facet
  81298. * @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
  81299. * @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
  81300. * @param x defines x coordinate
  81301. * @param y defines y coordinate
  81302. * @param z defines z coordinate
  81303. * @returns the face index if found (or null instead)
  81304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81305. */
  81306. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81307. /**
  81308. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81309. * @param projected sets as the (x,y,z) local projection on the facet
  81310. * @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
  81311. * @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
  81312. * @param x defines x coordinate
  81313. * @param y defines y coordinate
  81314. * @param z defines z coordinate
  81315. * @returns the face index if found (or null instead)
  81316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81317. */
  81318. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81319. /**
  81320. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81321. * @returns the parameters
  81322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81323. */
  81324. getFacetDataParameters(): any;
  81325. /**
  81326. * Disables the feature FacetData and frees the related memory
  81327. * @returns the current mesh
  81328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81329. */
  81330. disableFacetData(): AbstractMesh;
  81331. /**
  81332. * Updates the AbstractMesh indices array
  81333. * @param indices defines the data source
  81334. * @returns the current mesh
  81335. */
  81336. updateIndices(indices: IndicesArray): AbstractMesh;
  81337. /**
  81338. * Creates new normals data for the mesh
  81339. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81340. * @returns the current mesh
  81341. */
  81342. createNormals(updatable: boolean): AbstractMesh;
  81343. /**
  81344. * Align the mesh with a normal
  81345. * @param normal defines the normal to use
  81346. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81347. * @returns the current mesh
  81348. */
  81349. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81350. /** @hidden */
  81351. _checkOcclusionQuery(): boolean;
  81352. }
  81353. }
  81354. declare module BABYLON {
  81355. /**
  81356. * Interface used to define ActionEvent
  81357. */
  81358. export interface IActionEvent {
  81359. /** The mesh or sprite that triggered the action */
  81360. source: any;
  81361. /** The X mouse cursor position at the time of the event */
  81362. pointerX: number;
  81363. /** The Y mouse cursor position at the time of the event */
  81364. pointerY: number;
  81365. /** The mesh that is currently pointed at (can be null) */
  81366. meshUnderPointer: Nullable<AbstractMesh>;
  81367. /** the original (browser) event that triggered the ActionEvent */
  81368. sourceEvent?: any;
  81369. /** additional data for the event */
  81370. additionalData?: any;
  81371. }
  81372. /**
  81373. * ActionEvent is the event being sent when an action is triggered.
  81374. */
  81375. export class ActionEvent implements IActionEvent {
  81376. /** The mesh or sprite that triggered the action */
  81377. source: any;
  81378. /** The X mouse cursor position at the time of the event */
  81379. pointerX: number;
  81380. /** The Y mouse cursor position at the time of the event */
  81381. pointerY: number;
  81382. /** The mesh that is currently pointed at (can be null) */
  81383. meshUnderPointer: Nullable<AbstractMesh>;
  81384. /** the original (browser) event that triggered the ActionEvent */
  81385. sourceEvent?: any;
  81386. /** additional data for the event */
  81387. additionalData?: any;
  81388. /**
  81389. * Creates a new ActionEvent
  81390. * @param source The mesh or sprite that triggered the action
  81391. * @param pointerX The X mouse cursor position at the time of the event
  81392. * @param pointerY The Y mouse cursor position at the time of the event
  81393. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81394. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81395. * @param additionalData additional data for the event
  81396. */
  81397. constructor(
  81398. /** The mesh or sprite that triggered the action */
  81399. source: any,
  81400. /** The X mouse cursor position at the time of the event */
  81401. pointerX: number,
  81402. /** The Y mouse cursor position at the time of the event */
  81403. pointerY: number,
  81404. /** The mesh that is currently pointed at (can be null) */
  81405. meshUnderPointer: Nullable<AbstractMesh>,
  81406. /** the original (browser) event that triggered the ActionEvent */
  81407. sourceEvent?: any,
  81408. /** additional data for the event */
  81409. additionalData?: any);
  81410. /**
  81411. * Helper function to auto-create an ActionEvent from a source mesh.
  81412. * @param source The source mesh that triggered the event
  81413. * @param evt The original (browser) event
  81414. * @param additionalData additional data for the event
  81415. * @returns the new ActionEvent
  81416. */
  81417. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81418. /**
  81419. * Helper function to auto-create an ActionEvent from a source sprite
  81420. * @param source The source sprite that triggered the event
  81421. * @param scene Scene associated with the sprite
  81422. * @param evt The original (browser) event
  81423. * @param additionalData additional data for the event
  81424. * @returns the new ActionEvent
  81425. */
  81426. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81427. /**
  81428. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81429. * @param scene the scene where the event occurred
  81430. * @param evt The original (browser) event
  81431. * @returns the new ActionEvent
  81432. */
  81433. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81434. /**
  81435. * Helper function to auto-create an ActionEvent from a primitive
  81436. * @param prim defines the target primitive
  81437. * @param pointerPos defines the pointer position
  81438. * @param evt The original (browser) event
  81439. * @param additionalData additional data for the event
  81440. * @returns the new ActionEvent
  81441. */
  81442. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81443. }
  81444. }
  81445. declare module BABYLON {
  81446. /**
  81447. * Abstract class used to decouple action Manager from scene and meshes.
  81448. * Do not instantiate.
  81449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81450. */
  81451. export abstract class AbstractActionManager implements IDisposable {
  81452. /** Gets the list of active triggers */
  81453. static Triggers: {
  81454. [key: string]: number;
  81455. };
  81456. /** Gets the cursor to use when hovering items */
  81457. hoverCursor: string;
  81458. /** Gets the list of actions */
  81459. actions: IAction[];
  81460. /**
  81461. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81462. */
  81463. isRecursive: boolean;
  81464. /**
  81465. * Releases all associated resources
  81466. */
  81467. abstract dispose(): void;
  81468. /**
  81469. * Does this action manager has pointer triggers
  81470. */
  81471. abstract readonly hasPointerTriggers: boolean;
  81472. /**
  81473. * Does this action manager has pick triggers
  81474. */
  81475. abstract readonly hasPickTriggers: boolean;
  81476. /**
  81477. * Process a specific trigger
  81478. * @param trigger defines the trigger to process
  81479. * @param evt defines the event details to be processed
  81480. */
  81481. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81482. /**
  81483. * Does this action manager handles actions of any of the given triggers
  81484. * @param triggers defines the triggers to be tested
  81485. * @return a boolean indicating whether one (or more) of the triggers is handled
  81486. */
  81487. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81488. /**
  81489. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81490. * speed.
  81491. * @param triggerA defines the trigger to be tested
  81492. * @param triggerB defines the trigger to be tested
  81493. * @return a boolean indicating whether one (or more) of the triggers is handled
  81494. */
  81495. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81496. /**
  81497. * Does this action manager handles actions of a given trigger
  81498. * @param trigger defines the trigger to be tested
  81499. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81500. * @return whether the trigger is handled
  81501. */
  81502. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81503. /**
  81504. * Serialize this manager to a JSON object
  81505. * @param name defines the property name to store this manager
  81506. * @returns a JSON representation of this manager
  81507. */
  81508. abstract serialize(name: string): any;
  81509. /**
  81510. * Does exist one action manager with at least one trigger
  81511. **/
  81512. static readonly HasTriggers: boolean;
  81513. /**
  81514. * Does exist one action manager with at least one pick trigger
  81515. **/
  81516. static readonly HasPickTriggers: boolean;
  81517. /**
  81518. * Does exist one action manager that handles actions of a given trigger
  81519. * @param trigger defines the trigger to be tested
  81520. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81521. **/
  81522. static HasSpecificTrigger(trigger: number): boolean;
  81523. }
  81524. }
  81525. declare module BABYLON {
  81526. /**
  81527. * Defines how a node can be built from a string name.
  81528. */
  81529. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81530. /**
  81531. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81532. */
  81533. export class Node implements IBehaviorAware<Node> {
  81534. /** @hidden */
  81535. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81536. private static _NodeConstructors;
  81537. /**
  81538. * Add a new node constructor
  81539. * @param type defines the type name of the node to construct
  81540. * @param constructorFunc defines the constructor function
  81541. */
  81542. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81543. /**
  81544. * Returns a node constructor based on type name
  81545. * @param type defines the type name
  81546. * @param name defines the new node name
  81547. * @param scene defines the hosting scene
  81548. * @param options defines optional options to transmit to constructors
  81549. * @returns the new constructor or null
  81550. */
  81551. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81552. /**
  81553. * Gets or sets the name of the node
  81554. */
  81555. name: string;
  81556. /**
  81557. * Gets or sets the id of the node
  81558. */
  81559. id: string;
  81560. /**
  81561. * Gets or sets the unique id of the node
  81562. */
  81563. uniqueId: number;
  81564. /**
  81565. * Gets or sets a string used to store user defined state for the node
  81566. */
  81567. state: string;
  81568. /**
  81569. * Gets or sets an object used to store user defined information for the node
  81570. */
  81571. metadata: any;
  81572. /**
  81573. * For internal use only. Please do not use.
  81574. */
  81575. reservedDataStore: any;
  81576. /**
  81577. * Gets or sets a boolean used to define if the node must be serialized
  81578. */
  81579. doNotSerialize: boolean;
  81580. /** @hidden */
  81581. _isDisposed: boolean;
  81582. /**
  81583. * Gets a list of Animations associated with the node
  81584. */
  81585. animations: Animation[];
  81586. protected _ranges: {
  81587. [name: string]: Nullable<AnimationRange>;
  81588. };
  81589. /**
  81590. * Callback raised when the node is ready to be used
  81591. */
  81592. onReady: (node: Node) => void;
  81593. private _isEnabled;
  81594. private _isParentEnabled;
  81595. private _isReady;
  81596. /** @hidden */
  81597. _currentRenderId: number;
  81598. private _parentRenderId;
  81599. protected _childRenderId: number;
  81600. /** @hidden */
  81601. _waitingParentId: Nullable<string>;
  81602. /** @hidden */
  81603. _scene: Scene;
  81604. /** @hidden */
  81605. _cache: any;
  81606. private _parentNode;
  81607. private _children;
  81608. /** @hidden */
  81609. _worldMatrix: Matrix;
  81610. /** @hidden */
  81611. _worldMatrixDeterminant: number;
  81612. /** @hidden */
  81613. private _sceneRootNodesIndex;
  81614. /**
  81615. * Gets a boolean indicating if the node has been disposed
  81616. * @returns true if the node was disposed
  81617. */
  81618. isDisposed(): boolean;
  81619. /**
  81620. * Gets or sets the parent of the node
  81621. */
  81622. parent: Nullable<Node>;
  81623. private addToSceneRootNodes;
  81624. private removeFromSceneRootNodes;
  81625. private _animationPropertiesOverride;
  81626. /**
  81627. * Gets or sets the animation properties override
  81628. */
  81629. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81630. /**
  81631. * Gets a string idenfifying the name of the class
  81632. * @returns "Node" string
  81633. */
  81634. getClassName(): string;
  81635. /** @hidden */
  81636. readonly _isNode: boolean;
  81637. /**
  81638. * An event triggered when the mesh is disposed
  81639. */
  81640. onDisposeObservable: Observable<Node>;
  81641. private _onDisposeObserver;
  81642. /**
  81643. * Sets a callback that will be raised when the node will be disposed
  81644. */
  81645. onDispose: () => void;
  81646. /**
  81647. * Creates a new Node
  81648. * @param name the name and id to be given to this node
  81649. * @param scene the scene this node will be added to
  81650. * @param addToRootNodes the node will be added to scene.rootNodes
  81651. */
  81652. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81653. /**
  81654. * Gets the scene of the node
  81655. * @returns a scene
  81656. */
  81657. getScene(): Scene;
  81658. /**
  81659. * Gets the engine of the node
  81660. * @returns a Engine
  81661. */
  81662. getEngine(): Engine;
  81663. private _behaviors;
  81664. /**
  81665. * Attach a behavior to the node
  81666. * @see http://doc.babylonjs.com/features/behaviour
  81667. * @param behavior defines the behavior to attach
  81668. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81669. * @returns the current Node
  81670. */
  81671. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81672. /**
  81673. * Remove an attached behavior
  81674. * @see http://doc.babylonjs.com/features/behaviour
  81675. * @param behavior defines the behavior to attach
  81676. * @returns the current Node
  81677. */
  81678. removeBehavior(behavior: Behavior<Node>): Node;
  81679. /**
  81680. * Gets the list of attached behaviors
  81681. * @see http://doc.babylonjs.com/features/behaviour
  81682. */
  81683. readonly behaviors: Behavior<Node>[];
  81684. /**
  81685. * Gets an attached behavior by name
  81686. * @param name defines the name of the behavior to look for
  81687. * @see http://doc.babylonjs.com/features/behaviour
  81688. * @returns null if behavior was not found else the requested behavior
  81689. */
  81690. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81691. /**
  81692. * Returns the latest update of the World matrix
  81693. * @returns a Matrix
  81694. */
  81695. getWorldMatrix(): Matrix;
  81696. /** @hidden */
  81697. _getWorldMatrixDeterminant(): number;
  81698. /**
  81699. * Returns directly the latest state of the mesh World matrix.
  81700. * A Matrix is returned.
  81701. */
  81702. readonly worldMatrixFromCache: Matrix;
  81703. /** @hidden */
  81704. _initCache(): void;
  81705. /** @hidden */
  81706. updateCache(force?: boolean): void;
  81707. /** @hidden */
  81708. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81709. /** @hidden */
  81710. _updateCache(ignoreParentClass?: boolean): void;
  81711. /** @hidden */
  81712. _isSynchronized(): boolean;
  81713. /** @hidden */
  81714. _markSyncedWithParent(): void;
  81715. /** @hidden */
  81716. isSynchronizedWithParent(): boolean;
  81717. /** @hidden */
  81718. isSynchronized(): boolean;
  81719. /**
  81720. * Is this node ready to be used/rendered
  81721. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81722. * @return true if the node is ready
  81723. */
  81724. isReady(completeCheck?: boolean): boolean;
  81725. /**
  81726. * Is this node enabled?
  81727. * 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
  81728. * @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
  81729. * @return whether this node (and its parent) is enabled
  81730. */
  81731. isEnabled(checkAncestors?: boolean): boolean;
  81732. /** @hidden */
  81733. protected _syncParentEnabledState(): void;
  81734. /**
  81735. * Set the enabled state of this node
  81736. * @param value defines the new enabled state
  81737. */
  81738. setEnabled(value: boolean): void;
  81739. /**
  81740. * Is this node a descendant of the given node?
  81741. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  81742. * @param ancestor defines the parent node to inspect
  81743. * @returns a boolean indicating if this node is a descendant of the given node
  81744. */
  81745. isDescendantOf(ancestor: Node): boolean;
  81746. /** @hidden */
  81747. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  81748. /**
  81749. * Will return all nodes that have this node as ascendant
  81750. * @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
  81751. * @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
  81752. * @return all children nodes of all types
  81753. */
  81754. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  81755. /**
  81756. * Get all child-meshes of this node
  81757. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  81758. * @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
  81759. * @returns an array of AbstractMesh
  81760. */
  81761. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  81762. /**
  81763. * Get all direct children of this node
  81764. * @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
  81765. * @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)
  81766. * @returns an array of Node
  81767. */
  81768. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  81769. /** @hidden */
  81770. _setReady(state: boolean): void;
  81771. /**
  81772. * Get an animation by name
  81773. * @param name defines the name of the animation to look for
  81774. * @returns null if not found else the requested animation
  81775. */
  81776. getAnimationByName(name: string): Nullable<Animation>;
  81777. /**
  81778. * Creates an animation range for this node
  81779. * @param name defines the name of the range
  81780. * @param from defines the starting key
  81781. * @param to defines the end key
  81782. */
  81783. createAnimationRange(name: string, from: number, to: number): void;
  81784. /**
  81785. * Delete a specific animation range
  81786. * @param name defines the name of the range to delete
  81787. * @param deleteFrames defines if animation frames from the range must be deleted as well
  81788. */
  81789. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81790. /**
  81791. * Get an animation range by name
  81792. * @param name defines the name of the animation range to look for
  81793. * @returns null if not found else the requested animation range
  81794. */
  81795. getAnimationRange(name: string): Nullable<AnimationRange>;
  81796. /**
  81797. * Gets the list of all animation ranges defined on this node
  81798. * @returns an array
  81799. */
  81800. getAnimationRanges(): Nullable<AnimationRange>[];
  81801. /**
  81802. * Will start the animation sequence
  81803. * @param name defines the range frames for animation sequence
  81804. * @param loop defines if the animation should loop (false by default)
  81805. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  81806. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  81807. * @returns the object created for this animation. If range does not exist, it will return null
  81808. */
  81809. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81810. /**
  81811. * Serialize animation ranges into a JSON compatible object
  81812. * @returns serialization object
  81813. */
  81814. serializeAnimationRanges(): any;
  81815. /**
  81816. * Computes the world matrix of the node
  81817. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81818. * @returns the world matrix
  81819. */
  81820. computeWorldMatrix(force?: boolean): Matrix;
  81821. /**
  81822. * Releases resources associated with this node.
  81823. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81824. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81825. */
  81826. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81827. /**
  81828. * Parse animation range data from a serialization object and store them into a given node
  81829. * @param node defines where to store the animation ranges
  81830. * @param parsedNode defines the serialization object to read data from
  81831. * @param scene defines the hosting scene
  81832. */
  81833. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  81834. }
  81835. }
  81836. declare module BABYLON {
  81837. /**
  81838. * Class used to store any kind of animation
  81839. */
  81840. export class Animation {
  81841. /**Name of the animation */
  81842. name: string;
  81843. /**Property to animate */
  81844. targetProperty: string;
  81845. /**The frames per second of the animation */
  81846. framePerSecond: number;
  81847. /**The data type of the animation */
  81848. dataType: number;
  81849. /**The loop mode of the animation */
  81850. loopMode?: number | undefined;
  81851. /**Specifies if blending should be enabled */
  81852. enableBlending?: boolean | undefined;
  81853. /**
  81854. * Use matrix interpolation instead of using direct key value when animating matrices
  81855. */
  81856. static AllowMatricesInterpolation: boolean;
  81857. /**
  81858. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  81859. */
  81860. static AllowMatrixDecomposeForInterpolation: boolean;
  81861. /**
  81862. * Stores the key frames of the animation
  81863. */
  81864. private _keys;
  81865. /**
  81866. * Stores the easing function of the animation
  81867. */
  81868. private _easingFunction;
  81869. /**
  81870. * @hidden Internal use only
  81871. */
  81872. _runtimeAnimations: RuntimeAnimation[];
  81873. /**
  81874. * The set of event that will be linked to this animation
  81875. */
  81876. private _events;
  81877. /**
  81878. * Stores an array of target property paths
  81879. */
  81880. targetPropertyPath: string[];
  81881. /**
  81882. * Stores the blending speed of the animation
  81883. */
  81884. blendingSpeed: number;
  81885. /**
  81886. * Stores the animation ranges for the animation
  81887. */
  81888. private _ranges;
  81889. /**
  81890. * @hidden Internal use
  81891. */
  81892. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  81893. /**
  81894. * Sets up an animation
  81895. * @param property The property to animate
  81896. * @param animationType The animation type to apply
  81897. * @param framePerSecond The frames per second of the animation
  81898. * @param easingFunction The easing function used in the animation
  81899. * @returns The created animation
  81900. */
  81901. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  81902. /**
  81903. * Create and start an animation on a node
  81904. * @param name defines the name of the global animation that will be run on all nodes
  81905. * @param node defines the root node where the animation will take place
  81906. * @param targetProperty defines property to animate
  81907. * @param framePerSecond defines the number of frame per second yo use
  81908. * @param totalFrame defines the number of frames in total
  81909. * @param from defines the initial value
  81910. * @param to defines the final value
  81911. * @param loopMode defines which loop mode you want to use (off by default)
  81912. * @param easingFunction defines the easing function to use (linear by default)
  81913. * @param onAnimationEnd defines the callback to call when animation end
  81914. * @returns the animatable created for this animation
  81915. */
  81916. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81917. /**
  81918. * Create and start an animation on a node and its descendants
  81919. * @param name defines the name of the global animation that will be run on all nodes
  81920. * @param node defines the root node where the animation will take place
  81921. * @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
  81922. * @param targetProperty defines property to animate
  81923. * @param framePerSecond defines the number of frame per second to use
  81924. * @param totalFrame defines the number of frames in total
  81925. * @param from defines the initial value
  81926. * @param to defines the final value
  81927. * @param loopMode defines which loop mode you want to use (off by default)
  81928. * @param easingFunction defines the easing function to use (linear by default)
  81929. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81930. * @returns the list of animatables created for all nodes
  81931. * @example https://www.babylonjs-playground.com/#MH0VLI
  81932. */
  81933. 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[]>;
  81934. /**
  81935. * Creates a new animation, merges it with the existing animations and starts it
  81936. * @param name Name of the animation
  81937. * @param node Node which contains the scene that begins the animations
  81938. * @param targetProperty Specifies which property to animate
  81939. * @param framePerSecond The frames per second of the animation
  81940. * @param totalFrame The total number of frames
  81941. * @param from The frame at the beginning of the animation
  81942. * @param to The frame at the end of the animation
  81943. * @param loopMode Specifies the loop mode of the animation
  81944. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  81945. * @param onAnimationEnd Callback to run once the animation is complete
  81946. * @returns Nullable animation
  81947. */
  81948. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81949. /**
  81950. * Transition property of an host to the target Value
  81951. * @param property The property to transition
  81952. * @param targetValue The target Value of the property
  81953. * @param host The object where the property to animate belongs
  81954. * @param scene Scene used to run the animation
  81955. * @param frameRate Framerate (in frame/s) to use
  81956. * @param transition The transition type we want to use
  81957. * @param duration The duration of the animation, in milliseconds
  81958. * @param onAnimationEnd Callback trigger at the end of the animation
  81959. * @returns Nullable animation
  81960. */
  81961. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  81962. /**
  81963. * Return the array of runtime animations currently using this animation
  81964. */
  81965. readonly runtimeAnimations: RuntimeAnimation[];
  81966. /**
  81967. * Specifies if any of the runtime animations are currently running
  81968. */
  81969. readonly hasRunningRuntimeAnimations: boolean;
  81970. /**
  81971. * Initializes the animation
  81972. * @param name Name of the animation
  81973. * @param targetProperty Property to animate
  81974. * @param framePerSecond The frames per second of the animation
  81975. * @param dataType The data type of the animation
  81976. * @param loopMode The loop mode of the animation
  81977. * @param enableBlending Specifies if blending should be enabled
  81978. */
  81979. constructor(
  81980. /**Name of the animation */
  81981. name: string,
  81982. /**Property to animate */
  81983. targetProperty: string,
  81984. /**The frames per second of the animation */
  81985. framePerSecond: number,
  81986. /**The data type of the animation */
  81987. dataType: number,
  81988. /**The loop mode of the animation */
  81989. loopMode?: number | undefined,
  81990. /**Specifies if blending should be enabled */
  81991. enableBlending?: boolean | undefined);
  81992. /**
  81993. * Converts the animation to a string
  81994. * @param fullDetails support for multiple levels of logging within scene loading
  81995. * @returns String form of the animation
  81996. */
  81997. toString(fullDetails?: boolean): string;
  81998. /**
  81999. * Add an event to this animation
  82000. * @param event Event to add
  82001. */
  82002. addEvent(event: AnimationEvent): void;
  82003. /**
  82004. * Remove all events found at the given frame
  82005. * @param frame The frame to remove events from
  82006. */
  82007. removeEvents(frame: number): void;
  82008. /**
  82009. * Retrieves all the events from the animation
  82010. * @returns Events from the animation
  82011. */
  82012. getEvents(): AnimationEvent[];
  82013. /**
  82014. * Creates an animation range
  82015. * @param name Name of the animation range
  82016. * @param from Starting frame of the animation range
  82017. * @param to Ending frame of the animation
  82018. */
  82019. createRange(name: string, from: number, to: number): void;
  82020. /**
  82021. * Deletes an animation range by name
  82022. * @param name Name of the animation range to delete
  82023. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82024. */
  82025. deleteRange(name: string, deleteFrames?: boolean): void;
  82026. /**
  82027. * Gets the animation range by name, or null if not defined
  82028. * @param name Name of the animation range
  82029. * @returns Nullable animation range
  82030. */
  82031. getRange(name: string): Nullable<AnimationRange>;
  82032. /**
  82033. * Gets the key frames from the animation
  82034. * @returns The key frames of the animation
  82035. */
  82036. getKeys(): Array<IAnimationKey>;
  82037. /**
  82038. * Gets the highest frame rate of the animation
  82039. * @returns Highest frame rate of the animation
  82040. */
  82041. getHighestFrame(): number;
  82042. /**
  82043. * Gets the easing function of the animation
  82044. * @returns Easing function of the animation
  82045. */
  82046. getEasingFunction(): IEasingFunction;
  82047. /**
  82048. * Sets the easing function of the animation
  82049. * @param easingFunction A custom mathematical formula for animation
  82050. */
  82051. setEasingFunction(easingFunction: EasingFunction): void;
  82052. /**
  82053. * Interpolates a scalar linearly
  82054. * @param startValue Start value of the animation curve
  82055. * @param endValue End value of the animation curve
  82056. * @param gradient Scalar amount to interpolate
  82057. * @returns Interpolated scalar value
  82058. */
  82059. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82060. /**
  82061. * Interpolates a scalar cubically
  82062. * @param startValue Start value of the animation curve
  82063. * @param outTangent End tangent of the animation
  82064. * @param endValue End value of the animation curve
  82065. * @param inTangent Start tangent of the animation curve
  82066. * @param gradient Scalar amount to interpolate
  82067. * @returns Interpolated scalar value
  82068. */
  82069. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82070. /**
  82071. * Interpolates a quaternion using a spherical linear interpolation
  82072. * @param startValue Start value of the animation curve
  82073. * @param endValue End value of the animation curve
  82074. * @param gradient Scalar amount to interpolate
  82075. * @returns Interpolated quaternion value
  82076. */
  82077. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82078. /**
  82079. * Interpolates a quaternion cubically
  82080. * @param startValue Start value of the animation curve
  82081. * @param outTangent End tangent of the animation curve
  82082. * @param endValue End value of the animation curve
  82083. * @param inTangent Start tangent of the animation curve
  82084. * @param gradient Scalar amount to interpolate
  82085. * @returns Interpolated quaternion value
  82086. */
  82087. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82088. /**
  82089. * Interpolates a Vector3 linearl
  82090. * @param startValue Start value of the animation curve
  82091. * @param endValue End value of the animation curve
  82092. * @param gradient Scalar amount to interpolate
  82093. * @returns Interpolated scalar value
  82094. */
  82095. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82096. /**
  82097. * Interpolates a Vector3 cubically
  82098. * @param startValue Start value of the animation curve
  82099. * @param outTangent End tangent of the animation
  82100. * @param endValue End value of the animation curve
  82101. * @param inTangent Start tangent of the animation curve
  82102. * @param gradient Scalar amount to interpolate
  82103. * @returns InterpolatedVector3 value
  82104. */
  82105. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82106. /**
  82107. * Interpolates a Vector2 linearly
  82108. * @param startValue Start value of the animation curve
  82109. * @param endValue End value of the animation curve
  82110. * @param gradient Scalar amount to interpolate
  82111. * @returns Interpolated Vector2 value
  82112. */
  82113. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82114. /**
  82115. * Interpolates a Vector2 cubically
  82116. * @param startValue Start value of the animation curve
  82117. * @param outTangent End tangent of the animation
  82118. * @param endValue End value of the animation curve
  82119. * @param inTangent Start tangent of the animation curve
  82120. * @param gradient Scalar amount to interpolate
  82121. * @returns Interpolated Vector2 value
  82122. */
  82123. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82124. /**
  82125. * Interpolates a size linearly
  82126. * @param startValue Start value of the animation curve
  82127. * @param endValue End value of the animation curve
  82128. * @param gradient Scalar amount to interpolate
  82129. * @returns Interpolated Size value
  82130. */
  82131. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82132. /**
  82133. * Interpolates a Color3 linearly
  82134. * @param startValue Start value of the animation curve
  82135. * @param endValue End value of the animation curve
  82136. * @param gradient Scalar amount to interpolate
  82137. * @returns Interpolated Color3 value
  82138. */
  82139. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82140. /**
  82141. * @hidden Internal use only
  82142. */
  82143. _getKeyValue(value: any): any;
  82144. /**
  82145. * @hidden Internal use only
  82146. */
  82147. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82148. /**
  82149. * Defines the function to use to interpolate matrices
  82150. * @param startValue defines the start matrix
  82151. * @param endValue defines the end matrix
  82152. * @param gradient defines the gradient between both matrices
  82153. * @param result defines an optional target matrix where to store the interpolation
  82154. * @returns the interpolated matrix
  82155. */
  82156. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82157. /**
  82158. * Makes a copy of the animation
  82159. * @returns Cloned animation
  82160. */
  82161. clone(): Animation;
  82162. /**
  82163. * Sets the key frames of the animation
  82164. * @param values The animation key frames to set
  82165. */
  82166. setKeys(values: Array<IAnimationKey>): void;
  82167. /**
  82168. * Serializes the animation to an object
  82169. * @returns Serialized object
  82170. */
  82171. serialize(): any;
  82172. /**
  82173. * Float animation type
  82174. */
  82175. private static _ANIMATIONTYPE_FLOAT;
  82176. /**
  82177. * Vector3 animation type
  82178. */
  82179. private static _ANIMATIONTYPE_VECTOR3;
  82180. /**
  82181. * Quaternion animation type
  82182. */
  82183. private static _ANIMATIONTYPE_QUATERNION;
  82184. /**
  82185. * Matrix animation type
  82186. */
  82187. private static _ANIMATIONTYPE_MATRIX;
  82188. /**
  82189. * Color3 animation type
  82190. */
  82191. private static _ANIMATIONTYPE_COLOR3;
  82192. /**
  82193. * Vector2 animation type
  82194. */
  82195. private static _ANIMATIONTYPE_VECTOR2;
  82196. /**
  82197. * Size animation type
  82198. */
  82199. private static _ANIMATIONTYPE_SIZE;
  82200. /**
  82201. * Relative Loop Mode
  82202. */
  82203. private static _ANIMATIONLOOPMODE_RELATIVE;
  82204. /**
  82205. * Cycle Loop Mode
  82206. */
  82207. private static _ANIMATIONLOOPMODE_CYCLE;
  82208. /**
  82209. * Constant Loop Mode
  82210. */
  82211. private static _ANIMATIONLOOPMODE_CONSTANT;
  82212. /**
  82213. * Get the float animation type
  82214. */
  82215. static readonly ANIMATIONTYPE_FLOAT: number;
  82216. /**
  82217. * Get the Vector3 animation type
  82218. */
  82219. static readonly ANIMATIONTYPE_VECTOR3: number;
  82220. /**
  82221. * Get the Vector2 animation type
  82222. */
  82223. static readonly ANIMATIONTYPE_VECTOR2: number;
  82224. /**
  82225. * Get the Size animation type
  82226. */
  82227. static readonly ANIMATIONTYPE_SIZE: number;
  82228. /**
  82229. * Get the Quaternion animation type
  82230. */
  82231. static readonly ANIMATIONTYPE_QUATERNION: number;
  82232. /**
  82233. * Get the Matrix animation type
  82234. */
  82235. static readonly ANIMATIONTYPE_MATRIX: number;
  82236. /**
  82237. * Get the Color3 animation type
  82238. */
  82239. static readonly ANIMATIONTYPE_COLOR3: number;
  82240. /**
  82241. * Get the Relative Loop Mode
  82242. */
  82243. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82244. /**
  82245. * Get the Cycle Loop Mode
  82246. */
  82247. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82248. /**
  82249. * Get the Constant Loop Mode
  82250. */
  82251. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82252. /** @hidden */
  82253. static _UniversalLerp(left: any, right: any, amount: number): any;
  82254. /**
  82255. * Parses an animation object and creates an animation
  82256. * @param parsedAnimation Parsed animation object
  82257. * @returns Animation object
  82258. */
  82259. static Parse(parsedAnimation: any): Animation;
  82260. /**
  82261. * Appends the serialized animations from the source animations
  82262. * @param source Source containing the animations
  82263. * @param destination Target to store the animations
  82264. */
  82265. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82266. }
  82267. }
  82268. declare module BABYLON {
  82269. /**
  82270. * Base class of all the textures in babylon.
  82271. * It groups all the common properties the materials, post process, lights... might need
  82272. * in order to make a correct use of the texture.
  82273. */
  82274. export class BaseTexture implements IAnimatable {
  82275. /**
  82276. * Default anisotropic filtering level for the application.
  82277. * It is set to 4 as a good tradeoff between perf and quality.
  82278. */
  82279. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82280. /**
  82281. * Gets or sets the unique id of the texture
  82282. */
  82283. uniqueId: number;
  82284. /**
  82285. * Define the name of the texture.
  82286. */
  82287. name: string;
  82288. /**
  82289. * Gets or sets an object used to store user defined information.
  82290. */
  82291. metadata: any;
  82292. /**
  82293. * For internal use only. Please do not use.
  82294. */
  82295. reservedDataStore: any;
  82296. private _hasAlpha;
  82297. /**
  82298. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82299. */
  82300. hasAlpha: boolean;
  82301. /**
  82302. * Defines if the alpha value should be determined via the rgb values.
  82303. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82304. */
  82305. getAlphaFromRGB: boolean;
  82306. /**
  82307. * Intensity or strength of the texture.
  82308. * It is commonly used by materials to fine tune the intensity of the texture
  82309. */
  82310. level: number;
  82311. /**
  82312. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82313. * This is part of the texture as textures usually maps to one uv set.
  82314. */
  82315. coordinatesIndex: number;
  82316. private _coordinatesMode;
  82317. /**
  82318. * How a texture is mapped.
  82319. *
  82320. * | Value | Type | Description |
  82321. * | ----- | ----------------------------------- | ----------- |
  82322. * | 0 | EXPLICIT_MODE | |
  82323. * | 1 | SPHERICAL_MODE | |
  82324. * | 2 | PLANAR_MODE | |
  82325. * | 3 | CUBIC_MODE | |
  82326. * | 4 | PROJECTION_MODE | |
  82327. * | 5 | SKYBOX_MODE | |
  82328. * | 6 | INVCUBIC_MODE | |
  82329. * | 7 | EQUIRECTANGULAR_MODE | |
  82330. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82331. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82332. */
  82333. coordinatesMode: number;
  82334. /**
  82335. * | Value | Type | Description |
  82336. * | ----- | ------------------ | ----------- |
  82337. * | 0 | CLAMP_ADDRESSMODE | |
  82338. * | 1 | WRAP_ADDRESSMODE | |
  82339. * | 2 | MIRROR_ADDRESSMODE | |
  82340. */
  82341. wrapU: number;
  82342. /**
  82343. * | Value | Type | Description |
  82344. * | ----- | ------------------ | ----------- |
  82345. * | 0 | CLAMP_ADDRESSMODE | |
  82346. * | 1 | WRAP_ADDRESSMODE | |
  82347. * | 2 | MIRROR_ADDRESSMODE | |
  82348. */
  82349. wrapV: number;
  82350. /**
  82351. * | Value | Type | Description |
  82352. * | ----- | ------------------ | ----------- |
  82353. * | 0 | CLAMP_ADDRESSMODE | |
  82354. * | 1 | WRAP_ADDRESSMODE | |
  82355. * | 2 | MIRROR_ADDRESSMODE | |
  82356. */
  82357. wrapR: number;
  82358. /**
  82359. * With compliant hardware and browser (supporting anisotropic filtering)
  82360. * this defines the level of anisotropic filtering in the texture.
  82361. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82362. */
  82363. anisotropicFilteringLevel: number;
  82364. /**
  82365. * Define if the texture is a cube texture or if false a 2d texture.
  82366. */
  82367. isCube: boolean;
  82368. /**
  82369. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82370. */
  82371. is3D: boolean;
  82372. /**
  82373. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82374. * HDR texture are usually stored in linear space.
  82375. * This only impacts the PBR and Background materials
  82376. */
  82377. gammaSpace: boolean;
  82378. /**
  82379. * Gets whether or not the texture contains RGBD data.
  82380. */
  82381. readonly isRGBD: boolean;
  82382. /**
  82383. * Is Z inverted in the texture (useful in a cube texture).
  82384. */
  82385. invertZ: boolean;
  82386. /**
  82387. * Are mip maps generated for this texture or not.
  82388. */
  82389. readonly noMipmap: boolean;
  82390. /**
  82391. * @hidden
  82392. */
  82393. lodLevelInAlpha: boolean;
  82394. /**
  82395. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82396. */
  82397. lodGenerationOffset: number;
  82398. /**
  82399. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82400. */
  82401. lodGenerationScale: number;
  82402. /**
  82403. * Define if the texture is a render target.
  82404. */
  82405. isRenderTarget: boolean;
  82406. /**
  82407. * Define the unique id of the texture in the scene.
  82408. */
  82409. readonly uid: string;
  82410. /**
  82411. * Return a string representation of the texture.
  82412. * @returns the texture as a string
  82413. */
  82414. toString(): string;
  82415. /**
  82416. * Get the class name of the texture.
  82417. * @returns "BaseTexture"
  82418. */
  82419. getClassName(): string;
  82420. /**
  82421. * Define the list of animation attached to the texture.
  82422. */
  82423. animations: Animation[];
  82424. /**
  82425. * An event triggered when the texture is disposed.
  82426. */
  82427. onDisposeObservable: Observable<BaseTexture>;
  82428. private _onDisposeObserver;
  82429. /**
  82430. * Callback triggered when the texture has been disposed.
  82431. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82432. */
  82433. onDispose: () => void;
  82434. /**
  82435. * Define the current state of the loading sequence when in delayed load mode.
  82436. */
  82437. delayLoadState: number;
  82438. private _scene;
  82439. /** @hidden */
  82440. _texture: Nullable<InternalTexture>;
  82441. private _uid;
  82442. /**
  82443. * Define if the texture is preventinga material to render or not.
  82444. * If not and the texture is not ready, the engine will use a default black texture instead.
  82445. */
  82446. readonly isBlocking: boolean;
  82447. /**
  82448. * Instantiates a new BaseTexture.
  82449. * Base class of all the textures in babylon.
  82450. * It groups all the common properties the materials, post process, lights... might need
  82451. * in order to make a correct use of the texture.
  82452. * @param scene Define the scene the texture blongs to
  82453. */
  82454. constructor(scene: Nullable<Scene>);
  82455. /**
  82456. * Get the scene the texture belongs to.
  82457. * @returns the scene or null if undefined
  82458. */
  82459. getScene(): Nullable<Scene>;
  82460. /**
  82461. * Get the texture transform matrix used to offset tile the texture for istance.
  82462. * @returns the transformation matrix
  82463. */
  82464. getTextureMatrix(): Matrix;
  82465. /**
  82466. * Get the texture reflection matrix used to rotate/transform the reflection.
  82467. * @returns the reflection matrix
  82468. */
  82469. getReflectionTextureMatrix(): Matrix;
  82470. /**
  82471. * Get the underlying lower level texture from Babylon.
  82472. * @returns the insternal texture
  82473. */
  82474. getInternalTexture(): Nullable<InternalTexture>;
  82475. /**
  82476. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82477. * @returns true if ready or not blocking
  82478. */
  82479. isReadyOrNotBlocking(): boolean;
  82480. /**
  82481. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82482. * @returns true if fully ready
  82483. */
  82484. isReady(): boolean;
  82485. private _cachedSize;
  82486. /**
  82487. * Get the size of the texture.
  82488. * @returns the texture size.
  82489. */
  82490. getSize(): ISize;
  82491. /**
  82492. * Get the base size of the texture.
  82493. * It can be different from the size if the texture has been resized for POT for instance
  82494. * @returns the base size
  82495. */
  82496. getBaseSize(): ISize;
  82497. /**
  82498. * Update the sampling mode of the texture.
  82499. * Default is Trilinear mode.
  82500. *
  82501. * | Value | Type | Description |
  82502. * | ----- | ------------------ | ----------- |
  82503. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82504. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82505. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82506. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82507. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82508. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82509. * | 7 | NEAREST_LINEAR | |
  82510. * | 8 | NEAREST_NEAREST | |
  82511. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82512. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82513. * | 11 | LINEAR_LINEAR | |
  82514. * | 12 | LINEAR_NEAREST | |
  82515. *
  82516. * > _mag_: magnification filter (close to the viewer)
  82517. * > _min_: minification filter (far from the viewer)
  82518. * > _mip_: filter used between mip map levels
  82519. *@param samplingMode Define the new sampling mode of the texture
  82520. */
  82521. updateSamplingMode(samplingMode: number): void;
  82522. /**
  82523. * Scales the texture if is `canRescale()`
  82524. * @param ratio the resize factor we want to use to rescale
  82525. */
  82526. scale(ratio: number): void;
  82527. /**
  82528. * Get if the texture can rescale.
  82529. */
  82530. readonly canRescale: boolean;
  82531. /** @hidden */
  82532. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  82533. /** @hidden */
  82534. _rebuild(): void;
  82535. /**
  82536. * Triggers the load sequence in delayed load mode.
  82537. */
  82538. delayLoad(): void;
  82539. /**
  82540. * Clones the texture.
  82541. * @returns the cloned texture
  82542. */
  82543. clone(): Nullable<BaseTexture>;
  82544. /**
  82545. * Get the texture underlying type (INT, FLOAT...)
  82546. */
  82547. readonly textureType: number;
  82548. /**
  82549. * Get the texture underlying format (RGB, RGBA...)
  82550. */
  82551. readonly textureFormat: number;
  82552. /**
  82553. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82554. * This will returns an RGBA array buffer containing either in values (0-255) or
  82555. * float values (0-1) depending of the underlying buffer type.
  82556. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82557. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82558. * @param buffer defines a user defined buffer to fill with data (can be null)
  82559. * @returns The Array buffer containing the pixels data.
  82560. */
  82561. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82562. /**
  82563. * Release and destroy the underlying lower level texture aka internalTexture.
  82564. */
  82565. releaseInternalTexture(): void;
  82566. /**
  82567. * Get the polynomial representation of the texture data.
  82568. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82569. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82570. */
  82571. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82572. /** @hidden */
  82573. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82574. /** @hidden */
  82575. readonly _lodTextureMid: Nullable<BaseTexture>;
  82576. /** @hidden */
  82577. readonly _lodTextureLow: Nullable<BaseTexture>;
  82578. /**
  82579. * Dispose the texture and release its associated resources.
  82580. */
  82581. dispose(): void;
  82582. /**
  82583. * Serialize the texture into a JSON representation that can be parsed later on.
  82584. * @returns the JSON representation of the texture
  82585. */
  82586. serialize(): any;
  82587. /**
  82588. * Helper function to be called back once a list of texture contains only ready textures.
  82589. * @param textures Define the list of textures to wait for
  82590. * @param callback Define the callback triggered once the entire list will be ready
  82591. */
  82592. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82593. }
  82594. }
  82595. declare module BABYLON {
  82596. /**
  82597. * Uniform buffer objects.
  82598. *
  82599. * Handles blocks of uniform on the GPU.
  82600. *
  82601. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82602. *
  82603. * For more information, please refer to :
  82604. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82605. */
  82606. export class UniformBuffer {
  82607. private _engine;
  82608. private _buffer;
  82609. private _data;
  82610. private _bufferData;
  82611. private _dynamic?;
  82612. private _uniformLocations;
  82613. private _uniformSizes;
  82614. private _uniformLocationPointer;
  82615. private _needSync;
  82616. private _noUBO;
  82617. private _currentEffect;
  82618. private static _MAX_UNIFORM_SIZE;
  82619. private static _tempBuffer;
  82620. /**
  82621. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82622. * This is dynamic to allow compat with webgl 1 and 2.
  82623. * You will need to pass the name of the uniform as well as the value.
  82624. */
  82625. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82626. /**
  82627. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82628. * This is dynamic to allow compat with webgl 1 and 2.
  82629. * You will need to pass the name of the uniform as well as the value.
  82630. */
  82631. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82632. /**
  82633. * Lambda to Update a single float in a uniform buffer.
  82634. * This is dynamic to allow compat with webgl 1 and 2.
  82635. * You will need to pass the name of the uniform as well as the value.
  82636. */
  82637. updateFloat: (name: string, x: number) => void;
  82638. /**
  82639. * Lambda to Update a vec2 of float in a uniform buffer.
  82640. * This is dynamic to allow compat with webgl 1 and 2.
  82641. * You will need to pass the name of the uniform as well as the value.
  82642. */
  82643. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82644. /**
  82645. * Lambda to Update a vec3 of float in a uniform buffer.
  82646. * This is dynamic to allow compat with webgl 1 and 2.
  82647. * You will need to pass the name of the uniform as well as the value.
  82648. */
  82649. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82650. /**
  82651. * Lambda to Update a vec4 of float in a uniform buffer.
  82652. * This is dynamic to allow compat with webgl 1 and 2.
  82653. * You will need to pass the name of the uniform as well as the value.
  82654. */
  82655. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82656. /**
  82657. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82658. * This is dynamic to allow compat with webgl 1 and 2.
  82659. * You will need to pass the name of the uniform as well as the value.
  82660. */
  82661. updateMatrix: (name: string, mat: Matrix) => void;
  82662. /**
  82663. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82664. * This is dynamic to allow compat with webgl 1 and 2.
  82665. * You will need to pass the name of the uniform as well as the value.
  82666. */
  82667. updateVector3: (name: string, vector: Vector3) => void;
  82668. /**
  82669. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82670. * This is dynamic to allow compat with webgl 1 and 2.
  82671. * You will need to pass the name of the uniform as well as the value.
  82672. */
  82673. updateVector4: (name: string, vector: Vector4) => void;
  82674. /**
  82675. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82676. * This is dynamic to allow compat with webgl 1 and 2.
  82677. * You will need to pass the name of the uniform as well as the value.
  82678. */
  82679. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82680. /**
  82681. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82682. * This is dynamic to allow compat with webgl 1 and 2.
  82683. * You will need to pass the name of the uniform as well as the value.
  82684. */
  82685. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82686. /**
  82687. * Instantiates a new Uniform buffer objects.
  82688. *
  82689. * Handles blocks of uniform on the GPU.
  82690. *
  82691. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82692. *
  82693. * For more information, please refer to :
  82694. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82695. * @param engine Define the engine the buffer is associated with
  82696. * @param data Define the data contained in the buffer
  82697. * @param dynamic Define if the buffer is updatable
  82698. */
  82699. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82700. /**
  82701. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82702. * or just falling back on setUniformXXX calls.
  82703. */
  82704. readonly useUbo: boolean;
  82705. /**
  82706. * Indicates if the WebGL underlying uniform buffer is in sync
  82707. * with the javascript cache data.
  82708. */
  82709. readonly isSync: boolean;
  82710. /**
  82711. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82712. * Also, a dynamic UniformBuffer will disable cache verification and always
  82713. * update the underlying WebGL uniform buffer to the GPU.
  82714. * @returns if Dynamic, otherwise false
  82715. */
  82716. isDynamic(): boolean;
  82717. /**
  82718. * The data cache on JS side.
  82719. * @returns the underlying data as a float array
  82720. */
  82721. getData(): Float32Array;
  82722. /**
  82723. * The underlying WebGL Uniform buffer.
  82724. * @returns the webgl buffer
  82725. */
  82726. getBuffer(): Nullable<WebGLBuffer>;
  82727. /**
  82728. * std140 layout specifies how to align data within an UBO structure.
  82729. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  82730. * for specs.
  82731. */
  82732. private _fillAlignment;
  82733. /**
  82734. * Adds an uniform in the buffer.
  82735. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  82736. * for the layout to be correct !
  82737. * @param name Name of the uniform, as used in the uniform block in the shader.
  82738. * @param size Data size, or data directly.
  82739. */
  82740. addUniform(name: string, size: number | number[]): void;
  82741. /**
  82742. * Adds a Matrix 4x4 to the uniform buffer.
  82743. * @param name Name of the uniform, as used in the uniform block in the shader.
  82744. * @param mat A 4x4 matrix.
  82745. */
  82746. addMatrix(name: string, mat: Matrix): void;
  82747. /**
  82748. * Adds a vec2 to the uniform buffer.
  82749. * @param name Name of the uniform, as used in the uniform block in the shader.
  82750. * @param x Define the x component value of the vec2
  82751. * @param y Define the y component value of the vec2
  82752. */
  82753. addFloat2(name: string, x: number, y: number): void;
  82754. /**
  82755. * Adds a vec3 to the uniform buffer.
  82756. * @param name Name of the uniform, as used in the uniform block in the shader.
  82757. * @param x Define the x component value of the vec3
  82758. * @param y Define the y component value of the vec3
  82759. * @param z Define the z component value of the vec3
  82760. */
  82761. addFloat3(name: string, x: number, y: number, z: number): void;
  82762. /**
  82763. * Adds a vec3 to the uniform buffer.
  82764. * @param name Name of the uniform, as used in the uniform block in the shader.
  82765. * @param color Define the vec3 from a Color
  82766. */
  82767. addColor3(name: string, color: Color3): void;
  82768. /**
  82769. * Adds a vec4 to the uniform buffer.
  82770. * @param name Name of the uniform, as used in the uniform block in the shader.
  82771. * @param color Define the rgb components from a Color
  82772. * @param alpha Define the a component of the vec4
  82773. */
  82774. addColor4(name: string, color: Color3, alpha: number): void;
  82775. /**
  82776. * Adds a vec3 to the uniform buffer.
  82777. * @param name Name of the uniform, as used in the uniform block in the shader.
  82778. * @param vector Define the vec3 components from a Vector
  82779. */
  82780. addVector3(name: string, vector: Vector3): void;
  82781. /**
  82782. * Adds a Matrix 3x3 to the uniform buffer.
  82783. * @param name Name of the uniform, as used in the uniform block in the shader.
  82784. */
  82785. addMatrix3x3(name: string): void;
  82786. /**
  82787. * Adds a Matrix 2x2 to the uniform buffer.
  82788. * @param name Name of the uniform, as used in the uniform block in the shader.
  82789. */
  82790. addMatrix2x2(name: string): void;
  82791. /**
  82792. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  82793. */
  82794. create(): void;
  82795. /** @hidden */
  82796. _rebuild(): void;
  82797. /**
  82798. * Updates the WebGL Uniform Buffer on the GPU.
  82799. * If the `dynamic` flag is set to true, no cache comparison is done.
  82800. * Otherwise, the buffer will be updated only if the cache differs.
  82801. */
  82802. update(): void;
  82803. /**
  82804. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  82805. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82806. * @param data Define the flattened data
  82807. * @param size Define the size of the data.
  82808. */
  82809. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  82810. private _updateMatrix3x3ForUniform;
  82811. private _updateMatrix3x3ForEffect;
  82812. private _updateMatrix2x2ForEffect;
  82813. private _updateMatrix2x2ForUniform;
  82814. private _updateFloatForEffect;
  82815. private _updateFloatForUniform;
  82816. private _updateFloat2ForEffect;
  82817. private _updateFloat2ForUniform;
  82818. private _updateFloat3ForEffect;
  82819. private _updateFloat3ForUniform;
  82820. private _updateFloat4ForEffect;
  82821. private _updateFloat4ForUniform;
  82822. private _updateMatrixForEffect;
  82823. private _updateMatrixForUniform;
  82824. private _updateVector3ForEffect;
  82825. private _updateVector3ForUniform;
  82826. private _updateVector4ForEffect;
  82827. private _updateVector4ForUniform;
  82828. private _updateColor3ForEffect;
  82829. private _updateColor3ForUniform;
  82830. private _updateColor4ForEffect;
  82831. private _updateColor4ForUniform;
  82832. /**
  82833. * Sets a sampler uniform on the effect.
  82834. * @param name Define the name of the sampler.
  82835. * @param texture Define the texture to set in the sampler
  82836. */
  82837. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  82838. /**
  82839. * Directly updates the value of the uniform in the cache AND on the GPU.
  82840. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82841. * @param data Define the flattened data
  82842. */
  82843. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  82844. /**
  82845. * Binds this uniform buffer to an effect.
  82846. * @param effect Define the effect to bind the buffer to
  82847. * @param name Name of the uniform block in the shader.
  82848. */
  82849. bindToEffect(effect: Effect, name: string): void;
  82850. /**
  82851. * Disposes the uniform buffer.
  82852. */
  82853. dispose(): void;
  82854. }
  82855. }
  82856. declare module BABYLON {
  82857. /**
  82858. * This represents the required contract to create a new type of texture loader.
  82859. */
  82860. export interface IInternalTextureLoader {
  82861. /**
  82862. * Defines wether the loader supports cascade loading the different faces.
  82863. */
  82864. supportCascades: boolean;
  82865. /**
  82866. * This returns if the loader support the current file information.
  82867. * @param extension defines the file extension of the file being loaded
  82868. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82869. * @param fallback defines the fallback internal texture if any
  82870. * @param isBase64 defines whether the texture is encoded as a base64
  82871. * @param isBuffer defines whether the texture data are stored as a buffer
  82872. * @returns true if the loader can load the specified file
  82873. */
  82874. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  82875. /**
  82876. * Transform the url before loading if required.
  82877. * @param rootUrl the url of the texture
  82878. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82879. * @returns the transformed texture
  82880. */
  82881. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  82882. /**
  82883. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  82884. * @param rootUrl the url of the texture
  82885. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82886. * @returns the fallback texture
  82887. */
  82888. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  82889. /**
  82890. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  82891. * @param data contains the texture data
  82892. * @param texture defines the BabylonJS internal texture
  82893. * @param createPolynomials will be true if polynomials have been requested
  82894. * @param onLoad defines the callback to trigger once the texture is ready
  82895. * @param onError defines the callback to trigger in case of error
  82896. */
  82897. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  82898. /**
  82899. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  82900. * @param data contains the texture data
  82901. * @param texture defines the BabylonJS internal texture
  82902. * @param callback defines the method to call once ready to upload
  82903. */
  82904. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  82905. }
  82906. }
  82907. declare module BABYLON {
  82908. /**
  82909. * Creation options of the multi render target texture.
  82910. */
  82911. export interface IMultiRenderTargetOptions {
  82912. /**
  82913. * Define if the texture needs to create mip maps after render.
  82914. */
  82915. generateMipMaps?: boolean;
  82916. /**
  82917. * Define the types of all the draw buffers we want to create
  82918. */
  82919. types?: number[];
  82920. /**
  82921. * Define the sampling modes of all the draw buffers we want to create
  82922. */
  82923. samplingModes?: number[];
  82924. /**
  82925. * Define if a depth buffer is required
  82926. */
  82927. generateDepthBuffer?: boolean;
  82928. /**
  82929. * Define if a stencil buffer is required
  82930. */
  82931. generateStencilBuffer?: boolean;
  82932. /**
  82933. * Define if a depth texture is required instead of a depth buffer
  82934. */
  82935. generateDepthTexture?: boolean;
  82936. /**
  82937. * Define the number of desired draw buffers
  82938. */
  82939. textureCount?: number;
  82940. /**
  82941. * Define if aspect ratio should be adapted to the texture or stay the scene one
  82942. */
  82943. doNotChangeAspectRatio?: boolean;
  82944. /**
  82945. * Define the default type of the buffers we are creating
  82946. */
  82947. defaultType?: number;
  82948. }
  82949. /**
  82950. * A multi render target, like a render target provides the ability to render to a texture.
  82951. * Unlike the render target, it can render to several draw buffers in one draw.
  82952. * This is specially interesting in deferred rendering or for any effects requiring more than
  82953. * just one color from a single pass.
  82954. */
  82955. export class MultiRenderTarget extends RenderTargetTexture {
  82956. private _internalTextures;
  82957. private _textures;
  82958. private _multiRenderTargetOptions;
  82959. /**
  82960. * Get if draw buffers are currently supported by the used hardware and browser.
  82961. */
  82962. readonly isSupported: boolean;
  82963. /**
  82964. * Get the list of textures generated by the multi render target.
  82965. */
  82966. readonly textures: Texture[];
  82967. /**
  82968. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  82969. */
  82970. readonly depthTexture: Texture;
  82971. /**
  82972. * Set the wrapping mode on U of all the textures we are rendering to.
  82973. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82974. */
  82975. wrapU: number;
  82976. /**
  82977. * Set the wrapping mode on V of all the textures we are rendering to.
  82978. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82979. */
  82980. wrapV: number;
  82981. /**
  82982. * Instantiate a new multi render target texture.
  82983. * A multi render target, like a render target provides the ability to render to a texture.
  82984. * Unlike the render target, it can render to several draw buffers in one draw.
  82985. * This is specially interesting in deferred rendering or for any effects requiring more than
  82986. * just one color from a single pass.
  82987. * @param name Define the name of the texture
  82988. * @param size Define the size of the buffers to render to
  82989. * @param count Define the number of target we are rendering into
  82990. * @param scene Define the scene the texture belongs to
  82991. * @param options Define the options used to create the multi render target
  82992. */
  82993. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  82994. /** @hidden */
  82995. _rebuild(): void;
  82996. private _createInternalTextures;
  82997. private _createTextures;
  82998. /**
  82999. * Define the number of samples used if MSAA is enabled.
  83000. */
  83001. samples: number;
  83002. /**
  83003. * Resize all the textures in the multi render target.
  83004. * Be carrefull as it will recreate all the data in the new texture.
  83005. * @param size Define the new size
  83006. */
  83007. resize(size: any): void;
  83008. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83009. /**
  83010. * Dispose the render targets and their associated resources
  83011. */
  83012. dispose(): void;
  83013. /**
  83014. * Release all the underlying texture used as draw buffers.
  83015. */
  83016. releaseInternalTextures(): void;
  83017. }
  83018. }
  83019. declare module BABYLON {
  83020. /**
  83021. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83023. */
  83024. export class Analyser {
  83025. /**
  83026. * Gets or sets the smoothing
  83027. * @ignorenaming
  83028. */
  83029. SMOOTHING: number;
  83030. /**
  83031. * Gets or sets the FFT table size
  83032. * @ignorenaming
  83033. */
  83034. FFT_SIZE: number;
  83035. /**
  83036. * Gets or sets the bar graph amplitude
  83037. * @ignorenaming
  83038. */
  83039. BARGRAPHAMPLITUDE: number;
  83040. /**
  83041. * Gets or sets the position of the debug canvas
  83042. * @ignorenaming
  83043. */
  83044. DEBUGCANVASPOS: {
  83045. x: number;
  83046. y: number;
  83047. };
  83048. /**
  83049. * Gets or sets the debug canvas size
  83050. * @ignorenaming
  83051. */
  83052. DEBUGCANVASSIZE: {
  83053. width: number;
  83054. height: number;
  83055. };
  83056. private _byteFreqs;
  83057. private _byteTime;
  83058. private _floatFreqs;
  83059. private _webAudioAnalyser;
  83060. private _debugCanvas;
  83061. private _debugCanvasContext;
  83062. private _scene;
  83063. private _registerFunc;
  83064. private _audioEngine;
  83065. /**
  83066. * Creates a new analyser
  83067. * @param scene defines hosting scene
  83068. */
  83069. constructor(scene: Scene);
  83070. /**
  83071. * Get the number of data values you will have to play with for the visualization
  83072. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83073. * @returns a number
  83074. */
  83075. getFrequencyBinCount(): number;
  83076. /**
  83077. * Gets the current frequency data as a byte array
  83078. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83079. * @returns a Uint8Array
  83080. */
  83081. getByteFrequencyData(): Uint8Array;
  83082. /**
  83083. * Gets the current waveform as a byte array
  83084. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83085. * @returns a Uint8Array
  83086. */
  83087. getByteTimeDomainData(): Uint8Array;
  83088. /**
  83089. * Gets the current frequency data as a float array
  83090. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83091. * @returns a Float32Array
  83092. */
  83093. getFloatFrequencyData(): Float32Array;
  83094. /**
  83095. * Renders the debug canvas
  83096. */
  83097. drawDebugCanvas(): void;
  83098. /**
  83099. * Stops rendering the debug canvas and removes it
  83100. */
  83101. stopDebugCanvas(): void;
  83102. /**
  83103. * Connects two audio nodes
  83104. * @param inputAudioNode defines first node to connect
  83105. * @param outputAudioNode defines second node to connect
  83106. */
  83107. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83108. /**
  83109. * Releases all associated resources
  83110. */
  83111. dispose(): void;
  83112. }
  83113. }
  83114. declare module BABYLON {
  83115. /**
  83116. * This represents an audio engine and it is responsible
  83117. * to play, synchronize and analyse sounds throughout the application.
  83118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83119. */
  83120. export interface IAudioEngine extends IDisposable {
  83121. /**
  83122. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83123. */
  83124. readonly canUseWebAudio: boolean;
  83125. /**
  83126. * Gets the current AudioContext if available.
  83127. */
  83128. readonly audioContext: Nullable<AudioContext>;
  83129. /**
  83130. * The master gain node defines the global audio volume of your audio engine.
  83131. */
  83132. readonly masterGain: GainNode;
  83133. /**
  83134. * Gets whether or not mp3 are supported by your browser.
  83135. */
  83136. readonly isMP3supported: boolean;
  83137. /**
  83138. * Gets whether or not ogg are supported by your browser.
  83139. */
  83140. readonly isOGGsupported: boolean;
  83141. /**
  83142. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83143. * @ignoreNaming
  83144. */
  83145. WarnedWebAudioUnsupported: boolean;
  83146. /**
  83147. * Defines if the audio engine relies on a custom unlocked button.
  83148. * In this case, the embedded button will not be displayed.
  83149. */
  83150. useCustomUnlockedButton: boolean;
  83151. /**
  83152. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83153. */
  83154. readonly unlocked: boolean;
  83155. /**
  83156. * Event raised when audio has been unlocked on the browser.
  83157. */
  83158. onAudioUnlockedObservable: Observable<AudioEngine>;
  83159. /**
  83160. * Event raised when audio has been locked on the browser.
  83161. */
  83162. onAudioLockedObservable: Observable<AudioEngine>;
  83163. /**
  83164. * Flags the audio engine in Locked state.
  83165. * This happens due to new browser policies preventing audio to autoplay.
  83166. */
  83167. lock(): void;
  83168. /**
  83169. * Unlocks the audio engine once a user action has been done on the dom.
  83170. * This is helpful to resume play once browser policies have been satisfied.
  83171. */
  83172. unlock(): void;
  83173. }
  83174. /**
  83175. * This represents the default audio engine used in babylon.
  83176. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83178. */
  83179. export class AudioEngine implements IAudioEngine {
  83180. private _audioContext;
  83181. private _audioContextInitialized;
  83182. private _muteButton;
  83183. private _hostElement;
  83184. /**
  83185. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83186. */
  83187. canUseWebAudio: boolean;
  83188. /**
  83189. * The master gain node defines the global audio volume of your audio engine.
  83190. */
  83191. masterGain: GainNode;
  83192. /**
  83193. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83194. * @ignoreNaming
  83195. */
  83196. WarnedWebAudioUnsupported: boolean;
  83197. /**
  83198. * Gets whether or not mp3 are supported by your browser.
  83199. */
  83200. isMP3supported: boolean;
  83201. /**
  83202. * Gets whether or not ogg are supported by your browser.
  83203. */
  83204. isOGGsupported: boolean;
  83205. /**
  83206. * Gets whether audio has been unlocked on the device.
  83207. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83208. * a user interaction has happened.
  83209. */
  83210. unlocked: boolean;
  83211. /**
  83212. * Defines if the audio engine relies on a custom unlocked button.
  83213. * In this case, the embedded button will not be displayed.
  83214. */
  83215. useCustomUnlockedButton: boolean;
  83216. /**
  83217. * Event raised when audio has been unlocked on the browser.
  83218. */
  83219. onAudioUnlockedObservable: Observable<AudioEngine>;
  83220. /**
  83221. * Event raised when audio has been locked on the browser.
  83222. */
  83223. onAudioLockedObservable: Observable<AudioEngine>;
  83224. /**
  83225. * Gets the current AudioContext if available.
  83226. */
  83227. readonly audioContext: Nullable<AudioContext>;
  83228. private _connectedAnalyser;
  83229. /**
  83230. * Instantiates a new audio engine.
  83231. *
  83232. * There should be only one per page as some browsers restrict the number
  83233. * of audio contexts you can create.
  83234. * @param hostElement defines the host element where to display the mute icon if necessary
  83235. */
  83236. constructor(hostElement?: Nullable<HTMLElement>);
  83237. /**
  83238. * Flags the audio engine in Locked state.
  83239. * This happens due to new browser policies preventing audio to autoplay.
  83240. */
  83241. lock(): void;
  83242. /**
  83243. * Unlocks the audio engine once a user action has been done on the dom.
  83244. * This is helpful to resume play once browser policies have been satisfied.
  83245. */
  83246. unlock(): void;
  83247. private _resumeAudioContext;
  83248. private _initializeAudioContext;
  83249. private _tryToRun;
  83250. private _triggerRunningState;
  83251. private _triggerSuspendedState;
  83252. private _displayMuteButton;
  83253. private _moveButtonToTopLeft;
  83254. private _onResize;
  83255. private _hideMuteButton;
  83256. /**
  83257. * Destroy and release the resources associated with the audio ccontext.
  83258. */
  83259. dispose(): void;
  83260. /**
  83261. * Gets the global volume sets on the master gain.
  83262. * @returns the global volume if set or -1 otherwise
  83263. */
  83264. getGlobalVolume(): number;
  83265. /**
  83266. * Sets the global volume of your experience (sets on the master gain).
  83267. * @param newVolume Defines the new global volume of the application
  83268. */
  83269. setGlobalVolume(newVolume: number): void;
  83270. /**
  83271. * Connect the audio engine to an audio analyser allowing some amazing
  83272. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83274. * @param analyser The analyser to connect to the engine
  83275. */
  83276. connectToAnalyser(analyser: Analyser): void;
  83277. }
  83278. }
  83279. declare module BABYLON {
  83280. /**
  83281. * Interface used to present a loading screen while loading a scene
  83282. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83283. */
  83284. export interface ILoadingScreen {
  83285. /**
  83286. * Function called to display the loading screen
  83287. */
  83288. displayLoadingUI: () => void;
  83289. /**
  83290. * Function called to hide the loading screen
  83291. */
  83292. hideLoadingUI: () => void;
  83293. /**
  83294. * Gets or sets the color to use for the background
  83295. */
  83296. loadingUIBackgroundColor: string;
  83297. /**
  83298. * Gets or sets the text to display while loading
  83299. */
  83300. loadingUIText: string;
  83301. }
  83302. /**
  83303. * Class used for the default loading screen
  83304. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83305. */
  83306. export class DefaultLoadingScreen implements ILoadingScreen {
  83307. private _renderingCanvas;
  83308. private _loadingText;
  83309. private _loadingDivBackgroundColor;
  83310. private _loadingDiv;
  83311. private _loadingTextDiv;
  83312. /**
  83313. * Creates a new default loading screen
  83314. * @param _renderingCanvas defines the canvas used to render the scene
  83315. * @param _loadingText defines the default text to display
  83316. * @param _loadingDivBackgroundColor defines the default background color
  83317. */
  83318. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83319. /**
  83320. * Function called to display the loading screen
  83321. */
  83322. displayLoadingUI(): void;
  83323. /**
  83324. * Function called to hide the loading screen
  83325. */
  83326. hideLoadingUI(): void;
  83327. /**
  83328. * Gets or sets the text to display while loading
  83329. */
  83330. loadingUIText: string;
  83331. /**
  83332. * Gets or sets the color to use for the background
  83333. */
  83334. loadingUIBackgroundColor: string;
  83335. private _resizeLoadingUI;
  83336. }
  83337. }
  83338. declare module BABYLON {
  83339. /**
  83340. * Settings for finer control over video usage
  83341. */
  83342. export interface VideoTextureSettings {
  83343. /**
  83344. * Applies `autoplay` to video, if specified
  83345. */
  83346. autoPlay?: boolean;
  83347. /**
  83348. * Applies `loop` to video, if specified
  83349. */
  83350. loop?: boolean;
  83351. /**
  83352. * Automatically updates internal texture from video at every frame in the render loop
  83353. */
  83354. autoUpdateTexture: boolean;
  83355. /**
  83356. * Image src displayed during the video loading or until the user interacts with the video.
  83357. */
  83358. poster?: string;
  83359. }
  83360. /**
  83361. * If you want to display a video in your scene, this is the special texture for that.
  83362. * This special texture works similar to other textures, with the exception of a few parameters.
  83363. * @see https://doc.babylonjs.com/how_to/video_texture
  83364. */
  83365. export class VideoTexture extends Texture {
  83366. /**
  83367. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83368. */
  83369. readonly autoUpdateTexture: boolean;
  83370. /**
  83371. * The video instance used by the texture internally
  83372. */
  83373. readonly video: HTMLVideoElement;
  83374. private _onUserActionRequestedObservable;
  83375. /**
  83376. * Event triggerd when a dom action is required by the user to play the video.
  83377. * This happens due to recent changes in browser policies preventing video to auto start.
  83378. */
  83379. readonly onUserActionRequestedObservable: Observable<Texture>;
  83380. private _generateMipMaps;
  83381. private _engine;
  83382. private _stillImageCaptured;
  83383. private _displayingPosterTexture;
  83384. private _settings;
  83385. private _createInternalTextureOnEvent;
  83386. /**
  83387. * Creates a video texture.
  83388. * If you want to display a video in your scene, this is the special texture for that.
  83389. * This special texture works similar to other textures, with the exception of a few parameters.
  83390. * @see https://doc.babylonjs.com/how_to/video_texture
  83391. * @param name optional name, will detect from video source, if not defined
  83392. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83393. * @param scene is obviously the current scene.
  83394. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83395. * @param invertY is false by default but can be used to invert video on Y axis
  83396. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83397. * @param settings allows finer control over video usage
  83398. */
  83399. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83400. private _getName;
  83401. private _getVideo;
  83402. private _createInternalTexture;
  83403. private reset;
  83404. /**
  83405. * @hidden Internal method to initiate `update`.
  83406. */
  83407. _rebuild(): void;
  83408. /**
  83409. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83410. */
  83411. update(): void;
  83412. /**
  83413. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83414. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83415. */
  83416. updateTexture(isVisible: boolean): void;
  83417. protected _updateInternalTexture: () => void;
  83418. /**
  83419. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83420. * @param url New url.
  83421. */
  83422. updateURL(url: string): void;
  83423. /**
  83424. * Dispose the texture and release its associated resources.
  83425. */
  83426. dispose(): void;
  83427. /**
  83428. * Creates a video texture straight from a stream.
  83429. * @param scene Define the scene the texture should be created in
  83430. * @param stream Define the stream the texture should be created from
  83431. * @returns The created video texture as a promise
  83432. */
  83433. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83434. /**
  83435. * Creates a video texture straight from your WebCam video feed.
  83436. * @param scene Define the scene the texture should be created in
  83437. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83438. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83439. * @returns The created video texture as a promise
  83440. */
  83441. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83442. minWidth: number;
  83443. maxWidth: number;
  83444. minHeight: number;
  83445. maxHeight: number;
  83446. deviceId: string;
  83447. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83448. /**
  83449. * Creates a video texture straight from your WebCam video feed.
  83450. * @param scene Define the scene the texture should be created in
  83451. * @param onReady Define a callback to triggered once the texture will be ready
  83452. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83453. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83454. */
  83455. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83456. minWidth: number;
  83457. maxWidth: number;
  83458. minHeight: number;
  83459. maxHeight: number;
  83460. deviceId: string;
  83461. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83462. }
  83463. }
  83464. declare module BABYLON {
  83465. /**
  83466. * Interface for attribute information associated with buffer instanciation
  83467. */
  83468. export class InstancingAttributeInfo {
  83469. /**
  83470. * Index/offset of the attribute in the vertex shader
  83471. */
  83472. index: number;
  83473. /**
  83474. * size of the attribute, 1, 2, 3 or 4
  83475. */
  83476. attributeSize: number;
  83477. /**
  83478. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83479. * default is FLOAT
  83480. */
  83481. attribyteType: number;
  83482. /**
  83483. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83484. */
  83485. normalized: boolean;
  83486. /**
  83487. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83488. */
  83489. offset: number;
  83490. /**
  83491. * Name of the GLSL attribute, for debugging purpose only
  83492. */
  83493. attributeName: string;
  83494. }
  83495. /**
  83496. * Define options used to create a depth texture
  83497. */
  83498. export class DepthTextureCreationOptions {
  83499. /** Specifies whether or not a stencil should be allocated in the texture */
  83500. generateStencil?: boolean;
  83501. /** Specifies whether or not bilinear filtering is enable on the texture */
  83502. bilinearFiltering?: boolean;
  83503. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83504. comparisonFunction?: number;
  83505. /** Specifies if the created texture is a cube texture */
  83506. isCube?: boolean;
  83507. }
  83508. /**
  83509. * Class used to describe the capabilities of the engine relatively to the current browser
  83510. */
  83511. export class EngineCapabilities {
  83512. /** Maximum textures units per fragment shader */
  83513. maxTexturesImageUnits: number;
  83514. /** Maximum texture units per vertex shader */
  83515. maxVertexTextureImageUnits: number;
  83516. /** Maximum textures units in the entire pipeline */
  83517. maxCombinedTexturesImageUnits: number;
  83518. /** Maximum texture size */
  83519. maxTextureSize: number;
  83520. /** Maximum cube texture size */
  83521. maxCubemapTextureSize: number;
  83522. /** Maximum render texture size */
  83523. maxRenderTextureSize: number;
  83524. /** Maximum number of vertex attributes */
  83525. maxVertexAttribs: number;
  83526. /** Maximum number of varyings */
  83527. maxVaryingVectors: number;
  83528. /** Maximum number of uniforms per vertex shader */
  83529. maxVertexUniformVectors: number;
  83530. /** Maximum number of uniforms per fragment shader */
  83531. maxFragmentUniformVectors: number;
  83532. /** Defines if standard derivates (dx/dy) are supported */
  83533. standardDerivatives: boolean;
  83534. /** Defines if s3tc texture compression is supported */
  83535. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83536. /** Defines if pvrtc texture compression is supported */
  83537. pvrtc: any;
  83538. /** Defines if etc1 texture compression is supported */
  83539. etc1: any;
  83540. /** Defines if etc2 texture compression is supported */
  83541. etc2: any;
  83542. /** Defines if astc texture compression is supported */
  83543. astc: any;
  83544. /** Defines if float textures are supported */
  83545. textureFloat: boolean;
  83546. /** Defines if vertex array objects are supported */
  83547. vertexArrayObject: boolean;
  83548. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83549. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83550. /** Gets the maximum level of anisotropy supported */
  83551. maxAnisotropy: number;
  83552. /** Defines if instancing is supported */
  83553. instancedArrays: boolean;
  83554. /** Defines if 32 bits indices are supported */
  83555. uintIndices: boolean;
  83556. /** Defines if high precision shaders are supported */
  83557. highPrecisionShaderSupported: boolean;
  83558. /** Defines if depth reading in the fragment shader is supported */
  83559. fragmentDepthSupported: boolean;
  83560. /** Defines if float texture linear filtering is supported*/
  83561. textureFloatLinearFiltering: boolean;
  83562. /** Defines if rendering to float textures is supported */
  83563. textureFloatRender: boolean;
  83564. /** Defines if half float textures are supported*/
  83565. textureHalfFloat: boolean;
  83566. /** Defines if half float texture linear filtering is supported*/
  83567. textureHalfFloatLinearFiltering: boolean;
  83568. /** Defines if rendering to half float textures is supported */
  83569. textureHalfFloatRender: boolean;
  83570. /** Defines if textureLOD shader command is supported */
  83571. textureLOD: boolean;
  83572. /** Defines if draw buffers extension is supported */
  83573. drawBuffersExtension: boolean;
  83574. /** Defines if depth textures are supported */
  83575. depthTextureExtension: boolean;
  83576. /** Defines if float color buffer are supported */
  83577. colorBufferFloat: boolean;
  83578. /** Gets disjoint timer query extension (null if not supported) */
  83579. timerQuery: EXT_disjoint_timer_query;
  83580. /** Defines if timestamp can be used with timer query */
  83581. canUseTimestampForTimerQuery: boolean;
  83582. /** Function used to let the system compiles shaders in background */
  83583. parallelShaderCompile: {
  83584. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83585. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83586. COMPLETION_STATUS_KHR: number;
  83587. };
  83588. }
  83589. /** Interface defining initialization parameters for Engine class */
  83590. export interface EngineOptions extends WebGLContextAttributes {
  83591. /**
  83592. * Defines if the engine should no exceed a specified device ratio
  83593. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83594. */
  83595. limitDeviceRatio?: number;
  83596. /**
  83597. * Defines if webvr should be enabled automatically
  83598. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83599. */
  83600. autoEnableWebVR?: boolean;
  83601. /**
  83602. * Defines if webgl2 should be turned off even if supported
  83603. * @see http://doc.babylonjs.com/features/webgl2
  83604. */
  83605. disableWebGL2Support?: boolean;
  83606. /**
  83607. * Defines if webaudio should be initialized as well
  83608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83609. */
  83610. audioEngine?: boolean;
  83611. /**
  83612. * Defines if animations should run using a deterministic lock step
  83613. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83614. */
  83615. deterministicLockstep?: boolean;
  83616. /** Defines the maximum steps to use with deterministic lock step mode */
  83617. lockstepMaxSteps?: number;
  83618. /**
  83619. * Defines that engine should ignore context lost events
  83620. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83621. */
  83622. doNotHandleContextLost?: boolean;
  83623. /**
  83624. * Defines that engine should ignore modifying touch action attribute and style
  83625. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83626. */
  83627. doNotHandleTouchAction?: boolean;
  83628. }
  83629. /**
  83630. * Defines the interface used by display changed events
  83631. */
  83632. export interface IDisplayChangedEventArgs {
  83633. /** Gets the vrDisplay object (if any) */
  83634. vrDisplay: Nullable<any>;
  83635. /** Gets a boolean indicating if webVR is supported */
  83636. vrSupported: boolean;
  83637. }
  83638. /**
  83639. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83640. */
  83641. export class Engine {
  83642. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83643. static ExceptionList: ({
  83644. key: string;
  83645. capture: string;
  83646. captureConstraint: number;
  83647. targets: string[];
  83648. } | {
  83649. key: string;
  83650. capture: null;
  83651. captureConstraint: null;
  83652. targets: string[];
  83653. })[];
  83654. /** Gets the list of created engines */
  83655. static readonly Instances: Engine[];
  83656. /**
  83657. * Gets the latest created engine
  83658. */
  83659. static readonly LastCreatedEngine: Nullable<Engine>;
  83660. /**
  83661. * Gets the latest created scene
  83662. */
  83663. static readonly LastCreatedScene: Nullable<Scene>;
  83664. /**
  83665. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83666. * @param flag defines which part of the materials must be marked as dirty
  83667. * @param predicate defines a predicate used to filter which materials should be affected
  83668. */
  83669. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83670. /**
  83671. * Hidden
  83672. */
  83673. static _TextureLoaders: IInternalTextureLoader[];
  83674. /** Defines that alpha blending is disabled */
  83675. static readonly ALPHA_DISABLE: number;
  83676. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83677. static readonly ALPHA_ADD: number;
  83678. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83679. static readonly ALPHA_COMBINE: number;
  83680. /** Defines that alpha blending to DEST - SRC * DEST */
  83681. static readonly ALPHA_SUBTRACT: number;
  83682. /** Defines that alpha blending to SRC * DEST */
  83683. static readonly ALPHA_MULTIPLY: number;
  83684. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83685. static readonly ALPHA_MAXIMIZED: number;
  83686. /** Defines that alpha blending to SRC + DEST */
  83687. static readonly ALPHA_ONEONE: number;
  83688. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83689. static readonly ALPHA_PREMULTIPLIED: number;
  83690. /**
  83691. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83692. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83693. */
  83694. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83695. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83696. static readonly ALPHA_INTERPOLATE: number;
  83697. /**
  83698. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83699. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83700. */
  83701. static readonly ALPHA_SCREENMODE: number;
  83702. /** Defines that the ressource is not delayed*/
  83703. static readonly DELAYLOADSTATE_NONE: number;
  83704. /** Defines that the ressource was successfully delay loaded */
  83705. static readonly DELAYLOADSTATE_LOADED: number;
  83706. /** Defines that the ressource is currently delay loading */
  83707. static readonly DELAYLOADSTATE_LOADING: number;
  83708. /** Defines that the ressource is delayed and has not started loading */
  83709. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83710. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83711. static readonly NEVER: number;
  83712. /** 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 */
  83713. static readonly ALWAYS: number;
  83714. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83715. static readonly LESS: number;
  83716. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83717. static readonly EQUAL: number;
  83718. /** 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 */
  83719. static readonly LEQUAL: number;
  83720. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  83721. static readonly GREATER: number;
  83722. /** 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 */
  83723. static readonly GEQUAL: number;
  83724. /** 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 */
  83725. static readonly NOTEQUAL: number;
  83726. /** Passed to stencilOperation to specify that stencil value must be kept */
  83727. static readonly KEEP: number;
  83728. /** Passed to stencilOperation to specify that stencil value must be replaced */
  83729. static readonly REPLACE: number;
  83730. /** Passed to stencilOperation to specify that stencil value must be incremented */
  83731. static readonly INCR: number;
  83732. /** Passed to stencilOperation to specify that stencil value must be decremented */
  83733. static readonly DECR: number;
  83734. /** Passed to stencilOperation to specify that stencil value must be inverted */
  83735. static readonly INVERT: number;
  83736. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  83737. static readonly INCR_WRAP: number;
  83738. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  83739. static readonly DECR_WRAP: number;
  83740. /** Texture is not repeating outside of 0..1 UVs */
  83741. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  83742. /** Texture is repeating outside of 0..1 UVs */
  83743. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  83744. /** Texture is repeating and mirrored */
  83745. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  83746. /** ALPHA */
  83747. static readonly TEXTUREFORMAT_ALPHA: number;
  83748. /** LUMINANCE */
  83749. static readonly TEXTUREFORMAT_LUMINANCE: number;
  83750. /** LUMINANCE_ALPHA */
  83751. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  83752. /** RGB */
  83753. static readonly TEXTUREFORMAT_RGB: number;
  83754. /** RGBA */
  83755. static readonly TEXTUREFORMAT_RGBA: number;
  83756. /** RED */
  83757. static readonly TEXTUREFORMAT_RED: number;
  83758. /** RED (2nd reference) */
  83759. static readonly TEXTUREFORMAT_R: number;
  83760. /** RG */
  83761. static readonly TEXTUREFORMAT_RG: number;
  83762. /** RED_INTEGER */
  83763. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  83764. /** RED_INTEGER (2nd reference) */
  83765. static readonly TEXTUREFORMAT_R_INTEGER: number;
  83766. /** RG_INTEGER */
  83767. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  83768. /** RGB_INTEGER */
  83769. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  83770. /** RGBA_INTEGER */
  83771. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  83772. /** UNSIGNED_BYTE */
  83773. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  83774. /** UNSIGNED_BYTE (2nd reference) */
  83775. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  83776. /** FLOAT */
  83777. static readonly TEXTURETYPE_FLOAT: number;
  83778. /** HALF_FLOAT */
  83779. static readonly TEXTURETYPE_HALF_FLOAT: number;
  83780. /** BYTE */
  83781. static readonly TEXTURETYPE_BYTE: number;
  83782. /** SHORT */
  83783. static readonly TEXTURETYPE_SHORT: number;
  83784. /** UNSIGNED_SHORT */
  83785. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  83786. /** INT */
  83787. static readonly TEXTURETYPE_INT: number;
  83788. /** UNSIGNED_INT */
  83789. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  83790. /** UNSIGNED_SHORT_4_4_4_4 */
  83791. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  83792. /** UNSIGNED_SHORT_5_5_5_1 */
  83793. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  83794. /** UNSIGNED_SHORT_5_6_5 */
  83795. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  83796. /** UNSIGNED_INT_2_10_10_10_REV */
  83797. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  83798. /** UNSIGNED_INT_24_8 */
  83799. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  83800. /** UNSIGNED_INT_10F_11F_11F_REV */
  83801. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  83802. /** UNSIGNED_INT_5_9_9_9_REV */
  83803. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  83804. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  83805. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  83806. /** nearest is mag = nearest and min = nearest and mip = linear */
  83807. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  83808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83809. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  83810. /** Trilinear is mag = linear and min = linear and mip = linear */
  83811. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  83812. /** nearest is mag = nearest and min = nearest and mip = linear */
  83813. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  83814. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83815. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  83816. /** Trilinear is mag = linear and min = linear and mip = linear */
  83817. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  83818. /** mag = nearest and min = nearest and mip = nearest */
  83819. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  83820. /** mag = nearest and min = linear and mip = nearest */
  83821. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  83822. /** mag = nearest and min = linear and mip = linear */
  83823. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  83824. /** mag = nearest and min = linear and mip = none */
  83825. static readonly TEXTURE_NEAREST_LINEAR: number;
  83826. /** mag = nearest and min = nearest and mip = none */
  83827. static readonly TEXTURE_NEAREST_NEAREST: number;
  83828. /** mag = linear and min = nearest and mip = nearest */
  83829. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  83830. /** mag = linear and min = nearest and mip = linear */
  83831. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  83832. /** mag = linear and min = linear and mip = none */
  83833. static readonly TEXTURE_LINEAR_LINEAR: number;
  83834. /** mag = linear and min = nearest and mip = none */
  83835. static readonly TEXTURE_LINEAR_NEAREST: number;
  83836. /** Explicit coordinates mode */
  83837. static readonly TEXTURE_EXPLICIT_MODE: number;
  83838. /** Spherical coordinates mode */
  83839. static readonly TEXTURE_SPHERICAL_MODE: number;
  83840. /** Planar coordinates mode */
  83841. static readonly TEXTURE_PLANAR_MODE: number;
  83842. /** Cubic coordinates mode */
  83843. static readonly TEXTURE_CUBIC_MODE: number;
  83844. /** Projection coordinates mode */
  83845. static readonly TEXTURE_PROJECTION_MODE: number;
  83846. /** Skybox coordinates mode */
  83847. static readonly TEXTURE_SKYBOX_MODE: number;
  83848. /** Inverse Cubic coordinates mode */
  83849. static readonly TEXTURE_INVCUBIC_MODE: number;
  83850. /** Equirectangular coordinates mode */
  83851. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  83852. /** Equirectangular Fixed coordinates mode */
  83853. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  83854. /** Equirectangular Fixed Mirrored coordinates mode */
  83855. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83856. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  83857. static readonly SCALEMODE_FLOOR: number;
  83858. /** Defines that texture rescaling will look for the nearest power of 2 size */
  83859. static readonly SCALEMODE_NEAREST: number;
  83860. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  83861. static readonly SCALEMODE_CEILING: number;
  83862. /**
  83863. * Returns the current version of the framework
  83864. */
  83865. static readonly Version: string;
  83866. /**
  83867. * Returns a string describing the current engine
  83868. */
  83869. readonly description: string;
  83870. /**
  83871. * Gets or sets the epsilon value used by collision engine
  83872. */
  83873. static CollisionsEpsilon: number;
  83874. /**
  83875. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  83876. */
  83877. static ShadersRepository: string;
  83878. /**
  83879. * Method called to create the default loading screen.
  83880. * This can be overriden in your own app.
  83881. * @param canvas The rendering canvas element
  83882. * @returns The loading screen
  83883. */
  83884. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  83885. /**
  83886. * Method called to create the default rescale post process on each engine.
  83887. */
  83888. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  83889. /**
  83890. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  83891. */
  83892. forcePOTTextures: boolean;
  83893. /**
  83894. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  83895. */
  83896. isFullscreen: boolean;
  83897. /**
  83898. * Gets a boolean indicating if the pointer is currently locked
  83899. */
  83900. isPointerLock: boolean;
  83901. /**
  83902. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  83903. */
  83904. cullBackFaces: boolean;
  83905. /**
  83906. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  83907. */
  83908. renderEvenInBackground: boolean;
  83909. /**
  83910. * Gets or sets a boolean indicating that cache can be kept between frames
  83911. */
  83912. preventCacheWipeBetweenFrames: boolean;
  83913. /**
  83914. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  83915. **/
  83916. enableOfflineSupport: boolean;
  83917. /**
  83918. * 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)
  83919. **/
  83920. disableManifestCheck: boolean;
  83921. /**
  83922. * Gets the list of created scenes
  83923. */
  83924. scenes: Scene[];
  83925. /**
  83926. * Event raised when a new scene is created
  83927. */
  83928. onNewSceneAddedObservable: Observable<Scene>;
  83929. /**
  83930. * Gets the list of created postprocesses
  83931. */
  83932. postProcesses: PostProcess[];
  83933. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  83934. validateShaderPrograms: boolean;
  83935. /**
  83936. * Observable event triggered each time the rendering canvas is resized
  83937. */
  83938. onResizeObservable: Observable<Engine>;
  83939. /**
  83940. * Observable event triggered each time the canvas loses focus
  83941. */
  83942. onCanvasBlurObservable: Observable<Engine>;
  83943. /**
  83944. * Observable event triggered each time the canvas gains focus
  83945. */
  83946. onCanvasFocusObservable: Observable<Engine>;
  83947. /**
  83948. * Observable event triggered each time the canvas receives pointerout event
  83949. */
  83950. onCanvasPointerOutObservable: Observable<PointerEvent>;
  83951. /**
  83952. * Observable event triggered before each texture is initialized
  83953. */
  83954. onBeforeTextureInitObservable: Observable<Texture>;
  83955. private _vrDisplay;
  83956. private _vrSupported;
  83957. private _oldSize;
  83958. private _oldHardwareScaleFactor;
  83959. private _vrExclusivePointerMode;
  83960. private _webVRInitPromise;
  83961. /**
  83962. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83963. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83964. */
  83965. readonly isInVRExclusivePointerMode: boolean;
  83966. /**
  83967. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  83968. */
  83969. disableUniformBuffers: boolean;
  83970. /** @hidden */
  83971. _uniformBuffers: UniformBuffer[];
  83972. /**
  83973. * Gets a boolean indicating that the engine supports uniform buffers
  83974. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83975. */
  83976. readonly supportsUniformBuffers: boolean;
  83977. /**
  83978. * Observable raised when the engine begins a new frame
  83979. */
  83980. onBeginFrameObservable: Observable<Engine>;
  83981. /**
  83982. * If set, will be used to request the next animation frame for the render loop
  83983. */
  83984. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  83985. /**
  83986. * Observable raised when the engine ends the current frame
  83987. */
  83988. onEndFrameObservable: Observable<Engine>;
  83989. /**
  83990. * Observable raised when the engine is about to compile a shader
  83991. */
  83992. onBeforeShaderCompilationObservable: Observable<Engine>;
  83993. /**
  83994. * Observable raised when the engine has jsut compiled a shader
  83995. */
  83996. onAfterShaderCompilationObservable: Observable<Engine>;
  83997. /** @hidden */
  83998. _gl: WebGLRenderingContext;
  83999. private _renderingCanvas;
  84000. private _windowIsBackground;
  84001. private _webGLVersion;
  84002. /**
  84003. * Gets a boolean indicating that only power of 2 textures are supported
  84004. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84005. */
  84006. readonly needPOTTextures: boolean;
  84007. /** @hidden */
  84008. _badOS: boolean;
  84009. /** @hidden */
  84010. _badDesktopOS: boolean;
  84011. /**
  84012. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84013. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84014. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84015. */
  84016. disableTextureBindingOptimization: boolean;
  84017. /**
  84018. * Gets the audio engine
  84019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84020. * @ignorenaming
  84021. */
  84022. static audioEngine: IAudioEngine;
  84023. /**
  84024. * Default AudioEngine factory responsible of creating the Audio Engine.
  84025. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84026. */
  84027. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84028. /**
  84029. * Default offline support factory responsible of creating a tool used to store data locally.
  84030. * By default, this will create a Database object if the workload has been embedded.
  84031. */
  84032. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84033. private _onFocus;
  84034. private _onBlur;
  84035. private _onCanvasPointerOut;
  84036. private _onCanvasBlur;
  84037. private _onCanvasFocus;
  84038. private _onFullscreenChange;
  84039. private _onPointerLockChange;
  84040. private _onVRDisplayPointerRestricted;
  84041. private _onVRDisplayPointerUnrestricted;
  84042. private _onVrDisplayConnect;
  84043. private _onVrDisplayDisconnect;
  84044. private _onVrDisplayPresentChange;
  84045. /**
  84046. * Observable signaled when VR display mode changes
  84047. */
  84048. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84049. /**
  84050. * Observable signaled when VR request present is complete
  84051. */
  84052. onVRRequestPresentComplete: Observable<boolean>;
  84053. /**
  84054. * Observable signaled when VR request present starts
  84055. */
  84056. onVRRequestPresentStart: Observable<Engine>;
  84057. private _hardwareScalingLevel;
  84058. /** @hidden */
  84059. protected _caps: EngineCapabilities;
  84060. private _pointerLockRequested;
  84061. private _isStencilEnable;
  84062. private _colorWrite;
  84063. private _loadingScreen;
  84064. /** @hidden */
  84065. _drawCalls: PerfCounter;
  84066. /** @hidden */
  84067. _textureCollisions: PerfCounter;
  84068. private _glVersion;
  84069. private _glRenderer;
  84070. private _glVendor;
  84071. private _videoTextureSupported;
  84072. private _renderingQueueLaunched;
  84073. private _activeRenderLoops;
  84074. private _deterministicLockstep;
  84075. private _lockstepMaxSteps;
  84076. /**
  84077. * Observable signaled when a context lost event is raised
  84078. */
  84079. onContextLostObservable: Observable<Engine>;
  84080. /**
  84081. * Observable signaled when a context restored event is raised
  84082. */
  84083. onContextRestoredObservable: Observable<Engine>;
  84084. private _onContextLost;
  84085. private _onContextRestored;
  84086. private _contextWasLost;
  84087. private _doNotHandleContextLost;
  84088. /**
  84089. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84090. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84091. */
  84092. doNotHandleContextLost: boolean;
  84093. private _performanceMonitor;
  84094. private _fps;
  84095. private _deltaTime;
  84096. /**
  84097. * Turn this value on if you want to pause FPS computation when in background
  84098. */
  84099. disablePerformanceMonitorInBackground: boolean;
  84100. /**
  84101. * Gets the performance monitor attached to this engine
  84102. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84103. */
  84104. readonly performanceMonitor: PerformanceMonitor;
  84105. /** @hidden */
  84106. protected _depthCullingState: _DepthCullingState;
  84107. /** @hidden */
  84108. protected _stencilState: _StencilState;
  84109. /** @hidden */
  84110. protected _alphaState: _AlphaState;
  84111. /** @hidden */
  84112. protected _alphaMode: number;
  84113. protected _internalTexturesCache: InternalTexture[];
  84114. /** @hidden */
  84115. protected _activeChannel: number;
  84116. private _currentTextureChannel;
  84117. /** @hidden */
  84118. protected _boundTexturesCache: {
  84119. [key: string]: Nullable<InternalTexture>;
  84120. };
  84121. /** @hidden */
  84122. protected _currentEffect: Nullable<Effect>;
  84123. /** @hidden */
  84124. protected _currentProgram: Nullable<WebGLProgram>;
  84125. private _compiledEffects;
  84126. private _vertexAttribArraysEnabled;
  84127. /** @hidden */
  84128. protected _cachedViewport: Nullable<Viewport>;
  84129. private _cachedVertexArrayObject;
  84130. /** @hidden */
  84131. protected _cachedVertexBuffers: any;
  84132. /** @hidden */
  84133. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84134. /** @hidden */
  84135. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84136. /** @hidden */
  84137. protected _currentRenderTarget: Nullable<InternalTexture>;
  84138. private _uintIndicesCurrentlySet;
  84139. private _currentBoundBuffer;
  84140. /** @hidden */
  84141. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84142. private _currentBufferPointers;
  84143. private _currentInstanceLocations;
  84144. private _currentInstanceBuffers;
  84145. private _textureUnits;
  84146. private _firstBoundInternalTextureTracker;
  84147. private _lastBoundInternalTextureTracker;
  84148. private _workingCanvas;
  84149. private _workingContext;
  84150. private _rescalePostProcess;
  84151. private _dummyFramebuffer;
  84152. private _externalData;
  84153. private _bindedRenderFunction;
  84154. private _vaoRecordInProgress;
  84155. private _mustWipeVertexAttributes;
  84156. private _emptyTexture;
  84157. private _emptyCubeTexture;
  84158. private _emptyTexture3D;
  84159. /** @hidden */
  84160. _frameHandler: number;
  84161. private _nextFreeTextureSlots;
  84162. private _maxSimultaneousTextures;
  84163. private _activeRequests;
  84164. private _texturesSupported;
  84165. private _textureFormatInUse;
  84166. /**
  84167. * Gets the list of texture formats supported
  84168. */
  84169. readonly texturesSupported: Array<string>;
  84170. /**
  84171. * Gets the list of texture formats in use
  84172. */
  84173. readonly textureFormatInUse: Nullable<string>;
  84174. /**
  84175. * Gets the current viewport
  84176. */
  84177. readonly currentViewport: Nullable<Viewport>;
  84178. /**
  84179. * Gets the default empty texture
  84180. */
  84181. readonly emptyTexture: InternalTexture;
  84182. /**
  84183. * Gets the default empty 3D texture
  84184. */
  84185. readonly emptyTexture3D: InternalTexture;
  84186. /**
  84187. * Gets the default empty cube texture
  84188. */
  84189. readonly emptyCubeTexture: InternalTexture;
  84190. /**
  84191. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84192. */
  84193. readonly premultipliedAlpha: boolean;
  84194. /**
  84195. * Creates a new engine
  84196. * @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
  84197. * @param antialias defines enable antialiasing (default: false)
  84198. * @param options defines further options to be sent to the getContext() function
  84199. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84200. */
  84201. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84202. private _disableTouchAction;
  84203. private _rebuildInternalTextures;
  84204. private _rebuildEffects;
  84205. /**
  84206. * Gets a boolean indicating if all created effects are ready
  84207. * @returns true if all effects are ready
  84208. */
  84209. areAllEffectsReady(): boolean;
  84210. private _rebuildBuffers;
  84211. private _initGLContext;
  84212. /**
  84213. * Gets version of the current webGL context
  84214. */
  84215. readonly webGLVersion: number;
  84216. /**
  84217. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84218. */
  84219. readonly isStencilEnable: boolean;
  84220. private _prepareWorkingCanvas;
  84221. /**
  84222. * Reset the texture cache to empty state
  84223. */
  84224. resetTextureCache(): void;
  84225. /**
  84226. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84227. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84228. * @returns true if engine is in deterministic lock step mode
  84229. */
  84230. isDeterministicLockStep(): boolean;
  84231. /**
  84232. * Gets the max steps when engine is running in deterministic lock step
  84233. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84234. * @returns the max steps
  84235. */
  84236. getLockstepMaxSteps(): number;
  84237. /**
  84238. * Gets an object containing information about the current webGL context
  84239. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84240. */
  84241. getGlInfo(): {
  84242. vendor: string;
  84243. renderer: string;
  84244. version: string;
  84245. };
  84246. /**
  84247. * Gets current aspect ratio
  84248. * @param camera defines the camera to use to get the aspect ratio
  84249. * @param useScreen defines if screen size must be used (or the current render target if any)
  84250. * @returns a number defining the aspect ratio
  84251. */
  84252. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84253. /**
  84254. * Gets current screen aspect ratio
  84255. * @returns a number defining the aspect ratio
  84256. */
  84257. getScreenAspectRatio(): number;
  84258. /**
  84259. * Gets the current render width
  84260. * @param useScreen defines if screen size must be used (or the current render target if any)
  84261. * @returns a number defining the current render width
  84262. */
  84263. getRenderWidth(useScreen?: boolean): number;
  84264. /**
  84265. * Gets the current render height
  84266. * @param useScreen defines if screen size must be used (or the current render target if any)
  84267. * @returns a number defining the current render height
  84268. */
  84269. getRenderHeight(useScreen?: boolean): number;
  84270. /**
  84271. * Gets the HTML canvas attached with the current webGL context
  84272. * @returns a HTML canvas
  84273. */
  84274. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84275. /**
  84276. * Gets the client rect of the HTML canvas attached with the current webGL context
  84277. * @returns a client rectanglee
  84278. */
  84279. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84280. /**
  84281. * Defines the hardware scaling level.
  84282. * By default the hardware scaling level is computed from the window device ratio.
  84283. * 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.
  84284. * @param level defines the level to use
  84285. */
  84286. setHardwareScalingLevel(level: number): void;
  84287. /**
  84288. * Gets the current hardware scaling level.
  84289. * By default the hardware scaling level is computed from the window device ratio.
  84290. * 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.
  84291. * @returns a number indicating the current hardware scaling level
  84292. */
  84293. getHardwareScalingLevel(): number;
  84294. /**
  84295. * Gets the list of loaded textures
  84296. * @returns an array containing all loaded textures
  84297. */
  84298. getLoadedTexturesCache(): InternalTexture[];
  84299. /**
  84300. * Gets the object containing all engine capabilities
  84301. * @returns the EngineCapabilities object
  84302. */
  84303. getCaps(): EngineCapabilities;
  84304. /**
  84305. * Gets the current depth function
  84306. * @returns a number defining the depth function
  84307. */
  84308. getDepthFunction(): Nullable<number>;
  84309. /**
  84310. * Sets the current depth function
  84311. * @param depthFunc defines the function to use
  84312. */
  84313. setDepthFunction(depthFunc: number): void;
  84314. /**
  84315. * Sets the current depth function to GREATER
  84316. */
  84317. setDepthFunctionToGreater(): void;
  84318. /**
  84319. * Sets the current depth function to GEQUAL
  84320. */
  84321. setDepthFunctionToGreaterOrEqual(): void;
  84322. /**
  84323. * Sets the current depth function to LESS
  84324. */
  84325. setDepthFunctionToLess(): void;
  84326. /**
  84327. * Sets the current depth function to LEQUAL
  84328. */
  84329. setDepthFunctionToLessOrEqual(): void;
  84330. /**
  84331. * Gets a boolean indicating if stencil buffer is enabled
  84332. * @returns the current stencil buffer state
  84333. */
  84334. getStencilBuffer(): boolean;
  84335. /**
  84336. * Enable or disable the stencil buffer
  84337. * @param enable defines if the stencil buffer must be enabled or disabled
  84338. */
  84339. setStencilBuffer(enable: boolean): void;
  84340. /**
  84341. * Gets the current stencil mask
  84342. * @returns a number defining the new stencil mask to use
  84343. */
  84344. getStencilMask(): number;
  84345. /**
  84346. * Sets the current stencil mask
  84347. * @param mask defines the new stencil mask to use
  84348. */
  84349. setStencilMask(mask: number): void;
  84350. /**
  84351. * Gets the current stencil function
  84352. * @returns a number defining the stencil function to use
  84353. */
  84354. getStencilFunction(): number;
  84355. /**
  84356. * Gets the current stencil reference value
  84357. * @returns a number defining the stencil reference value to use
  84358. */
  84359. getStencilFunctionReference(): number;
  84360. /**
  84361. * Gets the current stencil mask
  84362. * @returns a number defining the stencil mask to use
  84363. */
  84364. getStencilFunctionMask(): number;
  84365. /**
  84366. * Sets the current stencil function
  84367. * @param stencilFunc defines the new stencil function to use
  84368. */
  84369. setStencilFunction(stencilFunc: number): void;
  84370. /**
  84371. * Sets the current stencil reference
  84372. * @param reference defines the new stencil reference to use
  84373. */
  84374. setStencilFunctionReference(reference: number): void;
  84375. /**
  84376. * Sets the current stencil mask
  84377. * @param mask defines the new stencil mask to use
  84378. */
  84379. setStencilFunctionMask(mask: number): void;
  84380. /**
  84381. * Gets the current stencil operation when stencil fails
  84382. * @returns a number defining stencil operation to use when stencil fails
  84383. */
  84384. getStencilOperationFail(): number;
  84385. /**
  84386. * Gets the current stencil operation when depth fails
  84387. * @returns a number defining stencil operation to use when depth fails
  84388. */
  84389. getStencilOperationDepthFail(): number;
  84390. /**
  84391. * Gets the current stencil operation when stencil passes
  84392. * @returns a number defining stencil operation to use when stencil passes
  84393. */
  84394. getStencilOperationPass(): number;
  84395. /**
  84396. * Sets the stencil operation to use when stencil fails
  84397. * @param operation defines the stencil operation to use when stencil fails
  84398. */
  84399. setStencilOperationFail(operation: number): void;
  84400. /**
  84401. * Sets the stencil operation to use when depth fails
  84402. * @param operation defines the stencil operation to use when depth fails
  84403. */
  84404. setStencilOperationDepthFail(operation: number): void;
  84405. /**
  84406. * Sets the stencil operation to use when stencil passes
  84407. * @param operation defines the stencil operation to use when stencil passes
  84408. */
  84409. setStencilOperationPass(operation: number): void;
  84410. /**
  84411. * Sets a boolean indicating if the dithering state is enabled or disabled
  84412. * @param value defines the dithering state
  84413. */
  84414. setDitheringState(value: boolean): void;
  84415. /**
  84416. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84417. * @param value defines the rasterizer state
  84418. */
  84419. setRasterizerState(value: boolean): void;
  84420. /**
  84421. * stop executing a render loop function and remove it from the execution array
  84422. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84423. */
  84424. stopRenderLoop(renderFunction?: () => void): void;
  84425. /** @hidden */
  84426. _renderLoop(): void;
  84427. /**
  84428. * Register and execute a render loop. The engine can have more than one render function
  84429. * @param renderFunction defines the function to continuously execute
  84430. */
  84431. runRenderLoop(renderFunction: () => void): void;
  84432. /**
  84433. * Toggle full screen mode
  84434. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84435. */
  84436. switchFullscreen(requestPointerLock: boolean): void;
  84437. /**
  84438. * Enters full screen mode
  84439. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84440. */
  84441. enterFullscreen(requestPointerLock: boolean): void;
  84442. /**
  84443. * Exits full screen mode
  84444. */
  84445. exitFullscreen(): void;
  84446. /**
  84447. * Clear the current render buffer or the current render target (if any is set up)
  84448. * @param color defines the color to use
  84449. * @param backBuffer defines if the back buffer must be cleared
  84450. * @param depth defines if the depth buffer must be cleared
  84451. * @param stencil defines if the stencil buffer must be cleared
  84452. */
  84453. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84454. /**
  84455. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84456. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84457. * @param y defines the y-coordinate of the corner of the clear rectangle
  84458. * @param width defines the width of the clear rectangle
  84459. * @param height defines the height of the clear rectangle
  84460. * @param clearColor defines the clear color
  84461. */
  84462. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84463. /**
  84464. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84465. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84466. * @param y defines the y-coordinate of the corner of the clear rectangle
  84467. * @param width defines the width of the clear rectangle
  84468. * @param height defines the height of the clear rectangle
  84469. */
  84470. enableScissor(x: number, y: number, width: number, height: number): void;
  84471. /**
  84472. * Disable previously set scissor test rectangle
  84473. */
  84474. disableScissor(): void;
  84475. private _viewportCached;
  84476. /** @hidden */
  84477. _viewport(x: number, y: number, width: number, height: number): void;
  84478. /**
  84479. * Set the WebGL's viewport
  84480. * @param viewport defines the viewport element to be used
  84481. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84482. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84483. */
  84484. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84485. /**
  84486. * Directly set the WebGL Viewport
  84487. * @param x defines the x coordinate of the viewport (in screen space)
  84488. * @param y defines the y coordinate of the viewport (in screen space)
  84489. * @param width defines the width of the viewport (in screen space)
  84490. * @param height defines the height of the viewport (in screen space)
  84491. * @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
  84492. */
  84493. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84494. /**
  84495. * Begin a new frame
  84496. */
  84497. beginFrame(): void;
  84498. /**
  84499. * Enf the current frame
  84500. */
  84501. endFrame(): void;
  84502. /**
  84503. * Resize the view according to the canvas' size
  84504. */
  84505. resize(): void;
  84506. /**
  84507. * Force a specific size of the canvas
  84508. * @param width defines the new canvas' width
  84509. * @param height defines the new canvas' height
  84510. */
  84511. setSize(width: number, height: number): void;
  84512. /**
  84513. * Gets a boolean indicating if a webVR device was detected
  84514. * @returns true if a webVR device was detected
  84515. */
  84516. isVRDevicePresent(): boolean;
  84517. /**
  84518. * Gets the current webVR device
  84519. * @returns the current webVR device (or null)
  84520. */
  84521. getVRDevice(): any;
  84522. /**
  84523. * Initializes a webVR display and starts listening to display change events
  84524. * The onVRDisplayChangedObservable will be notified upon these changes
  84525. * @returns The onVRDisplayChangedObservable
  84526. */
  84527. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84528. /**
  84529. * Initializes a webVR display and starts listening to display change events
  84530. * The onVRDisplayChangedObservable will be notified upon these changes
  84531. * @returns A promise containing a VRDisplay and if vr is supported
  84532. */
  84533. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84534. /**
  84535. * Call this function to switch to webVR mode
  84536. * Will do nothing if webVR is not supported or if there is no webVR device
  84537. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84538. */
  84539. enableVR(): void;
  84540. /**
  84541. * Call this function to leave webVR mode
  84542. * Will do nothing if webVR is not supported or if there is no webVR device
  84543. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84544. */
  84545. disableVR(): void;
  84546. private _onVRFullScreenTriggered;
  84547. private _getVRDisplaysAsync;
  84548. /**
  84549. * Binds the frame buffer to the specified texture.
  84550. * @param texture The texture to render to or null for the default canvas
  84551. * @param faceIndex The face of the texture to render to in case of cube texture
  84552. * @param requiredWidth The width of the target to render to
  84553. * @param requiredHeight The height of the target to render to
  84554. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84555. * @param depthStencilTexture The depth stencil texture to use to render
  84556. * @param lodLevel defines le lod level to bind to the frame buffer
  84557. */
  84558. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84559. private bindUnboundFramebuffer;
  84560. /**
  84561. * Unbind the current render target texture from the webGL context
  84562. * @param texture defines the render target texture to unbind
  84563. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84564. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84565. */
  84566. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84567. /**
  84568. * Unbind a list of render target textures from the webGL context
  84569. * This is used only when drawBuffer extension or webGL2 are active
  84570. * @param textures defines the render target textures to unbind
  84571. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84572. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84573. */
  84574. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84575. /**
  84576. * Force the mipmap generation for the given render target texture
  84577. * @param texture defines the render target texture to use
  84578. */
  84579. generateMipMapsForCubemap(texture: InternalTexture): void;
  84580. /**
  84581. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84582. */
  84583. flushFramebuffer(): void;
  84584. /**
  84585. * Unbind the current render target and bind the default framebuffer
  84586. */
  84587. restoreDefaultFramebuffer(): void;
  84588. /**
  84589. * Create an uniform buffer
  84590. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84591. * @param elements defines the content of the uniform buffer
  84592. * @returns the webGL uniform buffer
  84593. */
  84594. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84595. /**
  84596. * Create a dynamic uniform buffer
  84597. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84598. * @param elements defines the content of the uniform buffer
  84599. * @returns the webGL uniform buffer
  84600. */
  84601. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84602. /**
  84603. * Update an existing uniform buffer
  84604. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84605. * @param uniformBuffer defines the target uniform buffer
  84606. * @param elements defines the content to update
  84607. * @param offset defines the offset in the uniform buffer where update should start
  84608. * @param count defines the size of the data to update
  84609. */
  84610. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84611. private _resetVertexBufferBinding;
  84612. /**
  84613. * Creates a vertex buffer
  84614. * @param data the data for the vertex buffer
  84615. * @returns the new WebGL static buffer
  84616. */
  84617. createVertexBuffer(data: DataArray): WebGLBuffer;
  84618. /**
  84619. * Creates a dynamic vertex buffer
  84620. * @param data the data for the dynamic vertex buffer
  84621. * @returns the new WebGL dynamic buffer
  84622. */
  84623. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84624. /**
  84625. * Update a dynamic index buffer
  84626. * @param indexBuffer defines the target index buffer
  84627. * @param indices defines the data to update
  84628. * @param offset defines the offset in the target index buffer where update should start
  84629. */
  84630. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84631. /**
  84632. * Updates a dynamic vertex buffer.
  84633. * @param vertexBuffer the vertex buffer to update
  84634. * @param data the data used to update the vertex buffer
  84635. * @param byteOffset the byte offset of the data
  84636. * @param byteLength the byte length of the data
  84637. */
  84638. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84639. private _resetIndexBufferBinding;
  84640. /**
  84641. * Creates a new index buffer
  84642. * @param indices defines the content of the index buffer
  84643. * @param updatable defines if the index buffer must be updatable
  84644. * @returns a new webGL buffer
  84645. */
  84646. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84647. /**
  84648. * Bind a webGL buffer to the webGL context
  84649. * @param buffer defines the buffer to bind
  84650. */
  84651. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84652. /**
  84653. * Bind an uniform buffer to the current webGL context
  84654. * @param buffer defines the buffer to bind
  84655. */
  84656. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84657. /**
  84658. * Bind a buffer to the current webGL context at a given location
  84659. * @param buffer defines the buffer to bind
  84660. * @param location defines the index where to bind the buffer
  84661. */
  84662. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84663. /**
  84664. * Bind a specific block at a given index in a specific shader program
  84665. * @param shaderProgram defines the shader program
  84666. * @param blockName defines the block name
  84667. * @param index defines the index where to bind the block
  84668. */
  84669. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84670. private bindIndexBuffer;
  84671. private bindBuffer;
  84672. /**
  84673. * update the bound buffer with the given data
  84674. * @param data defines the data to update
  84675. */
  84676. updateArrayBuffer(data: Float32Array): void;
  84677. private _vertexAttribPointer;
  84678. private _bindIndexBufferWithCache;
  84679. private _bindVertexBuffersAttributes;
  84680. /**
  84681. * Records a vertex array object
  84682. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84683. * @param vertexBuffers defines the list of vertex buffers to store
  84684. * @param indexBuffer defines the index buffer to store
  84685. * @param effect defines the effect to store
  84686. * @returns the new vertex array object
  84687. */
  84688. recordVertexArrayObject(vertexBuffers: {
  84689. [key: string]: VertexBuffer;
  84690. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84691. /**
  84692. * Bind a specific vertex array object
  84693. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84694. * @param vertexArrayObject defines the vertex array object to bind
  84695. * @param indexBuffer defines the index buffer to bind
  84696. */
  84697. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84698. /**
  84699. * Bind webGl buffers directly to the webGL context
  84700. * @param vertexBuffer defines the vertex buffer to bind
  84701. * @param indexBuffer defines the index buffer to bind
  84702. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84703. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84704. * @param effect defines the effect associated with the vertex buffer
  84705. */
  84706. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84707. private _unbindVertexArrayObject;
  84708. /**
  84709. * Bind a list of vertex buffers to the webGL context
  84710. * @param vertexBuffers defines the list of vertex buffers to bind
  84711. * @param indexBuffer defines the index buffer to bind
  84712. * @param effect defines the effect associated with the vertex buffers
  84713. */
  84714. bindBuffers(vertexBuffers: {
  84715. [key: string]: Nullable<VertexBuffer>;
  84716. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84717. /**
  84718. * Unbind all instance attributes
  84719. */
  84720. unbindInstanceAttributes(): void;
  84721. /**
  84722. * Release and free the memory of a vertex array object
  84723. * @param vao defines the vertex array object to delete
  84724. */
  84725. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  84726. /** @hidden */
  84727. _releaseBuffer(buffer: WebGLBuffer): boolean;
  84728. /**
  84729. * Creates a webGL buffer to use with instanciation
  84730. * @param capacity defines the size of the buffer
  84731. * @returns the webGL buffer
  84732. */
  84733. createInstancesBuffer(capacity: number): WebGLBuffer;
  84734. /**
  84735. * Delete a webGL buffer used with instanciation
  84736. * @param buffer defines the webGL buffer to delete
  84737. */
  84738. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  84739. /**
  84740. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  84741. * @param instancesBuffer defines the webGL buffer to update and bind
  84742. * @param data defines the data to store in the buffer
  84743. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  84744. */
  84745. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  84746. /**
  84747. * Apply all cached states (depth, culling, stencil and alpha)
  84748. */
  84749. applyStates(): void;
  84750. /**
  84751. * Send a draw order
  84752. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84753. * @param indexStart defines the starting index
  84754. * @param indexCount defines the number of index to draw
  84755. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84756. */
  84757. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  84758. /**
  84759. * Draw a list of points
  84760. * @param verticesStart defines the index of first vertex to draw
  84761. * @param verticesCount defines the count of vertices to draw
  84762. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84763. */
  84764. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84765. /**
  84766. * Draw a list of unindexed primitives
  84767. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84768. * @param verticesStart defines the index of first vertex to draw
  84769. * @param verticesCount defines the count of vertices to draw
  84770. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84771. */
  84772. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84773. /**
  84774. * Draw a list of indexed primitives
  84775. * @param fillMode defines the primitive to use
  84776. * @param indexStart defines the starting index
  84777. * @param indexCount defines the number of index to draw
  84778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84779. */
  84780. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  84781. /**
  84782. * Draw a list of unindexed primitives
  84783. * @param fillMode defines the primitive to use
  84784. * @param verticesStart defines the index of first vertex to draw
  84785. * @param verticesCount defines the count of vertices to draw
  84786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84787. */
  84788. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84789. private _drawMode;
  84790. /** @hidden */
  84791. _releaseEffect(effect: Effect): void;
  84792. /** @hidden */
  84793. _deleteProgram(program: WebGLProgram): void;
  84794. /**
  84795. * Create a new effect (used to store vertex/fragment shaders)
  84796. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  84797. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  84798. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  84799. * @param samplers defines an array of string used to represent textures
  84800. * @param defines defines the string containing the defines to use to compile the shaders
  84801. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  84802. * @param onCompiled defines a function to call when the effect creation is successful
  84803. * @param onError defines a function to call when the effect creation has failed
  84804. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  84805. * @returns the new Effect
  84806. */
  84807. 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;
  84808. private _compileShader;
  84809. private _compileRawShader;
  84810. /**
  84811. * Directly creates a webGL program
  84812. * @param vertexCode defines the vertex shader code to use
  84813. * @param fragmentCode defines the fragment shader code to use
  84814. * @param context defines the webGL context to use (if not set, the current one will be used)
  84815. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84816. * @returns the new webGL program
  84817. */
  84818. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84819. /**
  84820. * Creates a webGL program
  84821. * @param vertexCode defines the vertex shader code to use
  84822. * @param fragmentCode defines the fragment shader code to use
  84823. * @param defines defines the string containing the defines to use to compile the shaders
  84824. * @param context defines the webGL context to use (if not set, the current one will be used)
  84825. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84826. * @returns the new webGL program
  84827. */
  84828. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84829. private _createShaderProgram;
  84830. private _finalizeProgram;
  84831. /** @hidden */
  84832. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  84833. /** @hidden */
  84834. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  84835. /**
  84836. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  84837. * @param shaderProgram defines the webGL program to use
  84838. * @param uniformsNames defines the list of uniform names
  84839. * @returns an array of webGL uniform locations
  84840. */
  84841. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  84842. /**
  84843. * Gets the lsit of active attributes for a given webGL program
  84844. * @param shaderProgram defines the webGL program to use
  84845. * @param attributesNames defines the list of attribute names to get
  84846. * @returns an array of indices indicating the offset of each attribute
  84847. */
  84848. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  84849. /**
  84850. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  84851. * @param effect defines the effect to activate
  84852. */
  84853. enableEffect(effect: Nullable<Effect>): void;
  84854. /**
  84855. * Set the value of an uniform to an array of int32
  84856. * @param uniform defines the webGL uniform location where to store the value
  84857. * @param array defines the array of int32 to store
  84858. */
  84859. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84860. /**
  84861. * Set the value of an uniform to an array of int32 (stored as vec2)
  84862. * @param uniform defines the webGL uniform location where to store the value
  84863. * @param array defines the array of int32 to store
  84864. */
  84865. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84866. /**
  84867. * Set the value of an uniform to an array of int32 (stored as vec3)
  84868. * @param uniform defines the webGL uniform location where to store the value
  84869. * @param array defines the array of int32 to store
  84870. */
  84871. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84872. /**
  84873. * Set the value of an uniform to an array of int32 (stored as vec4)
  84874. * @param uniform defines the webGL uniform location where to store the value
  84875. * @param array defines the array of int32 to store
  84876. */
  84877. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84878. /**
  84879. * Set the value of an uniform to an array of float32
  84880. * @param uniform defines the webGL uniform location where to store the value
  84881. * @param array defines the array of float32 to store
  84882. */
  84883. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84884. /**
  84885. * Set the value of an uniform to an array of float32 (stored as vec2)
  84886. * @param uniform defines the webGL uniform location where to store the value
  84887. * @param array defines the array of float32 to store
  84888. */
  84889. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84890. /**
  84891. * Set the value of an uniform to an array of float32 (stored as vec3)
  84892. * @param uniform defines the webGL uniform location where to store the value
  84893. * @param array defines the array of float32 to store
  84894. */
  84895. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84896. /**
  84897. * Set the value of an uniform to an array of float32 (stored as vec4)
  84898. * @param uniform defines the webGL uniform location where to store the value
  84899. * @param array defines the array of float32 to store
  84900. */
  84901. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84902. /**
  84903. * Set the value of an uniform to an array of number
  84904. * @param uniform defines the webGL uniform location where to store the value
  84905. * @param array defines the array of number to store
  84906. */
  84907. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84908. /**
  84909. * Set the value of an uniform to an array of number (stored as vec2)
  84910. * @param uniform defines the webGL uniform location where to store the value
  84911. * @param array defines the array of number to store
  84912. */
  84913. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84914. /**
  84915. * Set the value of an uniform to an array of number (stored as vec3)
  84916. * @param uniform defines the webGL uniform location where to store the value
  84917. * @param array defines the array of number to store
  84918. */
  84919. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84920. /**
  84921. * Set the value of an uniform to an array of number (stored as vec4)
  84922. * @param uniform defines the webGL uniform location where to store the value
  84923. * @param array defines the array of number to store
  84924. */
  84925. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84926. /**
  84927. * Set the value of an uniform to an array of float32 (stored as matrices)
  84928. * @param uniform defines the webGL uniform location where to store the value
  84929. * @param matrices defines the array of float32 to store
  84930. */
  84931. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  84932. /**
  84933. * Set the value of an uniform to a matrix
  84934. * @param uniform defines the webGL uniform location where to store the value
  84935. * @param matrix defines the matrix to store
  84936. */
  84937. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  84938. /**
  84939. * Set the value of an uniform to a matrix (3x3)
  84940. * @param uniform defines the webGL uniform location where to store the value
  84941. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  84942. */
  84943. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84944. /**
  84945. * Set the value of an uniform to a matrix (2x2)
  84946. * @param uniform defines the webGL uniform location where to store the value
  84947. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  84948. */
  84949. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84950. /**
  84951. * Set the value of an uniform to a number (int)
  84952. * @param uniform defines the webGL uniform location where to store the value
  84953. * @param value defines the int number to store
  84954. */
  84955. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84956. /**
  84957. * Set the value of an uniform to a number (float)
  84958. * @param uniform defines the webGL uniform location where to store the value
  84959. * @param value defines the float number to store
  84960. */
  84961. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84962. /**
  84963. * Set the value of an uniform to a vec2
  84964. * @param uniform defines the webGL uniform location where to store the value
  84965. * @param x defines the 1st component of the value
  84966. * @param y defines the 2nd component of the value
  84967. */
  84968. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  84969. /**
  84970. * Set the value of an uniform to a vec3
  84971. * @param uniform defines the webGL uniform location where to store the value
  84972. * @param x defines the 1st component of the value
  84973. * @param y defines the 2nd component of the value
  84974. * @param z defines the 3rd component of the value
  84975. */
  84976. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  84977. /**
  84978. * Set the value of an uniform to a boolean
  84979. * @param uniform defines the webGL uniform location where to store the value
  84980. * @param bool defines the boolean to store
  84981. */
  84982. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  84983. /**
  84984. * Set the value of an uniform to a vec4
  84985. * @param uniform defines the webGL uniform location where to store the value
  84986. * @param x defines the 1st component of the value
  84987. * @param y defines the 2nd component of the value
  84988. * @param z defines the 3rd component of the value
  84989. * @param w defines the 4th component of the value
  84990. */
  84991. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  84992. /**
  84993. * Set the value of an uniform to a Color3
  84994. * @param uniform defines the webGL uniform location where to store the value
  84995. * @param color3 defines the color to store
  84996. */
  84997. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  84998. /**
  84999. * Set the value of an uniform to a Color3 and an alpha value
  85000. * @param uniform defines the webGL uniform location where to store the value
  85001. * @param color3 defines the color to store
  85002. * @param alpha defines the alpha component to store
  85003. */
  85004. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85005. /**
  85006. * Sets a Color4 on a uniform variable
  85007. * @param uniform defines the uniform location
  85008. * @param color4 defines the value to be set
  85009. */
  85010. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85011. /**
  85012. * Set various states to the webGL context
  85013. * @param culling defines backface culling state
  85014. * @param zOffset defines the value to apply to zOffset (0 by default)
  85015. * @param force defines if states must be applied even if cache is up to date
  85016. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85017. */
  85018. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85019. /**
  85020. * Set the z offset to apply to current rendering
  85021. * @param value defines the offset to apply
  85022. */
  85023. setZOffset(value: number): void;
  85024. /**
  85025. * Gets the current value of the zOffset
  85026. * @returns the current zOffset state
  85027. */
  85028. getZOffset(): number;
  85029. /**
  85030. * Enable or disable depth buffering
  85031. * @param enable defines the state to set
  85032. */
  85033. setDepthBuffer(enable: boolean): void;
  85034. /**
  85035. * Gets a boolean indicating if depth writing is enabled
  85036. * @returns the current depth writing state
  85037. */
  85038. getDepthWrite(): boolean;
  85039. /**
  85040. * Enable or disable depth writing
  85041. * @param enable defines the state to set
  85042. */
  85043. setDepthWrite(enable: boolean): void;
  85044. /**
  85045. * Enable or disable color writing
  85046. * @param enable defines the state to set
  85047. */
  85048. setColorWrite(enable: boolean): void;
  85049. /**
  85050. * Gets a boolean indicating if color writing is enabled
  85051. * @returns the current color writing state
  85052. */
  85053. getColorWrite(): boolean;
  85054. /**
  85055. * Sets alpha constants used by some alpha blending modes
  85056. * @param r defines the red component
  85057. * @param g defines the green component
  85058. * @param b defines the blue component
  85059. * @param a defines the alpha component
  85060. */
  85061. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85062. /**
  85063. * Sets the current alpha mode
  85064. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85065. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85066. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85067. */
  85068. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85069. /**
  85070. * Gets the current alpha mode
  85071. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85072. * @returns the current alpha mode
  85073. */
  85074. getAlphaMode(): number;
  85075. /**
  85076. * Clears the list of texture accessible through engine.
  85077. * This can help preventing texture load conflict due to name collision.
  85078. */
  85079. clearInternalTexturesCache(): void;
  85080. /**
  85081. * Force the entire cache to be cleared
  85082. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85083. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85084. */
  85085. wipeCaches(bruteForce?: boolean): void;
  85086. /**
  85087. * Set the compressed texture format to use, based on the formats you have, and the formats
  85088. * supported by the hardware / browser.
  85089. *
  85090. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85091. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85092. * to API arguments needed to compressed textures. This puts the burden on the container
  85093. * generator to house the arcane code for determining these for current & future formats.
  85094. *
  85095. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85096. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85097. *
  85098. * Note: The result of this call is not taken into account when a texture is base64.
  85099. *
  85100. * @param formatsAvailable defines the list of those format families you have created
  85101. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85102. *
  85103. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85104. * @returns The extension selected.
  85105. */
  85106. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85107. private _getSamplingParameters;
  85108. private _partialLoadImg;
  85109. private _cascadeLoadImgs;
  85110. /** @hidden */
  85111. _createTexture(): WebGLTexture;
  85112. /**
  85113. * Usually called from Texture.ts.
  85114. * Passed information to create a WebGLTexture
  85115. * @param urlArg defines a value which contains one of the following:
  85116. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85117. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85118. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85119. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85120. * @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)
  85121. * @param scene needed for loading to the correct scene
  85122. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85123. * @param onLoad optional callback to be called upon successful completion
  85124. * @param onError optional callback to be called upon failure
  85125. * @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
  85126. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85127. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85128. * @param forcedExtension defines the extension to use to pick the right loader
  85129. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85130. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85131. */
  85132. 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;
  85133. private _rescaleTexture;
  85134. /**
  85135. * Update a raw texture
  85136. * @param texture defines the texture to update
  85137. * @param data defines the data to store in the texture
  85138. * @param format defines the format of the data
  85139. * @param invertY defines if data must be stored with Y axis inverted
  85140. * @param compression defines the compression used (null by default)
  85141. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85142. */
  85143. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85144. /**
  85145. * Creates a raw texture
  85146. * @param data defines the data to store in the texture
  85147. * @param width defines the width of the texture
  85148. * @param height defines the height of the texture
  85149. * @param format defines the format of the data
  85150. * @param generateMipMaps defines if the engine should generate the mip levels
  85151. * @param invertY defines if data must be stored with Y axis inverted
  85152. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85153. * @param compression defines the compression used (null by default)
  85154. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85155. * @returns the raw texture inside an InternalTexture
  85156. */
  85157. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85158. private _unpackFlipYCached;
  85159. /**
  85160. * In case you are sharing the context with other applications, it might
  85161. * be interested to not cache the unpack flip y state to ensure a consistent
  85162. * value would be set.
  85163. */
  85164. enableUnpackFlipYCached: boolean;
  85165. /** @hidden */
  85166. _unpackFlipY(value: boolean): void;
  85167. /** @hidden */
  85168. _getUnpackAlignement(): number;
  85169. /**
  85170. * Creates a dynamic texture
  85171. * @param width defines the width of the texture
  85172. * @param height defines the height of the texture
  85173. * @param generateMipMaps defines if the engine should generate the mip levels
  85174. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85175. * @returns the dynamic texture inside an InternalTexture
  85176. */
  85177. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85178. /**
  85179. * Update the sampling mode of a given texture
  85180. * @param samplingMode defines the required sampling mode
  85181. * @param texture defines the texture to update
  85182. */
  85183. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85184. /**
  85185. * Update the content of a dynamic texture
  85186. * @param texture defines the texture to update
  85187. * @param canvas defines the canvas containing the source
  85188. * @param invertY defines if data must be stored with Y axis inverted
  85189. * @param premulAlpha defines if alpha is stored as premultiplied
  85190. * @param format defines the format of the data
  85191. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85192. */
  85193. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85194. /**
  85195. * Update a video texture
  85196. * @param texture defines the texture to update
  85197. * @param video defines the video element to use
  85198. * @param invertY defines if data must be stored with Y axis inverted
  85199. */
  85200. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85201. /**
  85202. * Updates a depth texture Comparison Mode and Function.
  85203. * If the comparison Function is equal to 0, the mode will be set to none.
  85204. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85205. * @param texture The texture to set the comparison function for
  85206. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85207. */
  85208. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85209. private _setupDepthStencilTexture;
  85210. /**
  85211. * Creates a depth stencil texture.
  85212. * This is only available in WebGL 2 or with the depth texture extension available.
  85213. * @param size The size of face edge in the texture.
  85214. * @param options The options defining the texture.
  85215. * @returns The texture
  85216. */
  85217. createDepthStencilTexture(size: number | {
  85218. width: number;
  85219. height: number;
  85220. }, options: DepthTextureCreationOptions): InternalTexture;
  85221. /**
  85222. * Creates a depth stencil texture.
  85223. * This is only available in WebGL 2 or with the depth texture extension available.
  85224. * @param size The size of face edge in the texture.
  85225. * @param options The options defining the texture.
  85226. * @returns The texture
  85227. */
  85228. private _createDepthStencilTexture;
  85229. /**
  85230. * Creates a depth stencil cube texture.
  85231. * This is only available in WebGL 2.
  85232. * @param size The size of face edge in the cube texture.
  85233. * @param options The options defining the cube texture.
  85234. * @returns The cube texture
  85235. */
  85236. private _createDepthStencilCubeTexture;
  85237. /**
  85238. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85239. * @param renderTarget The render target to set the frame buffer for
  85240. */
  85241. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85242. /**
  85243. * Creates a new render target texture
  85244. * @param size defines the size of the texture
  85245. * @param options defines the options used to create the texture
  85246. * @returns a new render target texture stored in an InternalTexture
  85247. */
  85248. createRenderTargetTexture(size: number | {
  85249. width: number;
  85250. height: number;
  85251. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85252. /**
  85253. * Create a multi render target texture
  85254. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85255. * @param size defines the size of the texture
  85256. * @param options defines the creation options
  85257. * @returns the cube texture as an InternalTexture
  85258. */
  85259. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85260. private _setupFramebufferDepthAttachments;
  85261. /**
  85262. * Updates the sample count of a render target texture
  85263. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85264. * @param texture defines the texture to update
  85265. * @param samples defines the sample count to set
  85266. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85267. */
  85268. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85269. /**
  85270. * Update the sample count for a given multiple render target texture
  85271. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85272. * @param textures defines the textures to update
  85273. * @param samples defines the sample count to set
  85274. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85275. */
  85276. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85277. /** @hidden */
  85278. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85279. /** @hidden */
  85280. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85281. /** @hidden */
  85282. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85283. /** @hidden */
  85284. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85285. /**
  85286. * Creates a new render target cube texture
  85287. * @param size defines the size of the texture
  85288. * @param options defines the options used to create the texture
  85289. * @returns a new render target cube texture stored in an InternalTexture
  85290. */
  85291. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85292. /**
  85293. * Creates a cube texture
  85294. * @param rootUrl defines the url where the files to load is located
  85295. * @param scene defines the current scene
  85296. * @param files defines the list of files to load (1 per face)
  85297. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85298. * @param onLoad defines an optional callback raised when the texture is loaded
  85299. * @param onError defines an optional callback raised if there is an issue to load the texture
  85300. * @param format defines the format of the data
  85301. * @param forcedExtension defines the extension to use to pick the right loader
  85302. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85303. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85304. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85305. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85306. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85307. * @returns the cube texture as an InternalTexture
  85308. */
  85309. 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;
  85310. /**
  85311. * @hidden
  85312. */
  85313. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85314. /**
  85315. * Update a raw cube texture
  85316. * @param texture defines the texture to udpdate
  85317. * @param data defines the data to store
  85318. * @param format defines the data format
  85319. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85320. * @param invertY defines if data must be stored with Y axis inverted
  85321. * @param compression defines the compression used (null by default)
  85322. * @param level defines which level of the texture to update
  85323. */
  85324. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85325. /**
  85326. * Creates a new raw cube texture
  85327. * @param data defines the array of data to use to create each face
  85328. * @param size defines the size of the textures
  85329. * @param format defines the format of the data
  85330. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85331. * @param generateMipMaps defines if the engine should generate the mip levels
  85332. * @param invertY defines if data must be stored with Y axis inverted
  85333. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85334. * @param compression defines the compression used (null by default)
  85335. * @returns the cube texture as an InternalTexture
  85336. */
  85337. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85338. /**
  85339. * Creates a new raw cube texture from a specified url
  85340. * @param url defines the url where the data is located
  85341. * @param scene defines the current scene
  85342. * @param size defines the size of the textures
  85343. * @param format defines the format of the data
  85344. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85345. * @param noMipmap defines if the engine should avoid generating the mip levels
  85346. * @param callback defines a callback used to extract texture data from loaded data
  85347. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85348. * @param onLoad defines a callback called when texture is loaded
  85349. * @param onError defines a callback called if there is an error
  85350. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85351. * @param invertY defines if data must be stored with Y axis inverted
  85352. * @returns the cube texture as an InternalTexture
  85353. */
  85354. 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;
  85355. /**
  85356. * Update a raw 3D texture
  85357. * @param texture defines the texture to update
  85358. * @param data defines the data to store
  85359. * @param format defines the data format
  85360. * @param invertY defines if data must be stored with Y axis inverted
  85361. * @param compression defines the used compression (can be null)
  85362. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85363. */
  85364. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85365. /**
  85366. * Creates a new raw 3D texture
  85367. * @param data defines the data used to create the texture
  85368. * @param width defines the width of the texture
  85369. * @param height defines the height of the texture
  85370. * @param depth defines the depth of the texture
  85371. * @param format defines the format of the texture
  85372. * @param generateMipMaps defines if the engine must generate mip levels
  85373. * @param invertY defines if data must be stored with Y axis inverted
  85374. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85375. * @param compression defines the compressed used (can be null)
  85376. * @param textureType defines the compressed used (can be null)
  85377. * @returns a new raw 3D texture (stored in an InternalTexture)
  85378. */
  85379. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85380. private _prepareWebGLTextureContinuation;
  85381. private _prepareWebGLTexture;
  85382. private _convertRGBtoRGBATextureData;
  85383. /** @hidden */
  85384. _releaseFramebufferObjects(texture: InternalTexture): void;
  85385. /** @hidden */
  85386. _releaseTexture(texture: InternalTexture): void;
  85387. private setProgram;
  85388. private _boundUniforms;
  85389. /**
  85390. * Binds an effect to the webGL context
  85391. * @param effect defines the effect to bind
  85392. */
  85393. bindSamplers(effect: Effect): void;
  85394. private _moveBoundTextureOnTop;
  85395. private _getCorrectTextureChannel;
  85396. private _linkTrackers;
  85397. private _removeDesignatedSlot;
  85398. private _activateCurrentTexture;
  85399. /** @hidden */
  85400. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85401. /** @hidden */
  85402. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85403. /**
  85404. * Sets a texture to the webGL context from a postprocess
  85405. * @param channel defines the channel to use
  85406. * @param postProcess defines the source postprocess
  85407. */
  85408. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85409. /**
  85410. * Binds the output of the passed in post process to the texture channel specified
  85411. * @param channel The channel the texture should be bound to
  85412. * @param postProcess The post process which's output should be bound
  85413. */
  85414. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85415. /**
  85416. * Unbind all textures from the webGL context
  85417. */
  85418. unbindAllTextures(): void;
  85419. /**
  85420. * Sets a texture to the according uniform.
  85421. * @param channel The texture channel
  85422. * @param uniform The uniform to set
  85423. * @param texture The texture to apply
  85424. */
  85425. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85426. /**
  85427. * Sets a depth stencil texture from a render target to the according uniform.
  85428. * @param channel The texture channel
  85429. * @param uniform The uniform to set
  85430. * @param texture The render target texture containing the depth stencil texture to apply
  85431. */
  85432. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85433. private _bindSamplerUniformToChannel;
  85434. private _getTextureWrapMode;
  85435. private _setTexture;
  85436. /**
  85437. * Sets an array of texture to the webGL context
  85438. * @param channel defines the channel where the texture array must be set
  85439. * @param uniform defines the associated uniform location
  85440. * @param textures defines the array of textures to bind
  85441. */
  85442. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85443. /** @hidden */
  85444. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85445. private _setTextureParameterFloat;
  85446. private _setTextureParameterInteger;
  85447. /**
  85448. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85449. * @param x defines the x coordinate of the rectangle where pixels must be read
  85450. * @param y defines the y coordinate of the rectangle where pixels must be read
  85451. * @param width defines the width of the rectangle where pixels must be read
  85452. * @param height defines the height of the rectangle where pixels must be read
  85453. * @returns a Uint8Array containing RGBA colors
  85454. */
  85455. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85456. /**
  85457. * Add an externaly attached data from its key.
  85458. * This method call will fail and return false, if such key already exists.
  85459. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85460. * @param key the unique key that identifies the data
  85461. * @param data the data object to associate to the key for this Engine instance
  85462. * @return true if no such key were already present and the data was added successfully, false otherwise
  85463. */
  85464. addExternalData<T>(key: string, data: T): boolean;
  85465. /**
  85466. * Get an externaly attached data from its key
  85467. * @param key the unique key that identifies the data
  85468. * @return the associated data, if present (can be null), or undefined if not present
  85469. */
  85470. getExternalData<T>(key: string): T;
  85471. /**
  85472. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85473. * @param key the unique key that identifies the data
  85474. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85475. * @return the associated data, can be null if the factory returned null.
  85476. */
  85477. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85478. /**
  85479. * Remove an externaly attached data from the Engine instance
  85480. * @param key the unique key that identifies the data
  85481. * @return true if the data was successfully removed, false if it doesn't exist
  85482. */
  85483. removeExternalData(key: string): boolean;
  85484. /**
  85485. * Unbind all vertex attributes from the webGL context
  85486. */
  85487. unbindAllAttributes(): void;
  85488. /**
  85489. * 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
  85490. */
  85491. releaseEffects(): void;
  85492. /**
  85493. * Dispose and release all associated resources
  85494. */
  85495. dispose(): void;
  85496. /**
  85497. * Display the loading screen
  85498. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85499. */
  85500. displayLoadingUI(): void;
  85501. /**
  85502. * Hide the loading screen
  85503. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85504. */
  85505. hideLoadingUI(): void;
  85506. /**
  85507. * Gets the current loading screen object
  85508. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85509. */
  85510. /**
  85511. * Sets the current loading screen object
  85512. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85513. */
  85514. loadingScreen: ILoadingScreen;
  85515. /**
  85516. * Sets the current loading screen text
  85517. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85518. */
  85519. loadingUIText: string;
  85520. /**
  85521. * Sets the current loading screen background color
  85522. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85523. */
  85524. loadingUIBackgroundColor: string;
  85525. /**
  85526. * Attach a new callback raised when context lost event is fired
  85527. * @param callback defines the callback to call
  85528. */
  85529. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85530. /**
  85531. * Attach a new callback raised when context restored event is fired
  85532. * @param callback defines the callback to call
  85533. */
  85534. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85535. /**
  85536. * Gets the source code of the vertex shader associated with a specific webGL program
  85537. * @param program defines the program to use
  85538. * @returns a string containing the source code of the vertex shader associated with the program
  85539. */
  85540. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85541. /**
  85542. * Gets the source code of the fragment shader associated with a specific webGL program
  85543. * @param program defines the program to use
  85544. * @returns a string containing the source code of the fragment shader associated with the program
  85545. */
  85546. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85547. /**
  85548. * Get the current error code of the webGL context
  85549. * @returns the error code
  85550. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85551. */
  85552. getError(): number;
  85553. /**
  85554. * Gets the current framerate
  85555. * @returns a number representing the framerate
  85556. */
  85557. getFps(): number;
  85558. /**
  85559. * Gets the time spent between current and previous frame
  85560. * @returns a number representing the delta time in ms
  85561. */
  85562. getDeltaTime(): number;
  85563. private _measureFps;
  85564. /** @hidden */
  85565. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85566. private _canRenderToFloatFramebuffer;
  85567. private _canRenderToHalfFloatFramebuffer;
  85568. private _canRenderToFramebuffer;
  85569. /** @hidden */
  85570. _getWebGLTextureType(type: number): number;
  85571. private _getInternalFormat;
  85572. /** @hidden */
  85573. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85574. /** @hidden */
  85575. _getRGBAMultiSampleBufferFormat(type: number): number;
  85576. /** @hidden */
  85577. _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;
  85578. /** @hidden */
  85579. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85580. private _partialLoadFile;
  85581. private _cascadeLoadFiles;
  85582. /**
  85583. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85584. * @returns true if the engine can be created
  85585. * @ignorenaming
  85586. */
  85587. static isSupported(): boolean;
  85588. }
  85589. }
  85590. declare module BABYLON {
  85591. /**
  85592. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85593. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85594. */
  85595. export class EffectFallbacks {
  85596. private _defines;
  85597. private _currentRank;
  85598. private _maxRank;
  85599. private _mesh;
  85600. /**
  85601. * Removes the fallback from the bound mesh.
  85602. */
  85603. unBindMesh(): void;
  85604. /**
  85605. * Adds a fallback on the specified property.
  85606. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85607. * @param define The name of the define in the shader
  85608. */
  85609. addFallback(rank: number, define: string): void;
  85610. /**
  85611. * Sets the mesh to use CPU skinning when needing to fallback.
  85612. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85613. * @param mesh The mesh to use the fallbacks.
  85614. */
  85615. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85616. /**
  85617. * Checks to see if more fallbacks are still availible.
  85618. */
  85619. readonly isMoreFallbacks: boolean;
  85620. /**
  85621. * Removes the defines that shoould be removed when falling back.
  85622. * @param currentDefines defines the current define statements for the shader.
  85623. * @param effect defines the current effect we try to compile
  85624. * @returns The resulting defines with defines of the current rank removed.
  85625. */
  85626. reduce(currentDefines: string, effect: Effect): string;
  85627. }
  85628. /**
  85629. * Options to be used when creating an effect.
  85630. */
  85631. export class EffectCreationOptions {
  85632. /**
  85633. * Atrributes that will be used in the shader.
  85634. */
  85635. attributes: string[];
  85636. /**
  85637. * Uniform varible names that will be set in the shader.
  85638. */
  85639. uniformsNames: string[];
  85640. /**
  85641. * Uniform buffer varible names that will be set in the shader.
  85642. */
  85643. uniformBuffersNames: string[];
  85644. /**
  85645. * Sampler texture variable names that will be set in the shader.
  85646. */
  85647. samplers: string[];
  85648. /**
  85649. * Define statements that will be set in the shader.
  85650. */
  85651. defines: any;
  85652. /**
  85653. * Possible fallbacks for this effect to improve performance when needed.
  85654. */
  85655. fallbacks: Nullable<EffectFallbacks>;
  85656. /**
  85657. * Callback that will be called when the shader is compiled.
  85658. */
  85659. onCompiled: Nullable<(effect: Effect) => void>;
  85660. /**
  85661. * Callback that will be called if an error occurs during shader compilation.
  85662. */
  85663. onError: Nullable<(effect: Effect, errors: string) => void>;
  85664. /**
  85665. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85666. */
  85667. indexParameters: any;
  85668. /**
  85669. * Max number of lights that can be used in the shader.
  85670. */
  85671. maxSimultaneousLights: number;
  85672. /**
  85673. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85674. */
  85675. transformFeedbackVaryings: Nullable<string[]>;
  85676. }
  85677. /**
  85678. * Effect containing vertex and fragment shader that can be executed on an object.
  85679. */
  85680. export class Effect {
  85681. /**
  85682. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85683. */
  85684. static ShadersRepository: string;
  85685. /**
  85686. * Name of the effect.
  85687. */
  85688. name: any;
  85689. /**
  85690. * String container all the define statements that should be set on the shader.
  85691. */
  85692. defines: string;
  85693. /**
  85694. * Callback that will be called when the shader is compiled.
  85695. */
  85696. onCompiled: Nullable<(effect: Effect) => void>;
  85697. /**
  85698. * Callback that will be called if an error occurs during shader compilation.
  85699. */
  85700. onError: Nullable<(effect: Effect, errors: string) => void>;
  85701. /**
  85702. * Callback that will be called when effect is bound.
  85703. */
  85704. onBind: Nullable<(effect: Effect) => void>;
  85705. /**
  85706. * Unique ID of the effect.
  85707. */
  85708. uniqueId: number;
  85709. /**
  85710. * Observable that will be called when the shader is compiled.
  85711. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85712. */
  85713. onCompileObservable: Observable<Effect>;
  85714. /**
  85715. * Observable that will be called if an error occurs during shader compilation.
  85716. */
  85717. onErrorObservable: Observable<Effect>;
  85718. /** @hidden */
  85719. _onBindObservable: Nullable<Observable<Effect>>;
  85720. /**
  85721. * Observable that will be called when effect is bound.
  85722. */
  85723. readonly onBindObservable: Observable<Effect>;
  85724. /** @hidden */
  85725. _bonesComputationForcedToCPU: boolean;
  85726. private static _uniqueIdSeed;
  85727. private _engine;
  85728. private _uniformBuffersNames;
  85729. private _uniformsNames;
  85730. private _samplers;
  85731. private _isReady;
  85732. private _compilationError;
  85733. private _attributesNames;
  85734. private _attributes;
  85735. private _uniforms;
  85736. /**
  85737. * Key for the effect.
  85738. * @hidden
  85739. */
  85740. _key: string;
  85741. private _indexParameters;
  85742. private _fallbacks;
  85743. private _vertexSourceCode;
  85744. private _fragmentSourceCode;
  85745. private _vertexSourceCodeOverride;
  85746. private _fragmentSourceCodeOverride;
  85747. private _transformFeedbackVaryings;
  85748. /**
  85749. * Compiled shader to webGL program.
  85750. * @hidden
  85751. */
  85752. _program: WebGLProgram;
  85753. private _valueCache;
  85754. private static _baseCache;
  85755. /**
  85756. * Instantiates an effect.
  85757. * An effect can be used to create/manage/execute vertex and fragment shaders.
  85758. * @param baseName Name of the effect.
  85759. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  85760. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  85761. * @param samplers List of sampler variables that will be passed to the shader.
  85762. * @param engine Engine to be used to render the effect
  85763. * @param defines Define statements to be added to the shader.
  85764. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  85765. * @param onCompiled Callback that will be called when the shader is compiled.
  85766. * @param onError Callback that will be called if an error occurs during shader compilation.
  85767. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85768. */
  85769. 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);
  85770. /**
  85771. * Unique key for this effect
  85772. */
  85773. readonly key: string;
  85774. /**
  85775. * If the effect has been compiled and prepared.
  85776. * @returns if the effect is compiled and prepared.
  85777. */
  85778. isReady(): boolean;
  85779. /**
  85780. * The engine the effect was initialized with.
  85781. * @returns the engine.
  85782. */
  85783. getEngine(): Engine;
  85784. /**
  85785. * The compiled webGL program for the effect
  85786. * @returns the webGL program.
  85787. */
  85788. getProgram(): WebGLProgram;
  85789. /**
  85790. * The set of names of attribute variables for the shader.
  85791. * @returns An array of attribute names.
  85792. */
  85793. getAttributesNames(): string[];
  85794. /**
  85795. * Returns the attribute at the given index.
  85796. * @param index The index of the attribute.
  85797. * @returns The location of the attribute.
  85798. */
  85799. getAttributeLocation(index: number): number;
  85800. /**
  85801. * Returns the attribute based on the name of the variable.
  85802. * @param name of the attribute to look up.
  85803. * @returns the attribute location.
  85804. */
  85805. getAttributeLocationByName(name: string): number;
  85806. /**
  85807. * The number of attributes.
  85808. * @returns the numnber of attributes.
  85809. */
  85810. getAttributesCount(): number;
  85811. /**
  85812. * Gets the index of a uniform variable.
  85813. * @param uniformName of the uniform to look up.
  85814. * @returns the index.
  85815. */
  85816. getUniformIndex(uniformName: string): number;
  85817. /**
  85818. * Returns the attribute based on the name of the variable.
  85819. * @param uniformName of the uniform to look up.
  85820. * @returns the location of the uniform.
  85821. */
  85822. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  85823. /**
  85824. * Returns an array of sampler variable names
  85825. * @returns The array of sampler variable neames.
  85826. */
  85827. getSamplers(): string[];
  85828. /**
  85829. * The error from the last compilation.
  85830. * @returns the error string.
  85831. */
  85832. getCompilationError(): string;
  85833. /**
  85834. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  85835. * @param func The callback to be used.
  85836. */
  85837. executeWhenCompiled(func: (effect: Effect) => void): void;
  85838. private _checkIsReady;
  85839. /** @hidden */
  85840. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  85841. /** @hidden */
  85842. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  85843. /** @hidden */
  85844. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  85845. private _processShaderConversion;
  85846. private _processIncludes;
  85847. private _processPrecision;
  85848. /**
  85849. * Recompiles the webGL program
  85850. * @param vertexSourceCode The source code for the vertex shader.
  85851. * @param fragmentSourceCode The source code for the fragment shader.
  85852. * @param onCompiled Callback called when completed.
  85853. * @param onError Callback called on error.
  85854. * @hidden
  85855. */
  85856. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  85857. /**
  85858. * Gets the uniform locations of the the specified variable names
  85859. * @param names THe names of the variables to lookup.
  85860. * @returns Array of locations in the same order as variable names.
  85861. */
  85862. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  85863. /**
  85864. * Prepares the effect
  85865. * @hidden
  85866. */
  85867. _prepareEffect(): void;
  85868. /**
  85869. * Checks if the effect is supported. (Must be called after compilation)
  85870. */
  85871. readonly isSupported: boolean;
  85872. /**
  85873. * Binds a texture to the engine to be used as output of the shader.
  85874. * @param channel Name of the output variable.
  85875. * @param texture Texture to bind.
  85876. * @hidden
  85877. */
  85878. _bindTexture(channel: string, texture: InternalTexture): void;
  85879. /**
  85880. * Sets a texture on the engine to be used in the shader.
  85881. * @param channel Name of the sampler variable.
  85882. * @param texture Texture to set.
  85883. */
  85884. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  85885. /**
  85886. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  85887. * @param channel Name of the sampler variable.
  85888. * @param texture Texture to set.
  85889. */
  85890. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  85891. /**
  85892. * Sets an array of textures on the engine to be used in the shader.
  85893. * @param channel Name of the variable.
  85894. * @param textures Textures to set.
  85895. */
  85896. setTextureArray(channel: string, textures: BaseTexture[]): void;
  85897. /**
  85898. * 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)
  85899. * @param channel Name of the sampler variable.
  85900. * @param postProcess Post process to get the input texture from.
  85901. */
  85902. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  85903. /**
  85904. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  85905. * 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)
  85906. * @param channel Name of the sampler variable.
  85907. * @param postProcess Post process to get the output texture from.
  85908. */
  85909. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  85910. /** @hidden */
  85911. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  85912. /** @hidden */
  85913. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  85914. /** @hidden */
  85915. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  85916. /** @hidden */
  85917. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  85918. /**
  85919. * Binds a buffer to a uniform.
  85920. * @param buffer Buffer to bind.
  85921. * @param name Name of the uniform variable to bind to.
  85922. */
  85923. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  85924. /**
  85925. * Binds block to a uniform.
  85926. * @param blockName Name of the block to bind.
  85927. * @param index Index to bind.
  85928. */
  85929. bindUniformBlock(blockName: string, index: number): void;
  85930. /**
  85931. * Sets an interger value on a uniform variable.
  85932. * @param uniformName Name of the variable.
  85933. * @param value Value to be set.
  85934. * @returns this effect.
  85935. */
  85936. setInt(uniformName: string, value: number): Effect;
  85937. /**
  85938. * Sets an int array on a uniform variable.
  85939. * @param uniformName Name of the variable.
  85940. * @param array array to be set.
  85941. * @returns this effect.
  85942. */
  85943. setIntArray(uniformName: string, array: Int32Array): Effect;
  85944. /**
  85945. * 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)
  85946. * @param uniformName Name of the variable.
  85947. * @param array array to be set.
  85948. * @returns this effect.
  85949. */
  85950. setIntArray2(uniformName: string, array: Int32Array): Effect;
  85951. /**
  85952. * 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)
  85953. * @param uniformName Name of the variable.
  85954. * @param array array to be set.
  85955. * @returns this effect.
  85956. */
  85957. setIntArray3(uniformName: string, array: Int32Array): Effect;
  85958. /**
  85959. * 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)
  85960. * @param uniformName Name of the variable.
  85961. * @param array array to be set.
  85962. * @returns this effect.
  85963. */
  85964. setIntArray4(uniformName: string, array: Int32Array): Effect;
  85965. /**
  85966. * Sets an float array on a uniform variable.
  85967. * @param uniformName Name of the variable.
  85968. * @param array array to be set.
  85969. * @returns this effect.
  85970. */
  85971. setFloatArray(uniformName: string, array: Float32Array): Effect;
  85972. /**
  85973. * 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)
  85974. * @param uniformName Name of the variable.
  85975. * @param array array to be set.
  85976. * @returns this effect.
  85977. */
  85978. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  85979. /**
  85980. * 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)
  85981. * @param uniformName Name of the variable.
  85982. * @param array array to be set.
  85983. * @returns this effect.
  85984. */
  85985. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  85986. /**
  85987. * 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)
  85988. * @param uniformName Name of the variable.
  85989. * @param array array to be set.
  85990. * @returns this effect.
  85991. */
  85992. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  85993. /**
  85994. * Sets an array on a uniform variable.
  85995. * @param uniformName Name of the variable.
  85996. * @param array array to be set.
  85997. * @returns this effect.
  85998. */
  85999. setArray(uniformName: string, array: number[]): Effect;
  86000. /**
  86001. * 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)
  86002. * @param uniformName Name of the variable.
  86003. * @param array array to be set.
  86004. * @returns this effect.
  86005. */
  86006. setArray2(uniformName: string, array: number[]): Effect;
  86007. /**
  86008. * 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)
  86009. * @param uniformName Name of the variable.
  86010. * @param array array to be set.
  86011. * @returns this effect.
  86012. */
  86013. setArray3(uniformName: string, array: number[]): Effect;
  86014. /**
  86015. * 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)
  86016. * @param uniformName Name of the variable.
  86017. * @param array array to be set.
  86018. * @returns this effect.
  86019. */
  86020. setArray4(uniformName: string, array: number[]): Effect;
  86021. /**
  86022. * Sets matrices on a uniform variable.
  86023. * @param uniformName Name of the variable.
  86024. * @param matrices matrices to be set.
  86025. * @returns this effect.
  86026. */
  86027. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86028. /**
  86029. * Sets matrix on a uniform variable.
  86030. * @param uniformName Name of the variable.
  86031. * @param matrix matrix to be set.
  86032. * @returns this effect.
  86033. */
  86034. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86035. /**
  86036. * 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)
  86037. * @param uniformName Name of the variable.
  86038. * @param matrix matrix to be set.
  86039. * @returns this effect.
  86040. */
  86041. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86042. /**
  86043. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86044. * @param uniformName Name of the variable.
  86045. * @param matrix matrix to be set.
  86046. * @returns this effect.
  86047. */
  86048. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86049. /**
  86050. * Sets a float on a uniform variable.
  86051. * @param uniformName Name of the variable.
  86052. * @param value value to be set.
  86053. * @returns this effect.
  86054. */
  86055. setFloat(uniformName: string, value: number): Effect;
  86056. /**
  86057. * Sets a boolean on a uniform variable.
  86058. * @param uniformName Name of the variable.
  86059. * @param bool value to be set.
  86060. * @returns this effect.
  86061. */
  86062. setBool(uniformName: string, bool: boolean): Effect;
  86063. /**
  86064. * Sets a Vector2 on a uniform variable.
  86065. * @param uniformName Name of the variable.
  86066. * @param vector2 vector2 to be set.
  86067. * @returns this effect.
  86068. */
  86069. setVector2(uniformName: string, vector2: Vector2): Effect;
  86070. /**
  86071. * Sets a float2 on a uniform variable.
  86072. * @param uniformName Name of the variable.
  86073. * @param x First float in float2.
  86074. * @param y Second float in float2.
  86075. * @returns this effect.
  86076. */
  86077. setFloat2(uniformName: string, x: number, y: number): Effect;
  86078. /**
  86079. * Sets a Vector3 on a uniform variable.
  86080. * @param uniformName Name of the variable.
  86081. * @param vector3 Value to be set.
  86082. * @returns this effect.
  86083. */
  86084. setVector3(uniformName: string, vector3: Vector3): Effect;
  86085. /**
  86086. * Sets a float3 on a uniform variable.
  86087. * @param uniformName Name of the variable.
  86088. * @param x First float in float3.
  86089. * @param y Second float in float3.
  86090. * @param z Third float in float3.
  86091. * @returns this effect.
  86092. */
  86093. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86094. /**
  86095. * Sets a Vector4 on a uniform variable.
  86096. * @param uniformName Name of the variable.
  86097. * @param vector4 Value to be set.
  86098. * @returns this effect.
  86099. */
  86100. setVector4(uniformName: string, vector4: Vector4): Effect;
  86101. /**
  86102. * Sets a float4 on a uniform variable.
  86103. * @param uniformName Name of the variable.
  86104. * @param x First float in float4.
  86105. * @param y Second float in float4.
  86106. * @param z Third float in float4.
  86107. * @param w Fourth float in float4.
  86108. * @returns this effect.
  86109. */
  86110. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86111. /**
  86112. * Sets a Color3 on a uniform variable.
  86113. * @param uniformName Name of the variable.
  86114. * @param color3 Value to be set.
  86115. * @returns this effect.
  86116. */
  86117. setColor3(uniformName: string, color3: Color3): Effect;
  86118. /**
  86119. * Sets a Color4 on a uniform variable.
  86120. * @param uniformName Name of the variable.
  86121. * @param color3 Value to be set.
  86122. * @param alpha Alpha value to be set.
  86123. * @returns this effect.
  86124. */
  86125. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86126. /**
  86127. * Sets a Color4 on a uniform variable
  86128. * @param uniformName defines the name of the variable
  86129. * @param color4 defines the value to be set
  86130. * @returns this effect.
  86131. */
  86132. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86133. /**
  86134. * This function will add a new shader to the shader store
  86135. * @param name the name of the shader
  86136. * @param pixelShader optional pixel shader content
  86137. * @param vertexShader optional vertex shader content
  86138. */
  86139. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86140. /**
  86141. * Store of each shader (The can be looked up using effect.key)
  86142. */
  86143. static ShadersStore: {
  86144. [key: string]: string;
  86145. };
  86146. /**
  86147. * Store of each included file for a shader (The can be looked up using effect.key)
  86148. */
  86149. static IncludesShadersStore: {
  86150. [key: string]: string;
  86151. };
  86152. /**
  86153. * Resets the cache of effects.
  86154. */
  86155. static ResetCache(): void;
  86156. }
  86157. }
  86158. declare module BABYLON {
  86159. /**
  86160. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86161. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86162. * 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;
  86163. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86164. */
  86165. export class ColorCurves {
  86166. private _dirty;
  86167. private _tempColor;
  86168. private _globalCurve;
  86169. private _highlightsCurve;
  86170. private _midtonesCurve;
  86171. private _shadowsCurve;
  86172. private _positiveCurve;
  86173. private _negativeCurve;
  86174. private _globalHue;
  86175. private _globalDensity;
  86176. private _globalSaturation;
  86177. private _globalExposure;
  86178. /**
  86179. * Gets the global Hue value.
  86180. * 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).
  86181. */
  86182. /**
  86183. * Sets the global Hue value.
  86184. * 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).
  86185. */
  86186. globalHue: number;
  86187. /**
  86188. * Gets the global Density value.
  86189. * 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.
  86190. * Values less than zero provide a filter of opposite hue.
  86191. */
  86192. /**
  86193. * Sets the global Density value.
  86194. * 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.
  86195. * Values less than zero provide a filter of opposite hue.
  86196. */
  86197. globalDensity: number;
  86198. /**
  86199. * Gets the global Saturation value.
  86200. * 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.
  86201. */
  86202. /**
  86203. * Sets the global Saturation value.
  86204. * 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.
  86205. */
  86206. globalSaturation: number;
  86207. /**
  86208. * Gets the global Exposure value.
  86209. * 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.
  86210. */
  86211. /**
  86212. * Sets the global Exposure value.
  86213. * 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.
  86214. */
  86215. globalExposure: number;
  86216. private _highlightsHue;
  86217. private _highlightsDensity;
  86218. private _highlightsSaturation;
  86219. private _highlightsExposure;
  86220. /**
  86221. * Gets the highlights Hue value.
  86222. * 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).
  86223. */
  86224. /**
  86225. * Sets the highlights Hue value.
  86226. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  86227. */
  86228. highlightsHue: number;
  86229. /**
  86230. * Gets the highlights Density value.
  86231. * 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.
  86232. * Values less than zero provide a filter of opposite hue.
  86233. */
  86234. /**
  86235. * Sets the highlights Density value.
  86236. * 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.
  86237. * Values less than zero provide a filter of opposite hue.
  86238. */
  86239. highlightsDensity: number;
  86240. /**
  86241. * Gets the highlights Saturation value.
  86242. * 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.
  86243. */
  86244. /**
  86245. * Sets the highlights Saturation value.
  86246. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  86247. */
  86248. highlightsSaturation: number;
  86249. /**
  86250. * Gets the highlights Exposure value.
  86251. * 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.
  86252. */
  86253. /**
  86254. * Sets the highlights Exposure value.
  86255. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  86256. */
  86257. highlightsExposure: number;
  86258. private _midtonesHue;
  86259. private _midtonesDensity;
  86260. private _midtonesSaturation;
  86261. private _midtonesExposure;
  86262. /**
  86263. * Gets the midtones Hue value.
  86264. * 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).
  86265. */
  86266. /**
  86267. * Sets the midtones Hue value.
  86268. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  86269. */
  86270. midtonesHue: number;
  86271. /**
  86272. * Gets the midtones Density value.
  86273. * 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.
  86274. * Values less than zero provide a filter of opposite hue.
  86275. */
  86276. /**
  86277. * Sets the midtones Density value.
  86278. * 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.
  86279. * Values less than zero provide a filter of opposite hue.
  86280. */
  86281. midtonesDensity: number;
  86282. /**
  86283. * Gets the midtones Saturation value.
  86284. * 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.
  86285. */
  86286. /**
  86287. * Sets the midtones Saturation value.
  86288. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  86289. */
  86290. midtonesSaturation: number;
  86291. /**
  86292. * Gets the midtones Exposure value.
  86293. * 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.
  86294. */
  86295. /**
  86296. * Sets the midtones Exposure value.
  86297. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  86298. */
  86299. midtonesExposure: number;
  86300. private _shadowsHue;
  86301. private _shadowsDensity;
  86302. private _shadowsSaturation;
  86303. private _shadowsExposure;
  86304. /**
  86305. * Gets the shadows Hue value.
  86306. * 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).
  86307. */
  86308. /**
  86309. * Sets the shadows Hue value.
  86310. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  86311. */
  86312. shadowsHue: number;
  86313. /**
  86314. * Gets the shadows Density value.
  86315. * 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.
  86316. * Values less than zero provide a filter of opposite hue.
  86317. */
  86318. /**
  86319. * Sets the shadows Density value.
  86320. * 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.
  86321. * Values less than zero provide a filter of opposite hue.
  86322. */
  86323. shadowsDensity: number;
  86324. /**
  86325. * Gets the shadows Saturation value.
  86326. * 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.
  86327. */
  86328. /**
  86329. * Sets the shadows Saturation value.
  86330. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  86331. */
  86332. shadowsSaturation: number;
  86333. /**
  86334. * Gets the shadows Exposure value.
  86335. * 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.
  86336. */
  86337. /**
  86338. * Sets the shadows Exposure value.
  86339. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  86340. */
  86341. shadowsExposure: number;
  86342. /**
  86343. * Returns the class name
  86344. * @returns The class name
  86345. */
  86346. getClassName(): string;
  86347. /**
  86348. * Binds the color curves to the shader.
  86349. * @param colorCurves The color curve to bind
  86350. * @param effect The effect to bind to
  86351. * @param positiveUniform The positive uniform shader parameter
  86352. * @param neutralUniform The neutral uniform shader parameter
  86353. * @param negativeUniform The negative uniform shader parameter
  86354. */
  86355. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86356. /**
  86357. * Prepare the list of uniforms associated with the ColorCurves effects.
  86358. * @param uniformsList The list of uniforms used in the effect
  86359. */
  86360. static PrepareUniforms(uniformsList: string[]): void;
  86361. /**
  86362. * Returns color grading data based on a hue, density, saturation and exposure value.
  86363. * @param filterHue The hue of the color filter.
  86364. * @param filterDensity The density of the color filter.
  86365. * @param saturation The saturation.
  86366. * @param exposure The exposure.
  86367. * @param result The result data container.
  86368. */
  86369. private getColorGradingDataToRef;
  86370. /**
  86371. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86372. * @param value The input slider value in range [-100,100].
  86373. * @returns Adjusted value.
  86374. */
  86375. private static applyColorGradingSliderNonlinear;
  86376. /**
  86377. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86378. * @param hue The hue (H) input.
  86379. * @param saturation The saturation (S) input.
  86380. * @param brightness The brightness (B) input.
  86381. * @result An RGBA color represented as Vector4.
  86382. */
  86383. private static fromHSBToRef;
  86384. /**
  86385. * Returns a value clamped between min and max
  86386. * @param value The value to clamp
  86387. * @param min The minimum of value
  86388. * @param max The maximum of value
  86389. * @returns The clamped value.
  86390. */
  86391. private static clamp;
  86392. /**
  86393. * Clones the current color curve instance.
  86394. * @return The cloned curves
  86395. */
  86396. clone(): ColorCurves;
  86397. /**
  86398. * Serializes the current color curve instance to a json representation.
  86399. * @return a JSON representation
  86400. */
  86401. serialize(): any;
  86402. /**
  86403. * Parses the color curve from a json representation.
  86404. * @param source the JSON source to parse
  86405. * @return The parsed curves
  86406. */
  86407. static Parse(source: any): ColorCurves;
  86408. }
  86409. }
  86410. declare module BABYLON {
  86411. /**
  86412. * Interface to follow in your material defines to integrate easily the
  86413. * Image proccessing functions.
  86414. * @hidden
  86415. */
  86416. export interface IImageProcessingConfigurationDefines {
  86417. IMAGEPROCESSING: boolean;
  86418. VIGNETTE: boolean;
  86419. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86420. VIGNETTEBLENDMODEOPAQUE: boolean;
  86421. TONEMAPPING: boolean;
  86422. TONEMAPPING_ACES: boolean;
  86423. CONTRAST: boolean;
  86424. EXPOSURE: boolean;
  86425. COLORCURVES: boolean;
  86426. COLORGRADING: boolean;
  86427. COLORGRADING3D: boolean;
  86428. SAMPLER3DGREENDEPTH: boolean;
  86429. SAMPLER3DBGRMAP: boolean;
  86430. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86431. }
  86432. /**
  86433. * @hidden
  86434. */
  86435. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86436. IMAGEPROCESSING: boolean;
  86437. VIGNETTE: boolean;
  86438. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86439. VIGNETTEBLENDMODEOPAQUE: boolean;
  86440. TONEMAPPING: boolean;
  86441. TONEMAPPING_ACES: boolean;
  86442. CONTRAST: boolean;
  86443. COLORCURVES: boolean;
  86444. COLORGRADING: boolean;
  86445. COLORGRADING3D: boolean;
  86446. SAMPLER3DGREENDEPTH: boolean;
  86447. SAMPLER3DBGRMAP: boolean;
  86448. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86449. EXPOSURE: boolean;
  86450. constructor();
  86451. }
  86452. /**
  86453. * This groups together the common properties used for image processing either in direct forward pass
  86454. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86455. * or not.
  86456. */
  86457. export class ImageProcessingConfiguration {
  86458. /**
  86459. * Default tone mapping applied in BabylonJS.
  86460. */
  86461. static readonly TONEMAPPING_STANDARD: number;
  86462. /**
  86463. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86464. * to other engines rendering to increase portability.
  86465. */
  86466. static readonly TONEMAPPING_ACES: number;
  86467. /**
  86468. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86469. */
  86470. colorCurves: Nullable<ColorCurves>;
  86471. private _colorCurvesEnabled;
  86472. /**
  86473. * Gets wether the color curves effect is enabled.
  86474. */
  86475. /**
  86476. * Sets wether the color curves effect is enabled.
  86477. */
  86478. colorCurvesEnabled: boolean;
  86479. private _colorGradingTexture;
  86480. /**
  86481. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86482. */
  86483. /**
  86484. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86485. */
  86486. colorGradingTexture: Nullable<BaseTexture>;
  86487. private _colorGradingEnabled;
  86488. /**
  86489. * Gets wether the color grading effect is enabled.
  86490. */
  86491. /**
  86492. * Sets wether the color grading effect is enabled.
  86493. */
  86494. colorGradingEnabled: boolean;
  86495. private _colorGradingWithGreenDepth;
  86496. /**
  86497. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86498. */
  86499. /**
  86500. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86501. */
  86502. colorGradingWithGreenDepth: boolean;
  86503. private _colorGradingBGR;
  86504. /**
  86505. * Gets wether the color grading texture contains BGR values.
  86506. */
  86507. /**
  86508. * Sets wether the color grading texture contains BGR values.
  86509. */
  86510. colorGradingBGR: boolean;
  86511. /** @hidden */
  86512. _exposure: number;
  86513. /**
  86514. * Gets the Exposure used in the effect.
  86515. */
  86516. /**
  86517. * Sets the Exposure used in the effect.
  86518. */
  86519. exposure: number;
  86520. private _toneMappingEnabled;
  86521. /**
  86522. * Gets wether the tone mapping effect is enabled.
  86523. */
  86524. /**
  86525. * Sets wether the tone mapping effect is enabled.
  86526. */
  86527. toneMappingEnabled: boolean;
  86528. private _toneMappingType;
  86529. /**
  86530. * Gets the type of tone mapping effect.
  86531. */
  86532. /**
  86533. * Sets the type of tone mapping effect used in BabylonJS.
  86534. */
  86535. toneMappingType: number;
  86536. protected _contrast: number;
  86537. /**
  86538. * Gets the contrast used in the effect.
  86539. */
  86540. /**
  86541. * Sets the contrast used in the effect.
  86542. */
  86543. contrast: number;
  86544. /**
  86545. * Vignette stretch size.
  86546. */
  86547. vignetteStretch: number;
  86548. /**
  86549. * Vignette centre X Offset.
  86550. */
  86551. vignetteCentreX: number;
  86552. /**
  86553. * Vignette centre Y Offset.
  86554. */
  86555. vignetteCentreY: number;
  86556. /**
  86557. * Vignette weight or intensity of the vignette effect.
  86558. */
  86559. vignetteWeight: number;
  86560. /**
  86561. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86562. * if vignetteEnabled is set to true.
  86563. */
  86564. vignetteColor: Color4;
  86565. /**
  86566. * Camera field of view used by the Vignette effect.
  86567. */
  86568. vignetteCameraFov: number;
  86569. private _vignetteBlendMode;
  86570. /**
  86571. * Gets the vignette blend mode allowing different kind of effect.
  86572. */
  86573. /**
  86574. * Sets the vignette blend mode allowing different kind of effect.
  86575. */
  86576. vignetteBlendMode: number;
  86577. private _vignetteEnabled;
  86578. /**
  86579. * Gets wether the vignette effect is enabled.
  86580. */
  86581. /**
  86582. * Sets wether the vignette effect is enabled.
  86583. */
  86584. vignetteEnabled: boolean;
  86585. private _applyByPostProcess;
  86586. /**
  86587. * Gets wether the image processing is applied through a post process or not.
  86588. */
  86589. /**
  86590. * Sets wether the image processing is applied through a post process or not.
  86591. */
  86592. applyByPostProcess: boolean;
  86593. private _isEnabled;
  86594. /**
  86595. * Gets wether the image processing is enabled or not.
  86596. */
  86597. /**
  86598. * Sets wether the image processing is enabled or not.
  86599. */
  86600. isEnabled: boolean;
  86601. /**
  86602. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86603. */
  86604. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86605. /**
  86606. * Method called each time the image processing information changes requires to recompile the effect.
  86607. */
  86608. protected _updateParameters(): void;
  86609. /**
  86610. * Gets the current class name.
  86611. * @return "ImageProcessingConfiguration"
  86612. */
  86613. getClassName(): string;
  86614. /**
  86615. * Prepare the list of uniforms associated with the Image Processing effects.
  86616. * @param uniforms The list of uniforms used in the effect
  86617. * @param defines the list of defines currently in use
  86618. */
  86619. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86620. /**
  86621. * Prepare the list of samplers associated with the Image Processing effects.
  86622. * @param samplersList The list of uniforms used in the effect
  86623. * @param defines the list of defines currently in use
  86624. */
  86625. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86626. /**
  86627. * Prepare the list of defines associated to the shader.
  86628. * @param defines the list of defines to complete
  86629. * @param forPostProcess Define if we are currently in post process mode or not
  86630. */
  86631. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86632. /**
  86633. * Returns true if all the image processing information are ready.
  86634. * @returns True if ready, otherwise, false
  86635. */
  86636. isReady(): boolean;
  86637. /**
  86638. * Binds the image processing to the shader.
  86639. * @param effect The effect to bind to
  86640. * @param aspectRatio Define the current aspect ratio of the effect
  86641. */
  86642. bind(effect: Effect, aspectRatio?: number): void;
  86643. /**
  86644. * Clones the current image processing instance.
  86645. * @return The cloned image processing
  86646. */
  86647. clone(): ImageProcessingConfiguration;
  86648. /**
  86649. * Serializes the current image processing instance to a json representation.
  86650. * @return a JSON representation
  86651. */
  86652. serialize(): any;
  86653. /**
  86654. * Parses the image processing from a json representation.
  86655. * @param source the JSON source to parse
  86656. * @return The parsed image processing
  86657. */
  86658. static Parse(source: any): ImageProcessingConfiguration;
  86659. private static _VIGNETTEMODE_MULTIPLY;
  86660. private static _VIGNETTEMODE_OPAQUE;
  86661. /**
  86662. * Used to apply the vignette as a mix with the pixel color.
  86663. */
  86664. static readonly VIGNETTEMODE_MULTIPLY: number;
  86665. /**
  86666. * Used to apply the vignette as a replacement of the pixel color.
  86667. */
  86668. static readonly VIGNETTEMODE_OPAQUE: number;
  86669. }
  86670. }
  86671. declare module BABYLON {
  86672. /**
  86673. * This represents all the required information to add a fresnel effect on a material:
  86674. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86675. */
  86676. export class FresnelParameters {
  86677. private _isEnabled;
  86678. /**
  86679. * Define if the fresnel effect is enable or not.
  86680. */
  86681. isEnabled: boolean;
  86682. /**
  86683. * Define the color used on edges (grazing angle)
  86684. */
  86685. leftColor: Color3;
  86686. /**
  86687. * Define the color used on center
  86688. */
  86689. rightColor: Color3;
  86690. /**
  86691. * Define bias applied to computed fresnel term
  86692. */
  86693. bias: number;
  86694. /**
  86695. * Defined the power exponent applied to fresnel term
  86696. */
  86697. power: number;
  86698. /**
  86699. * Clones the current fresnel and its valuues
  86700. * @returns a clone fresnel configuration
  86701. */
  86702. clone(): FresnelParameters;
  86703. /**
  86704. * Serializes the current fresnel parameters to a JSON representation.
  86705. * @return the JSON serialization
  86706. */
  86707. serialize(): any;
  86708. /**
  86709. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86710. * @param parsedFresnelParameters Define the JSON representation
  86711. * @returns the parsed parameters
  86712. */
  86713. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86714. }
  86715. }
  86716. declare module BABYLON {
  86717. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86718. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86719. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86720. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86721. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86722. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86723. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86724. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86725. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86726. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86727. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86728. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86729. /**
  86730. * Decorator used to define property that can be serialized as reference to a camera
  86731. * @param sourceName defines the name of the property to decorate
  86732. */
  86733. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86734. /**
  86735. * Class used to help serialization objects
  86736. */
  86737. export class SerializationHelper {
  86738. /** hidden */
  86739. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  86740. /** hidden */
  86741. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  86742. /** hidden */
  86743. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  86744. /** hidden */
  86745. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  86746. /**
  86747. * Appends the serialized animations from the source animations
  86748. * @param source Source containing the animations
  86749. * @param destination Target to store the animations
  86750. */
  86751. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  86752. /**
  86753. * Static function used to serialized a specific entity
  86754. * @param entity defines the entity to serialize
  86755. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  86756. * @returns a JSON compatible object representing the serialization of the entity
  86757. */
  86758. static Serialize<T>(entity: T, serializationObject?: any): any;
  86759. /**
  86760. * Creates a new entity from a serialization data object
  86761. * @param creationFunction defines a function used to instanciated the new entity
  86762. * @param source defines the source serialization data
  86763. * @param scene defines the hosting scene
  86764. * @param rootUrl defines the root url for resources
  86765. * @returns a new entity
  86766. */
  86767. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  86768. /**
  86769. * Clones an object
  86770. * @param creationFunction defines the function used to instanciate the new object
  86771. * @param source defines the source object
  86772. * @returns the cloned object
  86773. */
  86774. static Clone<T>(creationFunction: () => T, source: T): T;
  86775. /**
  86776. * Instanciates a new object based on a source one (some data will be shared between both object)
  86777. * @param creationFunction defines the function used to instanciate the new object
  86778. * @param source defines the source object
  86779. * @returns the new object
  86780. */
  86781. static Instanciate<T>(creationFunction: () => T, source: T): T;
  86782. }
  86783. }
  86784. declare module BABYLON {
  86785. /**
  86786. * This is the base class of all the camera used in the application.
  86787. * @see http://doc.babylonjs.com/features/cameras
  86788. */
  86789. export class Camera extends Node {
  86790. /** @hidden */
  86791. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  86792. /**
  86793. * This is the default projection mode used by the cameras.
  86794. * It helps recreating a feeling of perspective and better appreciate depth.
  86795. * This is the best way to simulate real life cameras.
  86796. */
  86797. static readonly PERSPECTIVE_CAMERA: number;
  86798. /**
  86799. * This helps creating camera with an orthographic mode.
  86800. * 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.
  86801. */
  86802. static readonly ORTHOGRAPHIC_CAMERA: number;
  86803. /**
  86804. * This is the default FOV mode for perspective cameras.
  86805. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  86806. */
  86807. static readonly FOVMODE_VERTICAL_FIXED: number;
  86808. /**
  86809. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  86810. */
  86811. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  86812. /**
  86813. * This specifies ther is no need for a camera rig.
  86814. * Basically only one eye is rendered corresponding to the camera.
  86815. */
  86816. static readonly RIG_MODE_NONE: number;
  86817. /**
  86818. * Simulates a camera Rig with one blue eye and one red eye.
  86819. * This can be use with 3d blue and red glasses.
  86820. */
  86821. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  86822. /**
  86823. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  86824. */
  86825. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  86826. /**
  86827. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  86828. */
  86829. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  86830. /**
  86831. * Defines that both eyes of the camera will be rendered over under each other.
  86832. */
  86833. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  86834. /**
  86835. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  86836. */
  86837. static readonly RIG_MODE_VR: number;
  86838. /**
  86839. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  86840. */
  86841. static readonly RIG_MODE_WEBVR: number;
  86842. /**
  86843. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  86844. */
  86845. static readonly RIG_MODE_CUSTOM: number;
  86846. /**
  86847. * Defines if by default attaching controls should prevent the default javascript event to continue.
  86848. */
  86849. static ForceAttachControlToAlwaysPreventDefault: boolean;
  86850. /**
  86851. * @hidden
  86852. * Might be removed once multiview will be a thing
  86853. */
  86854. static UseAlternateWebVRRendering: boolean;
  86855. /**
  86856. * Define the input manager associated with the camera.
  86857. */
  86858. inputs: CameraInputsManager<Camera>;
  86859. /** @hidden */
  86860. _position: Vector3;
  86861. /**
  86862. * Define the current local position of the camera in the scene
  86863. */
  86864. position: Vector3;
  86865. /**
  86866. * The vector the camera should consider as up.
  86867. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  86868. */
  86869. upVector: Vector3;
  86870. /**
  86871. * Define the current limit on the left side for an orthographic camera
  86872. * In scene unit
  86873. */
  86874. orthoLeft: Nullable<number>;
  86875. /**
  86876. * Define the current limit on the right side for an orthographic camera
  86877. * In scene unit
  86878. */
  86879. orthoRight: Nullable<number>;
  86880. /**
  86881. * Define the current limit on the bottom side for an orthographic camera
  86882. * In scene unit
  86883. */
  86884. orthoBottom: Nullable<number>;
  86885. /**
  86886. * Define the current limit on the top side for an orthographic camera
  86887. * In scene unit
  86888. */
  86889. orthoTop: Nullable<number>;
  86890. /**
  86891. * Field Of View is set in Radians. (default is 0.8)
  86892. */
  86893. fov: number;
  86894. /**
  86895. * Define the minimum distance the camera can see from.
  86896. * This is important to note that the depth buffer are not infinite and the closer it starts
  86897. * the more your scene might encounter depth fighting issue.
  86898. */
  86899. minZ: number;
  86900. /**
  86901. * Define the maximum distance the camera can see to.
  86902. * This is important to note that the depth buffer are not infinite and the further it end
  86903. * the more your scene might encounter depth fighting issue.
  86904. */
  86905. maxZ: number;
  86906. /**
  86907. * Define the default inertia of the camera.
  86908. * This helps giving a smooth feeling to the camera movement.
  86909. */
  86910. inertia: number;
  86911. /**
  86912. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  86913. */
  86914. mode: number;
  86915. /**
  86916. * Define wether the camera is intermediate.
  86917. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  86918. */
  86919. isIntermediate: boolean;
  86920. /**
  86921. * Define the viewport of the camera.
  86922. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  86923. */
  86924. viewport: Viewport;
  86925. /**
  86926. * Restricts the camera to viewing objects with the same layerMask.
  86927. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  86928. */
  86929. layerMask: number;
  86930. /**
  86931. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  86932. */
  86933. fovMode: number;
  86934. /**
  86935. * Rig mode of the camera.
  86936. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  86937. * This is normally controlled byt the camera themselves as internal use.
  86938. */
  86939. cameraRigMode: number;
  86940. /**
  86941. * Defines the distance between both "eyes" in case of a RIG
  86942. */
  86943. interaxialDistance: number;
  86944. /**
  86945. * Defines if stereoscopic rendering is done side by side or over under.
  86946. */
  86947. isStereoscopicSideBySide: boolean;
  86948. /**
  86949. * 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
  86950. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  86951. * else in the scene.
  86952. */
  86953. customRenderTargets: RenderTargetTexture[];
  86954. /**
  86955. * When set, the camera will render to this render target instead of the default canvas
  86956. */
  86957. outputRenderTarget: Nullable<RenderTargetTexture>;
  86958. /**
  86959. * Observable triggered when the camera view matrix has changed.
  86960. */
  86961. onViewMatrixChangedObservable: Observable<Camera>;
  86962. /**
  86963. * Observable triggered when the camera Projection matrix has changed.
  86964. */
  86965. onProjectionMatrixChangedObservable: Observable<Camera>;
  86966. /**
  86967. * Observable triggered when the inputs have been processed.
  86968. */
  86969. onAfterCheckInputsObservable: Observable<Camera>;
  86970. /**
  86971. * Observable triggered when reset has been called and applied to the camera.
  86972. */
  86973. onRestoreStateObservable: Observable<Camera>;
  86974. /** @hidden */
  86975. _cameraRigParams: any;
  86976. /** @hidden */
  86977. _rigCameras: Camera[];
  86978. /** @hidden */
  86979. _rigPostProcess: Nullable<PostProcess>;
  86980. protected _webvrViewMatrix: Matrix;
  86981. /** @hidden */
  86982. _skipRendering: boolean;
  86983. /** @hidden */
  86984. _alternateCamera: Camera;
  86985. /** @hidden */
  86986. _projectionMatrix: Matrix;
  86987. /** @hidden */
  86988. _postProcesses: Nullable<PostProcess>[];
  86989. /** @hidden */
  86990. _activeMeshes: SmartArray<AbstractMesh>;
  86991. protected _globalPosition: Vector3;
  86992. /** hidden */
  86993. _computedViewMatrix: Matrix;
  86994. private _doNotComputeProjectionMatrix;
  86995. private _transformMatrix;
  86996. private _frustumPlanes;
  86997. private _refreshFrustumPlanes;
  86998. private _storedFov;
  86999. private _stateStored;
  87000. /**
  87001. * Instantiates a new camera object.
  87002. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87003. * @see http://doc.babylonjs.com/features/cameras
  87004. * @param name Defines the name of the camera in the scene
  87005. * @param position Defines the position of the camera
  87006. * @param scene Defines the scene the camera belongs too
  87007. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87008. */
  87009. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87010. /**
  87011. * Store current camera state (fov, position, etc..)
  87012. * @returns the camera
  87013. */
  87014. storeState(): Camera;
  87015. /**
  87016. * Restores the camera state values if it has been stored. You must call storeState() first
  87017. */
  87018. protected _restoreStateValues(): boolean;
  87019. /**
  87020. * Restored camera state. You must call storeState() first.
  87021. * @returns true if restored and false otherwise
  87022. */
  87023. restoreState(): boolean;
  87024. /**
  87025. * Gets the class name of the camera.
  87026. * @returns the class name
  87027. */
  87028. getClassName(): string;
  87029. /** @hidden */
  87030. readonly _isCamera: boolean;
  87031. /**
  87032. * Gets a string representation of the camera useful for debug purpose.
  87033. * @param fullDetails Defines that a more verboe level of logging is required
  87034. * @returns the string representation
  87035. */
  87036. toString(fullDetails?: boolean): string;
  87037. /**
  87038. * Gets the current world space position of the camera.
  87039. */
  87040. readonly globalPosition: Vector3;
  87041. /**
  87042. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87043. * @returns the active meshe list
  87044. */
  87045. getActiveMeshes(): SmartArray<AbstractMesh>;
  87046. /**
  87047. * Check wether a mesh is part of the current active mesh list of the camera
  87048. * @param mesh Defines the mesh to check
  87049. * @returns true if active, false otherwise
  87050. */
  87051. isActiveMesh(mesh: Mesh): boolean;
  87052. /**
  87053. * Is this camera ready to be used/rendered
  87054. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87055. * @return true if the camera is ready
  87056. */
  87057. isReady(completeCheck?: boolean): boolean;
  87058. /** @hidden */
  87059. _initCache(): void;
  87060. /** @hidden */
  87061. _updateCache(ignoreParentClass?: boolean): void;
  87062. /** @hidden */
  87063. _isSynchronized(): boolean;
  87064. /** @hidden */
  87065. _isSynchronizedViewMatrix(): boolean;
  87066. /** @hidden */
  87067. _isSynchronizedProjectionMatrix(): boolean;
  87068. /**
  87069. * Attach the input controls to a specific dom element to get the input from.
  87070. * @param element Defines the element the controls should be listened from
  87071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87072. */
  87073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87074. /**
  87075. * Detach the current controls from the specified dom element.
  87076. * @param element Defines the element to stop listening the inputs from
  87077. */
  87078. detachControl(element: HTMLElement): void;
  87079. /**
  87080. * Update the camera state according to the different inputs gathered during the frame.
  87081. */
  87082. update(): void;
  87083. /** @hidden */
  87084. _checkInputs(): void;
  87085. /** @hidden */
  87086. readonly rigCameras: Camera[];
  87087. /**
  87088. * Gets the post process used by the rig cameras
  87089. */
  87090. readonly rigPostProcess: Nullable<PostProcess>;
  87091. /**
  87092. * Internal, gets the first post proces.
  87093. * @returns the first post process to be run on this camera.
  87094. */
  87095. _getFirstPostProcess(): Nullable<PostProcess>;
  87096. private _cascadePostProcessesToRigCams;
  87097. /**
  87098. * Attach a post process to the camera.
  87099. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87100. * @param postProcess The post process to attach to the camera
  87101. * @param insertAt The position of the post process in case several of them are in use in the scene
  87102. * @returns the position the post process has been inserted at
  87103. */
  87104. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87105. /**
  87106. * Detach a post process to the camera.
  87107. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87108. * @param postProcess The post process to detach from the camera
  87109. */
  87110. detachPostProcess(postProcess: PostProcess): void;
  87111. /**
  87112. * Gets the current world matrix of the camera
  87113. */
  87114. getWorldMatrix(): Matrix;
  87115. /** @hidden */
  87116. _getViewMatrix(): Matrix;
  87117. /**
  87118. * Gets the current view matrix of the camera.
  87119. * @param force forces the camera to recompute the matrix without looking at the cached state
  87120. * @returns the view matrix
  87121. */
  87122. getViewMatrix(force?: boolean): Matrix;
  87123. /**
  87124. * Freeze the projection matrix.
  87125. * It will prevent the cache check of the camera projection compute and can speed up perf
  87126. * if no parameter of the camera are meant to change
  87127. * @param projection Defines manually a projection if necessary
  87128. */
  87129. freezeProjectionMatrix(projection?: Matrix): void;
  87130. /**
  87131. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87132. */
  87133. unfreezeProjectionMatrix(): void;
  87134. /**
  87135. * Gets the current projection matrix of the camera.
  87136. * @param force forces the camera to recompute the matrix without looking at the cached state
  87137. * @returns the projection matrix
  87138. */
  87139. getProjectionMatrix(force?: boolean): Matrix;
  87140. /**
  87141. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87142. * @returns a Matrix
  87143. */
  87144. getTransformationMatrix(): Matrix;
  87145. private _updateFrustumPlanes;
  87146. /**
  87147. * Checks if a cullable object (mesh...) is in the camera frustum
  87148. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87149. * @param target The object to check
  87150. * @returns true if the object is in frustum otherwise false
  87151. */
  87152. isInFrustum(target: ICullable): boolean;
  87153. /**
  87154. * Checks if a cullable object (mesh...) is in the camera frustum
  87155. * Unlike isInFrustum this cheks the full bounding box
  87156. * @param target The object to check
  87157. * @returns true if the object is in frustum otherwise false
  87158. */
  87159. isCompletelyInFrustum(target: ICullable): boolean;
  87160. /**
  87161. * Gets a ray in the forward direction from the camera.
  87162. * @param length Defines the length of the ray to create
  87163. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87164. * @param origin Defines the start point of the ray which defaults to the camera position
  87165. * @returns the forward ray
  87166. */
  87167. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87168. /**
  87169. * Releases resources associated with this node.
  87170. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87171. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87172. */
  87173. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87174. /** @hidden */
  87175. _isLeftCamera: boolean;
  87176. /**
  87177. * Gets the left camera of a rig setup in case of Rigged Camera
  87178. */
  87179. readonly isLeftCamera: boolean;
  87180. /** @hidden */
  87181. _isRightCamera: boolean;
  87182. /**
  87183. * Gets the right camera of a rig setup in case of Rigged Camera
  87184. */
  87185. readonly isRightCamera: boolean;
  87186. /**
  87187. * Gets the left camera of a rig setup in case of Rigged Camera
  87188. */
  87189. readonly leftCamera: Nullable<FreeCamera>;
  87190. /**
  87191. * Gets the right camera of a rig setup in case of Rigged Camera
  87192. */
  87193. readonly rightCamera: Nullable<FreeCamera>;
  87194. /**
  87195. * Gets the left camera target of a rig setup in case of Rigged Camera
  87196. * @returns the target position
  87197. */
  87198. getLeftTarget(): Nullable<Vector3>;
  87199. /**
  87200. * Gets the right camera target of a rig setup in case of Rigged Camera
  87201. * @returns the target position
  87202. */
  87203. getRightTarget(): Nullable<Vector3>;
  87204. /**
  87205. * @hidden
  87206. */
  87207. setCameraRigMode(mode: number, rigParams: any): void;
  87208. /** @hidden */
  87209. static _setStereoscopicRigMode(camera: Camera): void;
  87210. /** @hidden */
  87211. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87212. /** @hidden */
  87213. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87214. /** @hidden */
  87215. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87216. /** @hidden */
  87217. _getVRProjectionMatrix(): Matrix;
  87218. protected _updateCameraRotationMatrix(): void;
  87219. protected _updateWebVRCameraRotationMatrix(): void;
  87220. /**
  87221. * This function MUST be overwritten by the different WebVR cameras available.
  87222. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87223. * @hidden
  87224. */
  87225. _getWebVRProjectionMatrix(): Matrix;
  87226. /**
  87227. * This function MUST be overwritten by the different WebVR cameras available.
  87228. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87229. * @hidden
  87230. */
  87231. _getWebVRViewMatrix(): Matrix;
  87232. /** @hidden */
  87233. setCameraRigParameter(name: string, value: any): void;
  87234. /**
  87235. * needs to be overridden by children so sub has required properties to be copied
  87236. * @hidden
  87237. */
  87238. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87239. /**
  87240. * May need to be overridden by children
  87241. * @hidden
  87242. */
  87243. _updateRigCameras(): void;
  87244. /** @hidden */
  87245. _setupInputs(): void;
  87246. /**
  87247. * Serialiaze the camera setup to a json represention
  87248. * @returns the JSON representation
  87249. */
  87250. serialize(): any;
  87251. /**
  87252. * Clones the current camera.
  87253. * @param name The cloned camera name
  87254. * @returns the cloned camera
  87255. */
  87256. clone(name: string): Camera;
  87257. /**
  87258. * Gets the direction of the camera relative to a given local axis.
  87259. * @param localAxis Defines the reference axis to provide a relative direction.
  87260. * @return the direction
  87261. */
  87262. getDirection(localAxis: Vector3): Vector3;
  87263. /**
  87264. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87265. * @param localAxis Defines the reference axis to provide a relative direction.
  87266. * @param result Defines the vector to store the result in
  87267. */
  87268. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87269. /**
  87270. * Gets a camera constructor for a given camera type
  87271. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87272. * @param name The name of the camera the result will be able to instantiate
  87273. * @param scene The scene the result will construct the camera in
  87274. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87275. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87276. * @returns a factory method to construc the camera
  87277. */
  87278. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87279. /**
  87280. * Compute the world matrix of the camera.
  87281. * @returns the camera workd matrix
  87282. */
  87283. computeWorldMatrix(): Matrix;
  87284. /**
  87285. * Parse a JSON and creates the camera from the parsed information
  87286. * @param parsedCamera The JSON to parse
  87287. * @param scene The scene to instantiate the camera in
  87288. * @returns the newly constructed camera
  87289. */
  87290. static Parse(parsedCamera: any, scene: Scene): Camera;
  87291. }
  87292. }
  87293. declare module BABYLON {
  87294. /**
  87295. * Interface for any object that can request an animation frame
  87296. */
  87297. export interface ICustomAnimationFrameRequester {
  87298. /**
  87299. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87300. */
  87301. renderFunction?: Function;
  87302. /**
  87303. * Called to request the next frame to render to
  87304. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87305. */
  87306. requestAnimationFrame: Function;
  87307. /**
  87308. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87309. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87310. */
  87311. requestID?: number;
  87312. }
  87313. /**
  87314. * Interface containing an array of animations
  87315. */
  87316. export interface IAnimatable {
  87317. /**
  87318. * Array of animations
  87319. */
  87320. animations: Array<Animation>;
  87321. }
  87322. /** Interface used by value gradients (color, factor, ...) */
  87323. export interface IValueGradient {
  87324. /**
  87325. * Gets or sets the gradient value (between 0 and 1)
  87326. */
  87327. gradient: number;
  87328. }
  87329. /** Class used to store color4 gradient */
  87330. export class ColorGradient implements IValueGradient {
  87331. /**
  87332. * Gets or sets the gradient value (between 0 and 1)
  87333. */
  87334. gradient: number;
  87335. /**
  87336. * Gets or sets first associated color
  87337. */
  87338. color1: Color4;
  87339. /**
  87340. * Gets or sets second associated color
  87341. */
  87342. color2?: Color4;
  87343. /**
  87344. * Will get a color picked randomly between color1 and color2.
  87345. * If color2 is undefined then color1 will be used
  87346. * @param result defines the target Color4 to store the result in
  87347. */
  87348. getColorToRef(result: Color4): void;
  87349. }
  87350. /** Class used to store color 3 gradient */
  87351. export class Color3Gradient implements IValueGradient {
  87352. /**
  87353. * Gets or sets the gradient value (between 0 and 1)
  87354. */
  87355. gradient: number;
  87356. /**
  87357. * Gets or sets the associated color
  87358. */
  87359. color: Color3;
  87360. }
  87361. /** Class used to store factor gradient */
  87362. export class FactorGradient implements IValueGradient {
  87363. /**
  87364. * Gets or sets the gradient value (between 0 and 1)
  87365. */
  87366. gradient: number;
  87367. /**
  87368. * Gets or sets first associated factor
  87369. */
  87370. factor1: number;
  87371. /**
  87372. * Gets or sets second associated factor
  87373. */
  87374. factor2?: number;
  87375. /**
  87376. * Will get a number picked randomly between factor1 and factor2.
  87377. * If factor2 is undefined then factor1 will be used
  87378. * @returns the picked number
  87379. */
  87380. getFactor(): number;
  87381. }
  87382. /**
  87383. * @ignore
  87384. * Application error to support additional information when loading a file
  87385. */
  87386. export class LoadFileError extends Error {
  87387. /** defines the optional XHR request */
  87388. request?: XMLHttpRequest | undefined;
  87389. private static _setPrototypeOf;
  87390. /**
  87391. * Creates a new LoadFileError
  87392. * @param message defines the message of the error
  87393. * @param request defines the optional XHR request
  87394. */
  87395. constructor(message: string,
  87396. /** defines the optional XHR request */
  87397. request?: XMLHttpRequest | undefined);
  87398. }
  87399. /**
  87400. * Class used to define a retry strategy when error happens while loading assets
  87401. */
  87402. export class RetryStrategy {
  87403. /**
  87404. * Function used to defines an exponential back off strategy
  87405. * @param maxRetries defines the maximum number of retries (3 by default)
  87406. * @param baseInterval defines the interval between retries
  87407. * @returns the strategy function to use
  87408. */
  87409. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87410. }
  87411. /**
  87412. * File request interface
  87413. */
  87414. export interface IFileRequest {
  87415. /**
  87416. * Raised when the request is complete (success or error).
  87417. */
  87418. onCompleteObservable: Observable<IFileRequest>;
  87419. /**
  87420. * Aborts the request for a file.
  87421. */
  87422. abort: () => void;
  87423. }
  87424. /**
  87425. * Class containing a set of static utilities functions
  87426. */
  87427. export class Tools {
  87428. /**
  87429. * Gets or sets the base URL to use to load assets
  87430. */
  87431. static BaseUrl: string;
  87432. /**
  87433. * Enable/Disable Custom HTTP Request Headers globally.
  87434. * default = false
  87435. * @see CustomRequestHeaders
  87436. */
  87437. static UseCustomRequestHeaders: boolean;
  87438. /**
  87439. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87440. * i.e. when loading files, where the server/service expects an Authorization header.
  87441. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  87442. */
  87443. static CustomRequestHeaders: {
  87444. [key: string]: string;
  87445. };
  87446. /**
  87447. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87448. */
  87449. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87450. /**
  87451. * Default behaviour for cors in the application.
  87452. * It can be a string if the expected behavior is identical in the entire app.
  87453. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87454. */
  87455. static CorsBehavior: string | ((url: string | string[]) => string);
  87456. /**
  87457. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87458. * @ignorenaming
  87459. */
  87460. static UseFallbackTexture: boolean;
  87461. /**
  87462. * Use this object to register external classes like custom textures or material
  87463. * to allow the laoders to instantiate them
  87464. */
  87465. static RegisteredExternalClasses: {
  87466. [key: string]: Object;
  87467. };
  87468. /**
  87469. * Texture content used if a texture cannot loaded
  87470. * @ignorenaming
  87471. */
  87472. static fallbackTexture: string;
  87473. /**
  87474. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87475. * @param u defines the coordinate on X axis
  87476. * @param v defines the coordinate on Y axis
  87477. * @param width defines the width of the source data
  87478. * @param height defines the height of the source data
  87479. * @param pixels defines the source byte array
  87480. * @param color defines the output color
  87481. */
  87482. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87483. /**
  87484. * Interpolates between a and b via alpha
  87485. * @param a The lower value (returned when alpha = 0)
  87486. * @param b The upper value (returned when alpha = 1)
  87487. * @param alpha The interpolation-factor
  87488. * @return The mixed value
  87489. */
  87490. static Mix(a: number, b: number, alpha: number): number;
  87491. /**
  87492. * Tries to instantiate a new object from a given class name
  87493. * @param className defines the class name to instantiate
  87494. * @returns the new object or null if the system was not able to do the instantiation
  87495. */
  87496. static Instantiate(className: string): any;
  87497. /**
  87498. * Provides a slice function that will work even on IE
  87499. * @param data defines the array to slice
  87500. * @param start defines the start of the data (optional)
  87501. * @param end defines the end of the data (optional)
  87502. * @returns the new sliced array
  87503. */
  87504. static Slice<T>(data: T, start?: number, end?: number): T;
  87505. /**
  87506. * Polyfill for setImmediate
  87507. * @param action defines the action to execute after the current execution block
  87508. */
  87509. static SetImmediate(action: () => void): void;
  87510. /**
  87511. * Function indicating if a number is an exponent of 2
  87512. * @param value defines the value to test
  87513. * @returns true if the value is an exponent of 2
  87514. */
  87515. static IsExponentOfTwo(value: number): boolean;
  87516. private static _tmpFloatArray;
  87517. /**
  87518. * Returns the nearest 32-bit single precision float representation of a Number
  87519. * @param value A Number. If the parameter is of a different type, it will get converted
  87520. * to a number or to NaN if it cannot be converted
  87521. * @returns number
  87522. */
  87523. static FloatRound(value: number): number;
  87524. /**
  87525. * Find the next highest power of two.
  87526. * @param x Number to start search from.
  87527. * @return Next highest power of two.
  87528. */
  87529. static CeilingPOT(x: number): number;
  87530. /**
  87531. * Find the next lowest power of two.
  87532. * @param x Number to start search from.
  87533. * @return Next lowest power of two.
  87534. */
  87535. static FloorPOT(x: number): number;
  87536. /**
  87537. * Find the nearest power of two.
  87538. * @param x Number to start search from.
  87539. * @return Next nearest power of two.
  87540. */
  87541. static NearestPOT(x: number): number;
  87542. /**
  87543. * Get the closest exponent of two
  87544. * @param value defines the value to approximate
  87545. * @param max defines the maximum value to return
  87546. * @param mode defines how to define the closest value
  87547. * @returns closest exponent of two of the given value
  87548. */
  87549. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87550. /**
  87551. * Extracts the filename from a path
  87552. * @param path defines the path to use
  87553. * @returns the filename
  87554. */
  87555. static GetFilename(path: string): string;
  87556. /**
  87557. * Extracts the "folder" part of a path (everything before the filename).
  87558. * @param uri The URI to extract the info from
  87559. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87560. * @returns The "folder" part of the path
  87561. */
  87562. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87563. /**
  87564. * Extracts text content from a DOM element hierarchy
  87565. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87566. */
  87567. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87568. /**
  87569. * Convert an angle in radians to degrees
  87570. * @param angle defines the angle to convert
  87571. * @returns the angle in degrees
  87572. */
  87573. static ToDegrees(angle: number): number;
  87574. /**
  87575. * Convert an angle in degrees to radians
  87576. * @param angle defines the angle to convert
  87577. * @returns the angle in radians
  87578. */
  87579. static ToRadians(angle: number): number;
  87580. /**
  87581. * Encode a buffer to a base64 string
  87582. * @param buffer defines the buffer to encode
  87583. * @returns the encoded string
  87584. */
  87585. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87586. /**
  87587. * Extracts minimum and maximum values from a list of indexed positions
  87588. * @param positions defines the positions to use
  87589. * @param indices defines the indices to the positions
  87590. * @param indexStart defines the start index
  87591. * @param indexCount defines the end index
  87592. * @param bias defines bias value to add to the result
  87593. * @return minimum and maximum values
  87594. */
  87595. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87596. minimum: Vector3;
  87597. maximum: Vector3;
  87598. };
  87599. /**
  87600. * Extracts minimum and maximum values from a list of positions
  87601. * @param positions defines the positions to use
  87602. * @param start defines the start index in the positions array
  87603. * @param count defines the number of positions to handle
  87604. * @param bias defines bias value to add to the result
  87605. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87606. * @return minimum and maximum values
  87607. */
  87608. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87609. minimum: Vector3;
  87610. maximum: Vector3;
  87611. };
  87612. /**
  87613. * Returns an array if obj is not an array
  87614. * @param obj defines the object to evaluate as an array
  87615. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87616. * @returns either obj directly if obj is an array or a new array containing obj
  87617. */
  87618. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87619. /**
  87620. * Gets the pointer prefix to use
  87621. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87622. */
  87623. static GetPointerPrefix(): string;
  87624. /**
  87625. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87626. * @param func - the function to be called
  87627. * @param requester - the object that will request the next frame. Falls back to window.
  87628. * @returns frame number
  87629. */
  87630. static QueueNewFrame(func: () => void, requester?: any): number;
  87631. /**
  87632. * Ask the browser to promote the current element to fullscreen rendering mode
  87633. * @param element defines the DOM element to promote
  87634. */
  87635. static RequestFullscreen(element: HTMLElement): void;
  87636. /**
  87637. * Asks the browser to exit fullscreen mode
  87638. */
  87639. static ExitFullscreen(): void;
  87640. /**
  87641. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87642. * @param url define the url we are trying
  87643. * @param element define the dom element where to configure the cors policy
  87644. */
  87645. static SetCorsBehavior(url: string | string[], element: {
  87646. crossOrigin: string | null;
  87647. }): void;
  87648. /**
  87649. * Removes unwanted characters from an url
  87650. * @param url defines the url to clean
  87651. * @returns the cleaned url
  87652. */
  87653. static CleanUrl(url: string): string;
  87654. /**
  87655. * Gets or sets a function used to pre-process url before using them to load assets
  87656. */
  87657. static PreprocessUrl: (url: string) => string;
  87658. /**
  87659. * Loads an image as an HTMLImageElement.
  87660. * @param input url string, ArrayBuffer, or Blob to load
  87661. * @param onLoad callback called when the image successfully loads
  87662. * @param onError callback called when the image fails to load
  87663. * @param offlineProvider offline provider for caching
  87664. * @returns the HTMLImageElement of the loaded image
  87665. */
  87666. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87667. /**
  87668. * Loads a file
  87669. * @param url url string, ArrayBuffer, or Blob to load
  87670. * @param onSuccess callback called when the file successfully loads
  87671. * @param onProgress callback called while file is loading (if the server supports this mode)
  87672. * @param offlineProvider defines the offline provider for caching
  87673. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87674. * @param onError callback called when the file fails to load
  87675. * @returns a file request object
  87676. */
  87677. 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;
  87678. /**
  87679. * Load a script (identified by an url). When the url returns, the
  87680. * content of this file is added into a new script element, attached to the DOM (body element)
  87681. * @param scriptUrl defines the url of the script to laod
  87682. * @param onSuccess defines the callback called when the script is loaded
  87683. * @param onError defines the callback to call if an error occurs
  87684. */
  87685. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87686. /**
  87687. * Loads a file from a blob
  87688. * @param fileToLoad defines the blob to use
  87689. * @param callback defines the callback to call when data is loaded
  87690. * @param progressCallback defines the callback to call during loading process
  87691. * @returns a file request object
  87692. */
  87693. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87694. /**
  87695. * Loads a file
  87696. * @param fileToLoad defines the file to load
  87697. * @param callback defines the callback to call when data is loaded
  87698. * @param progressCallBack defines the callback to call during loading process
  87699. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87700. * @returns a file request object
  87701. */
  87702. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87703. /**
  87704. * Creates a data url from a given string content
  87705. * @param content defines the content to convert
  87706. * @returns the new data url link
  87707. */
  87708. static FileAsURL(content: string): string;
  87709. /**
  87710. * Format the given number to a specific decimal format
  87711. * @param value defines the number to format
  87712. * @param decimals defines the number of decimals to use
  87713. * @returns the formatted string
  87714. */
  87715. static Format(value: number, decimals?: number): string;
  87716. /**
  87717. * Checks if a given vector is inside a specific range
  87718. * @param v defines the vector to test
  87719. * @param min defines the minimum range
  87720. * @param max defines the maximum range
  87721. */
  87722. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  87723. /**
  87724. * Tries to copy an object by duplicating every property
  87725. * @param source defines the source object
  87726. * @param destination defines the target object
  87727. * @param doNotCopyList defines a list of properties to avoid
  87728. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  87729. */
  87730. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  87731. /**
  87732. * Gets a boolean indicating if the given object has no own property
  87733. * @param obj defines the object to test
  87734. * @returns true if object has no own property
  87735. */
  87736. static IsEmpty(obj: any): boolean;
  87737. /**
  87738. * Function used to register events at window level
  87739. * @param events defines the events to register
  87740. */
  87741. static RegisterTopRootEvents(events: {
  87742. name: string;
  87743. handler: Nullable<(e: FocusEvent) => any>;
  87744. }[]): void;
  87745. /**
  87746. * Function used to unregister events from window level
  87747. * @param events defines the events to unregister
  87748. */
  87749. static UnregisterTopRootEvents(events: {
  87750. name: string;
  87751. handler: Nullable<(e: FocusEvent) => any>;
  87752. }[]): void;
  87753. /**
  87754. * @ignore
  87755. */
  87756. static _ScreenshotCanvas: HTMLCanvasElement;
  87757. /**
  87758. * Dumps the current bound framebuffer
  87759. * @param width defines the rendering width
  87760. * @param height defines the rendering height
  87761. * @param engine defines the hosting engine
  87762. * @param successCallback defines the callback triggered once the data are available
  87763. * @param mimeType defines the mime type of the result
  87764. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  87765. */
  87766. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87767. /**
  87768. * Converts the canvas data to blob.
  87769. * This acts as a polyfill for browsers not supporting the to blob function.
  87770. * @param canvas Defines the canvas to extract the data from
  87771. * @param successCallback Defines the callback triggered once the data are available
  87772. * @param mimeType Defines the mime type of the result
  87773. */
  87774. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  87775. /**
  87776. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  87777. * @param successCallback defines the callback triggered once the data are available
  87778. * @param mimeType defines the mime type of the result
  87779. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  87780. */
  87781. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87782. /**
  87783. * Downloads a blob in the browser
  87784. * @param blob defines the blob to download
  87785. * @param fileName defines the name of the downloaded file
  87786. */
  87787. static Download(blob: Blob, fileName: string): void;
  87788. /**
  87789. * Captures a screenshot of the current rendering
  87790. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87791. * @param engine defines the rendering engine
  87792. * @param camera defines the source camera
  87793. * @param size This parameter can be set to a single number or to an object with the
  87794. * following (optional) properties: precision, width, height. If a single number is passed,
  87795. * it will be used for both width and height. If an object is passed, the screenshot size
  87796. * will be derived from the parameters. The precision property is a multiplier allowing
  87797. * rendering at a higher or lower resolution
  87798. * @param successCallback defines the callback receives a single parameter which contains the
  87799. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87800. * src parameter of an <img> to display it
  87801. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  87802. * Check your browser for supported MIME types
  87803. */
  87804. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  87805. /**
  87806. * Generates an image screenshot from the specified camera.
  87807. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87808. * @param engine The engine to use for rendering
  87809. * @param camera The camera to use for rendering
  87810. * @param size This parameter can be set to a single number or to an object with the
  87811. * following (optional) properties: precision, width, height. If a single number is passed,
  87812. * it will be used for both width and height. If an object is passed, the screenshot size
  87813. * will be derived from the parameters. The precision property is a multiplier allowing
  87814. * rendering at a higher or lower resolution
  87815. * @param successCallback The callback receives a single parameter which contains the
  87816. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87817. * src parameter of an <img> to display it
  87818. * @param mimeType The MIME type of the screenshot image (default: image/png).
  87819. * Check your browser for supported MIME types
  87820. * @param samples Texture samples (default: 1)
  87821. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  87822. * @param fileName A name for for the downloaded file.
  87823. */
  87824. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  87825. /**
  87826. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87827. * Be aware Math.random() could cause collisions, but:
  87828. * "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"
  87829. * @returns a pseudo random id
  87830. */
  87831. static RandomId(): string;
  87832. /**
  87833. * Test if the given uri is a base64 string
  87834. * @param uri The uri to test
  87835. * @return True if the uri is a base64 string or false otherwise
  87836. */
  87837. static IsBase64(uri: string): boolean;
  87838. /**
  87839. * Decode the given base64 uri.
  87840. * @param uri The uri to decode
  87841. * @return The decoded base64 data.
  87842. */
  87843. static DecodeBase64(uri: string): ArrayBuffer;
  87844. /**
  87845. * No log
  87846. */
  87847. static readonly NoneLogLevel: number;
  87848. /**
  87849. * Only message logs
  87850. */
  87851. static readonly MessageLogLevel: number;
  87852. /**
  87853. * Only warning logs
  87854. */
  87855. static readonly WarningLogLevel: number;
  87856. /**
  87857. * Only error logs
  87858. */
  87859. static readonly ErrorLogLevel: number;
  87860. /**
  87861. * All logs
  87862. */
  87863. static readonly AllLogLevel: number;
  87864. /**
  87865. * Gets a value indicating the number of loading errors
  87866. * @ignorenaming
  87867. */
  87868. static readonly errorsCount: number;
  87869. /**
  87870. * Callback called when a new log is added
  87871. */
  87872. static OnNewCacheEntry: (entry: string) => void;
  87873. /**
  87874. * Log a message to the console
  87875. * @param message defines the message to log
  87876. */
  87877. static Log(message: string): void;
  87878. /**
  87879. * Write a warning message to the console
  87880. * @param message defines the message to log
  87881. */
  87882. static Warn(message: string): void;
  87883. /**
  87884. * Write an error message to the console
  87885. * @param message defines the message to log
  87886. */
  87887. static Error(message: string): void;
  87888. /**
  87889. * Gets current log cache (list of logs)
  87890. */
  87891. static readonly LogCache: string;
  87892. /**
  87893. * Clears the log cache
  87894. */
  87895. static ClearLogCache(): void;
  87896. /**
  87897. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  87898. */
  87899. static LogLevels: number;
  87900. /**
  87901. * Checks if the loaded document was accessed via `file:`-Protocol.
  87902. * @returns boolean
  87903. */
  87904. static IsFileURL(): boolean;
  87905. /**
  87906. * Checks if the window object exists
  87907. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  87908. */
  87909. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  87910. /**
  87911. * No performance log
  87912. */
  87913. static readonly PerformanceNoneLogLevel: number;
  87914. /**
  87915. * Use user marks to log performance
  87916. */
  87917. static readonly PerformanceUserMarkLogLevel: number;
  87918. /**
  87919. * Log performance to the console
  87920. */
  87921. static readonly PerformanceConsoleLogLevel: number;
  87922. private static _performance;
  87923. /**
  87924. * Sets the current performance log level
  87925. */
  87926. static PerformanceLogLevel: number;
  87927. private static _StartPerformanceCounterDisabled;
  87928. private static _EndPerformanceCounterDisabled;
  87929. private static _StartUserMark;
  87930. private static _EndUserMark;
  87931. private static _StartPerformanceConsole;
  87932. private static _EndPerformanceConsole;
  87933. /**
  87934. * Injects the @see CustomRequestHeaders into the given request
  87935. * @param request the request that should be used for injection
  87936. */
  87937. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  87938. /**
  87939. * Starts a performance counter
  87940. */
  87941. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87942. /**
  87943. * Ends a specific performance coutner
  87944. */
  87945. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87946. /**
  87947. * Gets either window.performance.now() if supported or Date.now() else
  87948. */
  87949. static readonly Now: number;
  87950. /**
  87951. * This method will return the name of the class used to create the instance of the given object.
  87952. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  87953. * @param object the object to get the class name from
  87954. * @param isType defines if the object is actually a type
  87955. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  87956. */
  87957. static GetClassName(object: any, isType?: boolean): string;
  87958. /**
  87959. * Gets the first element of an array satisfying a given predicate
  87960. * @param array defines the array to browse
  87961. * @param predicate defines the predicate to use
  87962. * @returns null if not found or the element
  87963. */
  87964. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  87965. /**
  87966. * This method will return the name of the full name of the class, including its owning module (if any).
  87967. * 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).
  87968. * @param object the object to get the class name from
  87969. * @param isType defines if the object is actually a type
  87970. * @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.
  87971. * @ignorenaming
  87972. */
  87973. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  87974. /**
  87975. * Returns a promise that resolves after the given amount of time.
  87976. * @param delay Number of milliseconds to delay
  87977. * @returns Promise that resolves after the given amount of time
  87978. */
  87979. static DelayAsync(delay: number): Promise<void>;
  87980. /**
  87981. * Gets the current gradient from an array of IValueGradient
  87982. * @param ratio defines the current ratio to get
  87983. * @param gradients defines the array of IValueGradient
  87984. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87985. */
  87986. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87987. }
  87988. /**
  87989. * This class is used to track a performance counter which is number based.
  87990. * The user has access to many properties which give statistics of different nature.
  87991. *
  87992. * The implementer can track two kinds of Performance Counter: time and count.
  87993. * 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.
  87994. * 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.
  87995. */
  87996. export class PerfCounter {
  87997. /**
  87998. * Gets or sets a global boolean to turn on and off all the counters
  87999. */
  88000. static Enabled: boolean;
  88001. /**
  88002. * Returns the smallest value ever
  88003. */
  88004. readonly min: number;
  88005. /**
  88006. * Returns the biggest value ever
  88007. */
  88008. readonly max: number;
  88009. /**
  88010. * Returns the average value since the performance counter is running
  88011. */
  88012. readonly average: number;
  88013. /**
  88014. * Returns the average value of the last second the counter was monitored
  88015. */
  88016. readonly lastSecAverage: number;
  88017. /**
  88018. * Returns the current value
  88019. */
  88020. readonly current: number;
  88021. /**
  88022. * Gets the accumulated total
  88023. */
  88024. readonly total: number;
  88025. /**
  88026. * Gets the total value count
  88027. */
  88028. readonly count: number;
  88029. /**
  88030. * Creates a new counter
  88031. */
  88032. constructor();
  88033. /**
  88034. * Call this method to start monitoring a new frame.
  88035. * 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.
  88036. */
  88037. fetchNewFrame(): void;
  88038. /**
  88039. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88040. * @param newCount the count value to add to the monitored count
  88041. * @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.
  88042. */
  88043. addCount(newCount: number, fetchResult: boolean): void;
  88044. /**
  88045. * Start monitoring this performance counter
  88046. */
  88047. beginMonitoring(): void;
  88048. /**
  88049. * Compute the time lapsed since the previous beginMonitoring() call.
  88050. * @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
  88051. */
  88052. endMonitoring(newFrame?: boolean): void;
  88053. private _fetchResult;
  88054. private _startMonitoringTime;
  88055. private _min;
  88056. private _max;
  88057. private _average;
  88058. private _current;
  88059. private _totalValueCount;
  88060. private _totalAccumulated;
  88061. private _lastSecAverage;
  88062. private _lastSecAccumulated;
  88063. private _lastSecTime;
  88064. private _lastSecValueCount;
  88065. }
  88066. /**
  88067. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88068. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88069. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88070. * @param name The name of the class, case should be preserved
  88071. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88072. */
  88073. export function className(name: string, module?: string): (target: Object) => void;
  88074. /**
  88075. * An implementation of a loop for asynchronous functions.
  88076. */
  88077. export class AsyncLoop {
  88078. /**
  88079. * Defines the number of iterations for the loop
  88080. */
  88081. iterations: number;
  88082. /**
  88083. * Defines the current index of the loop.
  88084. */
  88085. index: number;
  88086. private _done;
  88087. private _fn;
  88088. private _successCallback;
  88089. /**
  88090. * Constructor.
  88091. * @param iterations the number of iterations.
  88092. * @param func the function to run each iteration
  88093. * @param successCallback the callback that will be called upon succesful execution
  88094. * @param offset starting offset.
  88095. */
  88096. constructor(
  88097. /**
  88098. * Defines the number of iterations for the loop
  88099. */
  88100. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88101. /**
  88102. * Execute the next iteration. Must be called after the last iteration was finished.
  88103. */
  88104. executeNext(): void;
  88105. /**
  88106. * Break the loop and run the success callback.
  88107. */
  88108. breakLoop(): void;
  88109. /**
  88110. * Create and run an async loop.
  88111. * @param iterations the number of iterations.
  88112. * @param fn the function to run each iteration
  88113. * @param successCallback the callback that will be called upon succesful execution
  88114. * @param offset starting offset.
  88115. * @returns the created async loop object
  88116. */
  88117. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88118. /**
  88119. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88120. * @param iterations total number of iterations
  88121. * @param syncedIterations number of synchronous iterations in each async iteration.
  88122. * @param fn the function to call each iteration.
  88123. * @param callback a success call back that will be called when iterating stops.
  88124. * @param breakFunction a break condition (optional)
  88125. * @param timeout timeout settings for the setTimeout function. default - 0.
  88126. * @returns the created async loop object
  88127. */
  88128. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88129. }
  88130. }
  88131. declare module BABYLON {
  88132. /** @hidden */
  88133. export interface ICollisionCoordinator {
  88134. createCollider(): Collider;
  88135. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88136. init(scene: Scene): void;
  88137. }
  88138. /** @hidden */
  88139. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88140. private _scene;
  88141. private _scaledPosition;
  88142. private _scaledVelocity;
  88143. private _finalPosition;
  88144. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88145. createCollider(): Collider;
  88146. init(scene: Scene): void;
  88147. private _collideWithWorld;
  88148. }
  88149. }
  88150. declare module BABYLON {
  88151. /**
  88152. * This class defines the direct association between an animation and a target
  88153. */
  88154. export class TargetedAnimation {
  88155. /**
  88156. * Animation to perform
  88157. */
  88158. animation: Animation;
  88159. /**
  88160. * Target to animate
  88161. */
  88162. target: any;
  88163. }
  88164. /**
  88165. * Use this class to create coordinated animations on multiple targets
  88166. */
  88167. export class AnimationGroup implements IDisposable {
  88168. /** The name of the animation group */
  88169. name: string;
  88170. private _scene;
  88171. private _targetedAnimations;
  88172. private _animatables;
  88173. private _from;
  88174. private _to;
  88175. private _isStarted;
  88176. private _isPaused;
  88177. private _speedRatio;
  88178. /**
  88179. * Gets or sets the unique id of the node
  88180. */
  88181. uniqueId: number;
  88182. /**
  88183. * This observable will notify when one animation have ended
  88184. */
  88185. onAnimationEndObservable: Observable<TargetedAnimation>;
  88186. /**
  88187. * Observer raised when one animation loops
  88188. */
  88189. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88190. /**
  88191. * This observable will notify when all animations have ended.
  88192. */
  88193. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88194. /**
  88195. * This observable will notify when all animations have paused.
  88196. */
  88197. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88198. /**
  88199. * This observable will notify when all animations are playing.
  88200. */
  88201. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88202. /**
  88203. * Gets the first frame
  88204. */
  88205. readonly from: number;
  88206. /**
  88207. * Gets the last frame
  88208. */
  88209. readonly to: number;
  88210. /**
  88211. * Define if the animations are started
  88212. */
  88213. readonly isStarted: boolean;
  88214. /**
  88215. * Gets a value indicating that the current group is playing
  88216. */
  88217. readonly isPlaying: boolean;
  88218. /**
  88219. * Gets or sets the speed ratio to use for all animations
  88220. */
  88221. /**
  88222. * Gets or sets the speed ratio to use for all animations
  88223. */
  88224. speedRatio: number;
  88225. /**
  88226. * Gets the targeted animations for this animation group
  88227. */
  88228. readonly targetedAnimations: Array<TargetedAnimation>;
  88229. /**
  88230. * returning the list of animatables controlled by this animation group.
  88231. */
  88232. readonly animatables: Array<Animatable>;
  88233. /**
  88234. * Instantiates a new Animation Group.
  88235. * This helps managing several animations at once.
  88236. * @see http://doc.babylonjs.com/how_to/group
  88237. * @param name Defines the name of the group
  88238. * @param scene Defines the scene the group belongs to
  88239. */
  88240. constructor(
  88241. /** The name of the animation group */
  88242. name: string, scene?: Nullable<Scene>);
  88243. /**
  88244. * Add an animation (with its target) in the group
  88245. * @param animation defines the animation we want to add
  88246. * @param target defines the target of the animation
  88247. * @returns the TargetedAnimation object
  88248. */
  88249. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88250. /**
  88251. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88252. * It can add constant keys at begin or end
  88253. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88254. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88255. * @returns the animation group
  88256. */
  88257. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88258. /**
  88259. * Start all animations on given targets
  88260. * @param loop defines if animations must loop
  88261. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88262. * @param from defines the from key (optional)
  88263. * @param to defines the to key (optional)
  88264. * @returns the current animation group
  88265. */
  88266. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88267. /**
  88268. * Pause all animations
  88269. * @returns the animation group
  88270. */
  88271. pause(): AnimationGroup;
  88272. /**
  88273. * Play all animations to initial state
  88274. * This function will start() the animations if they were not started or will restart() them if they were paused
  88275. * @param loop defines if animations must loop
  88276. * @returns the animation group
  88277. */
  88278. play(loop?: boolean): AnimationGroup;
  88279. /**
  88280. * Reset all animations to initial state
  88281. * @returns the animation group
  88282. */
  88283. reset(): AnimationGroup;
  88284. /**
  88285. * Restart animations from key 0
  88286. * @returns the animation group
  88287. */
  88288. restart(): AnimationGroup;
  88289. /**
  88290. * Stop all animations
  88291. * @returns the animation group
  88292. */
  88293. stop(): AnimationGroup;
  88294. /**
  88295. * Set animation weight for all animatables
  88296. * @param weight defines the weight to use
  88297. * @return the animationGroup
  88298. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88299. */
  88300. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88301. /**
  88302. * Synchronize and normalize all animatables with a source animatable
  88303. * @param root defines the root animatable to synchronize with
  88304. * @return the animationGroup
  88305. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88306. */
  88307. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88308. /**
  88309. * Goes to a specific frame in this animation group
  88310. * @param frame the frame number to go to
  88311. * @return the animationGroup
  88312. */
  88313. goToFrame(frame: number): AnimationGroup;
  88314. /**
  88315. * Dispose all associated resources
  88316. */
  88317. dispose(): void;
  88318. private _checkAnimationGroupEnded;
  88319. /**
  88320. * Clone the current animation group and returns a copy
  88321. * @param newName defines the name of the new group
  88322. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88323. * @returns the new aniamtion group
  88324. */
  88325. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88326. /**
  88327. * Returns a new AnimationGroup object parsed from the source provided.
  88328. * @param parsedAnimationGroup defines the source
  88329. * @param scene defines the scene that will receive the animationGroup
  88330. * @returns a new AnimationGroup
  88331. */
  88332. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88333. /**
  88334. * Returns the string "AnimationGroup"
  88335. * @returns "AnimationGroup"
  88336. */
  88337. getClassName(): string;
  88338. /**
  88339. * Creates a detailled string about the object
  88340. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88341. * @returns a string representing the object
  88342. */
  88343. toString(fullDetails?: boolean): string;
  88344. }
  88345. }
  88346. declare module BABYLON {
  88347. /**
  88348. * Define an interface for all classes that will hold resources
  88349. */
  88350. export interface IDisposable {
  88351. /**
  88352. * Releases all held resources
  88353. */
  88354. dispose(): void;
  88355. }
  88356. /** Interface defining initialization parameters for Scene class */
  88357. export interface SceneOptions {
  88358. /**
  88359. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88360. * It will improve performance when the number of geometries becomes important.
  88361. */
  88362. useGeometryUniqueIdsMap?: boolean;
  88363. /**
  88364. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88365. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88366. */
  88367. useMaterialMeshMap?: boolean;
  88368. /**
  88369. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88370. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88371. */
  88372. useClonedMeshhMap?: boolean;
  88373. }
  88374. /**
  88375. * Represents a scene to be rendered by the engine.
  88376. * @see http://doc.babylonjs.com/features/scene
  88377. */
  88378. export class Scene extends AbstractScene implements IAnimatable {
  88379. private static _uniqueIdCounter;
  88380. /** The fog is deactivated */
  88381. static readonly FOGMODE_NONE: number;
  88382. /** The fog density is following an exponential function */
  88383. static readonly FOGMODE_EXP: number;
  88384. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88385. static readonly FOGMODE_EXP2: number;
  88386. /** The fog density is following a linear function. */
  88387. static readonly FOGMODE_LINEAR: number;
  88388. /**
  88389. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88390. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88391. */
  88392. static MinDeltaTime: number;
  88393. /**
  88394. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88395. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88396. */
  88397. static MaxDeltaTime: number;
  88398. /**
  88399. * Factory used to create the default material.
  88400. * @param name The name of the material to create
  88401. * @param scene The scene to create the material for
  88402. * @returns The default material
  88403. */
  88404. static DefaultMaterialFactory(scene: Scene): Material;
  88405. /**
  88406. * Factory used to create the a collision coordinator.
  88407. * @returns The collision coordinator
  88408. */
  88409. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88410. /** @hidden */
  88411. readonly _isScene: boolean;
  88412. /**
  88413. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88414. */
  88415. autoClear: boolean;
  88416. /**
  88417. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88418. */
  88419. autoClearDepthAndStencil: boolean;
  88420. /**
  88421. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88422. */
  88423. clearColor: Color4;
  88424. /**
  88425. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88426. */
  88427. ambientColor: Color3;
  88428. /** @hidden */
  88429. _environmentBRDFTexture: BaseTexture;
  88430. /** @hidden */
  88431. protected _environmentTexture: Nullable<BaseTexture>;
  88432. /**
  88433. * Texture used in all pbr material as the reflection texture.
  88434. * As in the majority of the scene they are the same (exception for multi room and so on),
  88435. * this is easier to reference from here than from all the materials.
  88436. */
  88437. /**
  88438. * Texture used in all pbr material as the reflection texture.
  88439. * As in the majority of the scene they are the same (exception for multi room and so on),
  88440. * this is easier to set here than in all the materials.
  88441. */
  88442. environmentTexture: Nullable<BaseTexture>;
  88443. /** @hidden */
  88444. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88445. /**
  88446. * Default image processing configuration used either in the rendering
  88447. * Forward main pass or through the imageProcessingPostProcess if present.
  88448. * As in the majority of the scene they are the same (exception for multi camera),
  88449. * this is easier to reference from here than from all the materials and post process.
  88450. *
  88451. * No setter as we it is a shared configuration, you can set the values instead.
  88452. */
  88453. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88454. private _forceWireframe;
  88455. /**
  88456. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88457. */
  88458. forceWireframe: boolean;
  88459. private _forcePointsCloud;
  88460. /**
  88461. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88462. */
  88463. forcePointsCloud: boolean;
  88464. /**
  88465. * Gets or sets the active clipplane 1
  88466. */
  88467. clipPlane: Nullable<Plane>;
  88468. /**
  88469. * Gets or sets the active clipplane 2
  88470. */
  88471. clipPlane2: Nullable<Plane>;
  88472. /**
  88473. * Gets or sets the active clipplane 3
  88474. */
  88475. clipPlane3: Nullable<Plane>;
  88476. /**
  88477. * Gets or sets the active clipplane 4
  88478. */
  88479. clipPlane4: Nullable<Plane>;
  88480. /**
  88481. * Gets or sets a boolean indicating if animations are enabled
  88482. */
  88483. animationsEnabled: boolean;
  88484. private _animationPropertiesOverride;
  88485. /**
  88486. * Gets or sets the animation properties override
  88487. */
  88488. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88489. /**
  88490. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88491. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88492. */
  88493. useConstantAnimationDeltaTime: boolean;
  88494. /**
  88495. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88496. * Please note that it requires to run a ray cast through the scene on every frame
  88497. */
  88498. constantlyUpdateMeshUnderPointer: boolean;
  88499. /**
  88500. * Defines the HTML cursor to use when hovering over interactive elements
  88501. */
  88502. hoverCursor: string;
  88503. /**
  88504. * Defines the HTML default cursor to use (empty by default)
  88505. */
  88506. defaultCursor: string;
  88507. /**
  88508. * This is used to call preventDefault() on pointer down
  88509. * in order to block unwanted artifacts like system double clicks
  88510. */
  88511. preventDefaultOnPointerDown: boolean;
  88512. /**
  88513. * This is used to call preventDefault() on pointer up
  88514. * in order to block unwanted artifacts like system double clicks
  88515. */
  88516. preventDefaultOnPointerUp: boolean;
  88517. /**
  88518. * Gets or sets user defined metadata
  88519. */
  88520. metadata: any;
  88521. /**
  88522. * For internal use only. Please do not use.
  88523. */
  88524. reservedDataStore: any;
  88525. /**
  88526. * Gets the name of the plugin used to load this scene (null by default)
  88527. */
  88528. loadingPluginName: string;
  88529. /**
  88530. * Use this array to add regular expressions used to disable offline support for specific urls
  88531. */
  88532. disableOfflineSupportExceptionRules: RegExp[];
  88533. /**
  88534. * An event triggered when the scene is disposed.
  88535. */
  88536. onDisposeObservable: Observable<Scene>;
  88537. private _onDisposeObserver;
  88538. /** Sets a function to be executed when this scene is disposed. */
  88539. onDispose: () => void;
  88540. /**
  88541. * An event triggered before rendering the scene (right after animations and physics)
  88542. */
  88543. onBeforeRenderObservable: Observable<Scene>;
  88544. private _onBeforeRenderObserver;
  88545. /** Sets a function to be executed before rendering this scene */
  88546. beforeRender: Nullable<() => void>;
  88547. /**
  88548. * An event triggered after rendering the scene
  88549. */
  88550. onAfterRenderObservable: Observable<Scene>;
  88551. private _onAfterRenderObserver;
  88552. /** Sets a function to be executed after rendering this scene */
  88553. afterRender: Nullable<() => void>;
  88554. /**
  88555. * An event triggered before animating the scene
  88556. */
  88557. onBeforeAnimationsObservable: Observable<Scene>;
  88558. /**
  88559. * An event triggered after animations processing
  88560. */
  88561. onAfterAnimationsObservable: Observable<Scene>;
  88562. /**
  88563. * An event triggered before draw calls are ready to be sent
  88564. */
  88565. onBeforeDrawPhaseObservable: Observable<Scene>;
  88566. /**
  88567. * An event triggered after draw calls have been sent
  88568. */
  88569. onAfterDrawPhaseObservable: Observable<Scene>;
  88570. /**
  88571. * An event triggered when the scene is ready
  88572. */
  88573. onReadyObservable: Observable<Scene>;
  88574. /**
  88575. * An event triggered before rendering a camera
  88576. */
  88577. onBeforeCameraRenderObservable: Observable<Camera>;
  88578. private _onBeforeCameraRenderObserver;
  88579. /** Sets a function to be executed before rendering a camera*/
  88580. beforeCameraRender: () => void;
  88581. /**
  88582. * An event triggered after rendering a camera
  88583. */
  88584. onAfterCameraRenderObservable: Observable<Camera>;
  88585. private _onAfterCameraRenderObserver;
  88586. /** Sets a function to be executed after rendering a camera*/
  88587. afterCameraRender: () => void;
  88588. /**
  88589. * An event triggered when active meshes evaluation is about to start
  88590. */
  88591. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88592. /**
  88593. * An event triggered when active meshes evaluation is done
  88594. */
  88595. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88596. /**
  88597. * An event triggered when particles rendering is about to start
  88598. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88599. */
  88600. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88601. /**
  88602. * An event triggered when particles rendering is done
  88603. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88604. */
  88605. onAfterParticlesRenderingObservable: Observable<Scene>;
  88606. /**
  88607. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88608. */
  88609. onDataLoadedObservable: Observable<Scene>;
  88610. /**
  88611. * An event triggered when a camera is created
  88612. */
  88613. onNewCameraAddedObservable: Observable<Camera>;
  88614. /**
  88615. * An event triggered when a camera is removed
  88616. */
  88617. onCameraRemovedObservable: Observable<Camera>;
  88618. /**
  88619. * An event triggered when a light is created
  88620. */
  88621. onNewLightAddedObservable: Observable<Light>;
  88622. /**
  88623. * An event triggered when a light is removed
  88624. */
  88625. onLightRemovedObservable: Observable<Light>;
  88626. /**
  88627. * An event triggered when a geometry is created
  88628. */
  88629. onNewGeometryAddedObservable: Observable<Geometry>;
  88630. /**
  88631. * An event triggered when a geometry is removed
  88632. */
  88633. onGeometryRemovedObservable: Observable<Geometry>;
  88634. /**
  88635. * An event triggered when a transform node is created
  88636. */
  88637. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88638. /**
  88639. * An event triggered when a transform node is removed
  88640. */
  88641. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88642. /**
  88643. * An event triggered when a mesh is created
  88644. */
  88645. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88646. /**
  88647. * An event triggered when a mesh is removed
  88648. */
  88649. onMeshRemovedObservable: Observable<AbstractMesh>;
  88650. /**
  88651. * An event triggered when a material is created
  88652. */
  88653. onNewMaterialAddedObservable: Observable<Material>;
  88654. /**
  88655. * An event triggered when a material is removed
  88656. */
  88657. onMaterialRemovedObservable: Observable<Material>;
  88658. /**
  88659. * An event triggered when a texture is created
  88660. */
  88661. onNewTextureAddedObservable: Observable<BaseTexture>;
  88662. /**
  88663. * An event triggered when a texture is removed
  88664. */
  88665. onTextureRemovedObservable: Observable<BaseTexture>;
  88666. /**
  88667. * An event triggered when render targets are about to be rendered
  88668. * Can happen multiple times per frame.
  88669. */
  88670. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88671. /**
  88672. * An event triggered when render targets were rendered.
  88673. * Can happen multiple times per frame.
  88674. */
  88675. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88676. /**
  88677. * An event triggered before calculating deterministic simulation step
  88678. */
  88679. onBeforeStepObservable: Observable<Scene>;
  88680. /**
  88681. * An event triggered after calculating deterministic simulation step
  88682. */
  88683. onAfterStepObservable: Observable<Scene>;
  88684. /**
  88685. * An event triggered when the activeCamera property is updated
  88686. */
  88687. onActiveCameraChanged: Observable<Scene>;
  88688. /**
  88689. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88690. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88691. * 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)
  88692. */
  88693. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88694. /**
  88695. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88696. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88697. * 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)
  88698. */
  88699. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88700. /**
  88701. * This Observable will when a mesh has been imported into the scene.
  88702. */
  88703. onMeshImportedObservable: Observable<AbstractMesh>;
  88704. /**
  88705. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  88706. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  88707. */
  88708. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  88709. /** @hidden */
  88710. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  88711. /**
  88712. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88713. */
  88714. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88715. /**
  88716. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88717. */
  88718. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88719. /**
  88720. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  88721. */
  88722. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  88723. private _onPointerMove;
  88724. private _onPointerDown;
  88725. private _onPointerUp;
  88726. /** Callback called when a pointer move is detected */
  88727. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88728. /** Callback called when a pointer down is detected */
  88729. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88730. /** Callback called when a pointer up is detected */
  88731. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  88732. /** Callback called when a pointer pick is detected */
  88733. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  88734. /**
  88735. * 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).
  88736. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  88737. */
  88738. onPrePointerObservable: Observable<PointerInfoPre>;
  88739. /**
  88740. * Observable event triggered each time an input event is received from the rendering canvas
  88741. */
  88742. onPointerObservable: Observable<PointerInfo>;
  88743. /**
  88744. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  88745. */
  88746. readonly unTranslatedPointer: Vector2;
  88747. /** The distance in pixel that you have to move to prevent some events */
  88748. static DragMovementThreshold: number;
  88749. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  88750. static LongPressDelay: number;
  88751. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  88752. static DoubleClickDelay: number;
  88753. /** If you need to check double click without raising a single click at first click, enable this flag */
  88754. static ExclusiveDoubleClickMode: boolean;
  88755. private _initClickEvent;
  88756. private _initActionManager;
  88757. private _delayedSimpleClick;
  88758. private _delayedSimpleClickTimeout;
  88759. private _previousDelayedSimpleClickTimeout;
  88760. private _meshPickProceed;
  88761. private _previousButtonPressed;
  88762. private _currentPickResult;
  88763. private _previousPickResult;
  88764. private _totalPointersPressed;
  88765. private _doubleClickOccured;
  88766. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  88767. cameraToUseForPointers: Nullable<Camera>;
  88768. private _pointerX;
  88769. private _pointerY;
  88770. private _unTranslatedPointerX;
  88771. private _unTranslatedPointerY;
  88772. private _startingPointerPosition;
  88773. private _previousStartingPointerPosition;
  88774. private _startingPointerTime;
  88775. private _previousStartingPointerTime;
  88776. private _pointerCaptures;
  88777. private _timeAccumulator;
  88778. private _currentStepId;
  88779. private _currentInternalStep;
  88780. /** @hidden */
  88781. _mirroredCameraPosition: Nullable<Vector3>;
  88782. /**
  88783. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  88784. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  88785. */
  88786. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  88787. /**
  88788. * Observable event triggered each time an keyboard event is received from the hosting window
  88789. */
  88790. onKeyboardObservable: Observable<KeyboardInfo>;
  88791. private _onKeyDown;
  88792. private _onKeyUp;
  88793. private _onCanvasFocusObserver;
  88794. private _onCanvasBlurObserver;
  88795. private _useRightHandedSystem;
  88796. /**
  88797. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  88798. */
  88799. useRightHandedSystem: boolean;
  88800. /**
  88801. * Sets the step Id used by deterministic lock step
  88802. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88803. * @param newStepId defines the step Id
  88804. */
  88805. setStepId(newStepId: number): void;
  88806. /**
  88807. * Gets the step Id used by deterministic lock step
  88808. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88809. * @returns the step Id
  88810. */
  88811. getStepId(): number;
  88812. /**
  88813. * Gets the internal step used by deterministic lock step
  88814. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88815. * @returns the internal step
  88816. */
  88817. getInternalStep(): number;
  88818. private _fogEnabled;
  88819. /**
  88820. * Gets or sets a boolean indicating if fog is enabled on this scene
  88821. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88822. * (Default is true)
  88823. */
  88824. fogEnabled: boolean;
  88825. private _fogMode;
  88826. /**
  88827. * Gets or sets the fog mode to use
  88828. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88829. * | mode | value |
  88830. * | --- | --- |
  88831. * | FOGMODE_NONE | 0 |
  88832. * | FOGMODE_EXP | 1 |
  88833. * | FOGMODE_EXP2 | 2 |
  88834. * | FOGMODE_LINEAR | 3 |
  88835. */
  88836. fogMode: number;
  88837. /**
  88838. * Gets or sets the fog color to use
  88839. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88840. * (Default is Color3(0.2, 0.2, 0.3))
  88841. */
  88842. fogColor: Color3;
  88843. /**
  88844. * Gets or sets the fog density to use
  88845. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88846. * (Default is 0.1)
  88847. */
  88848. fogDensity: number;
  88849. /**
  88850. * Gets or sets the fog start distance to use
  88851. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88852. * (Default is 0)
  88853. */
  88854. fogStart: number;
  88855. /**
  88856. * Gets or sets the fog end distance to use
  88857. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88858. * (Default is 1000)
  88859. */
  88860. fogEnd: number;
  88861. private _shadowsEnabled;
  88862. /**
  88863. * Gets or sets a boolean indicating if shadows are enabled on this scene
  88864. */
  88865. shadowsEnabled: boolean;
  88866. private _lightsEnabled;
  88867. /**
  88868. * Gets or sets a boolean indicating if lights are enabled on this scene
  88869. */
  88870. lightsEnabled: boolean;
  88871. /** All of the active cameras added to this scene. */
  88872. activeCameras: Camera[];
  88873. private _activeCamera;
  88874. /** Gets or sets the current active camera */
  88875. activeCamera: Nullable<Camera>;
  88876. private _defaultMaterial;
  88877. /** The default material used on meshes when no material is affected */
  88878. /** The default material used on meshes when no material is affected */
  88879. defaultMaterial: Material;
  88880. private _texturesEnabled;
  88881. /**
  88882. * Gets or sets a boolean indicating if textures are enabled on this scene
  88883. */
  88884. texturesEnabled: boolean;
  88885. /**
  88886. * Gets or sets a boolean indicating if particles are enabled on this scene
  88887. */
  88888. particlesEnabled: boolean;
  88889. /**
  88890. * Gets or sets a boolean indicating if sprites are enabled on this scene
  88891. */
  88892. spritesEnabled: boolean;
  88893. private _skeletonsEnabled;
  88894. /**
  88895. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  88896. */
  88897. skeletonsEnabled: boolean;
  88898. /**
  88899. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  88900. */
  88901. lensFlaresEnabled: boolean;
  88902. /**
  88903. * Gets or sets a boolean indicating if collisions are enabled on this scene
  88904. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88905. */
  88906. collisionsEnabled: boolean;
  88907. private _collisionCoordinator;
  88908. /** @hidden */
  88909. readonly collisionCoordinator: ICollisionCoordinator;
  88910. /**
  88911. * Defines the gravity applied to this scene (used only for collisions)
  88912. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88913. */
  88914. gravity: Vector3;
  88915. /**
  88916. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  88917. */
  88918. postProcessesEnabled: boolean;
  88919. /**
  88920. * The list of postprocesses added to the scene
  88921. */
  88922. postProcesses: PostProcess[];
  88923. /**
  88924. * Gets the current postprocess manager
  88925. */
  88926. postProcessManager: PostProcessManager;
  88927. /**
  88928. * Gets or sets a boolean indicating if render targets are enabled on this scene
  88929. */
  88930. renderTargetsEnabled: boolean;
  88931. /**
  88932. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  88933. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  88934. */
  88935. dumpNextRenderTargets: boolean;
  88936. /**
  88937. * The list of user defined render targets added to the scene
  88938. */
  88939. customRenderTargets: RenderTargetTexture[];
  88940. /**
  88941. * Defines if texture loading must be delayed
  88942. * If true, textures will only be loaded when they need to be rendered
  88943. */
  88944. useDelayedTextureLoading: boolean;
  88945. /**
  88946. * Gets the list of meshes imported to the scene through SceneLoader
  88947. */
  88948. importedMeshesFiles: String[];
  88949. /**
  88950. * Gets or sets a boolean indicating if probes are enabled on this scene
  88951. */
  88952. probesEnabled: boolean;
  88953. /**
  88954. * Gets or sets the current offline provider to use to store scene data
  88955. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  88956. */
  88957. offlineProvider: IOfflineProvider;
  88958. /**
  88959. * Gets or sets the action manager associated with the scene
  88960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88961. */
  88962. actionManager: AbstractActionManager;
  88963. private _meshesForIntersections;
  88964. /**
  88965. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  88966. */
  88967. proceduralTexturesEnabled: boolean;
  88968. private _engine;
  88969. private _totalVertices;
  88970. /** @hidden */
  88971. _activeIndices: PerfCounter;
  88972. /** @hidden */
  88973. _activeParticles: PerfCounter;
  88974. /** @hidden */
  88975. _activeBones: PerfCounter;
  88976. private _animationRatio;
  88977. /** @hidden */
  88978. _animationTimeLast: number;
  88979. /** @hidden */
  88980. _animationTime: number;
  88981. /**
  88982. * Gets or sets a general scale for animation speed
  88983. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  88984. */
  88985. animationTimeScale: number;
  88986. /** @hidden */
  88987. _cachedMaterial: Nullable<Material>;
  88988. /** @hidden */
  88989. _cachedEffect: Nullable<Effect>;
  88990. /** @hidden */
  88991. _cachedVisibility: Nullable<number>;
  88992. private _renderId;
  88993. private _frameId;
  88994. private _executeWhenReadyTimeoutId;
  88995. private _intermediateRendering;
  88996. private _viewUpdateFlag;
  88997. private _projectionUpdateFlag;
  88998. private _alternateViewUpdateFlag;
  88999. private _alternateProjectionUpdateFlag;
  89000. /** @hidden */
  89001. _toBeDisposed: Nullable<IDisposable>[];
  89002. private _activeRequests;
  89003. /** @hidden */
  89004. _pendingData: any[];
  89005. private _isDisposed;
  89006. /**
  89007. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89008. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89009. */
  89010. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89011. private _activeMeshes;
  89012. private _processedMaterials;
  89013. private _renderTargets;
  89014. /** @hidden */
  89015. _activeParticleSystems: SmartArray<IParticleSystem>;
  89016. private _activeSkeletons;
  89017. private _softwareSkinnedMeshes;
  89018. private _renderingManager;
  89019. /** @hidden */
  89020. _activeAnimatables: Animatable[];
  89021. private _transformMatrix;
  89022. private _sceneUbo;
  89023. private _alternateSceneUbo;
  89024. private _viewMatrix;
  89025. private _projectionMatrix;
  89026. private _alternateViewMatrix;
  89027. private _alternateProjectionMatrix;
  89028. private _alternateTransformMatrix;
  89029. private _useAlternateCameraConfiguration;
  89030. private _alternateRendering;
  89031. private _wheelEventName;
  89032. /** @hidden */
  89033. _forcedViewPosition: Nullable<Vector3>;
  89034. /** @hidden */
  89035. readonly _isAlternateRenderingEnabled: boolean;
  89036. private _frustumPlanes;
  89037. /**
  89038. * Gets the list of frustum planes (built from the active camera)
  89039. */
  89040. readonly frustumPlanes: Plane[];
  89041. /**
  89042. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89043. * This is useful if there are more lights that the maximum simulteanous authorized
  89044. */
  89045. requireLightSorting: boolean;
  89046. /** @hidden */
  89047. readonly useMaterialMeshMap: boolean;
  89048. /** @hidden */
  89049. readonly useClonedMeshhMap: boolean;
  89050. private _pointerOverMesh;
  89051. private _pickedDownMesh;
  89052. private _pickedUpMesh;
  89053. private _externalData;
  89054. private _uid;
  89055. /**
  89056. * @hidden
  89057. * Backing store of defined scene components.
  89058. */
  89059. _components: ISceneComponent[];
  89060. /**
  89061. * @hidden
  89062. * Backing store of defined scene components.
  89063. */
  89064. _serializableComponents: ISceneSerializableComponent[];
  89065. /**
  89066. * List of components to register on the next registration step.
  89067. */
  89068. private _transientComponents;
  89069. /**
  89070. * Registers the transient components if needed.
  89071. */
  89072. private _registerTransientComponents;
  89073. /**
  89074. * @hidden
  89075. * Add a component to the scene.
  89076. * Note that the ccomponent could be registered on th next frame if this is called after
  89077. * the register component stage.
  89078. * @param component Defines the component to add to the scene
  89079. */
  89080. _addComponent(component: ISceneComponent): void;
  89081. /**
  89082. * @hidden
  89083. * Gets a component from the scene.
  89084. * @param name defines the name of the component to retrieve
  89085. * @returns the component or null if not present
  89086. */
  89087. _getComponent(name: string): Nullable<ISceneComponent>;
  89088. /**
  89089. * @hidden
  89090. * Defines the actions happening before camera updates.
  89091. */
  89092. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89093. /**
  89094. * @hidden
  89095. * Defines the actions happening before clear the canvas.
  89096. */
  89097. _beforeClearStage: Stage<SimpleStageAction>;
  89098. /**
  89099. * @hidden
  89100. * Defines the actions when collecting render targets for the frame.
  89101. */
  89102. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89103. /**
  89104. * @hidden
  89105. * Defines the actions happening for one camera in the frame.
  89106. */
  89107. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89108. /**
  89109. * @hidden
  89110. * Defines the actions happening during the per mesh ready checks.
  89111. */
  89112. _isReadyForMeshStage: Stage<MeshStageAction>;
  89113. /**
  89114. * @hidden
  89115. * Defines the actions happening before evaluate active mesh checks.
  89116. */
  89117. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89118. /**
  89119. * @hidden
  89120. * Defines the actions happening during the evaluate sub mesh checks.
  89121. */
  89122. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89123. /**
  89124. * @hidden
  89125. * Defines the actions happening during the active mesh stage.
  89126. */
  89127. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89128. /**
  89129. * @hidden
  89130. * Defines the actions happening during the per camera render target step.
  89131. */
  89132. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89133. /**
  89134. * @hidden
  89135. * Defines the actions happening just before the active camera is drawing.
  89136. */
  89137. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89138. /**
  89139. * @hidden
  89140. * Defines the actions happening just before a render target is drawing.
  89141. */
  89142. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89143. /**
  89144. * @hidden
  89145. * Defines the actions happening just before a rendering group is drawing.
  89146. */
  89147. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89148. /**
  89149. * @hidden
  89150. * Defines the actions happening just before a mesh is drawing.
  89151. */
  89152. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89153. /**
  89154. * @hidden
  89155. * Defines the actions happening just after a mesh has been drawn.
  89156. */
  89157. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89158. /**
  89159. * @hidden
  89160. * Defines the actions happening just after a rendering group has been drawn.
  89161. */
  89162. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89163. /**
  89164. * @hidden
  89165. * Defines the actions happening just after the active camera has been drawn.
  89166. */
  89167. _afterCameraDrawStage: Stage<CameraStageAction>;
  89168. /**
  89169. * @hidden
  89170. * Defines the actions happening just after a render target has been drawn.
  89171. */
  89172. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89173. /**
  89174. * @hidden
  89175. * Defines the actions happening just after rendering all cameras and computing intersections.
  89176. */
  89177. _afterRenderStage: Stage<SimpleStageAction>;
  89178. /**
  89179. * @hidden
  89180. * Defines the actions happening when a pointer move event happens.
  89181. */
  89182. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89183. /**
  89184. * @hidden
  89185. * Defines the actions happening when a pointer down event happens.
  89186. */
  89187. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89188. /**
  89189. * @hidden
  89190. * Defines the actions happening when a pointer up event happens.
  89191. */
  89192. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89193. /**
  89194. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89195. */
  89196. private geometriesByUniqueId;
  89197. /**
  89198. * Creates a new Scene
  89199. * @param engine defines the engine to use to render this scene
  89200. * @param options defines the scene options
  89201. */
  89202. constructor(engine: Engine, options?: SceneOptions);
  89203. private _defaultMeshCandidates;
  89204. /**
  89205. * @hidden
  89206. */
  89207. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89208. private _defaultSubMeshCandidates;
  89209. /**
  89210. * @hidden
  89211. */
  89212. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89213. /**
  89214. * Sets the default candidate providers for the scene.
  89215. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89216. * and getCollidingSubMeshCandidates to their default function
  89217. */
  89218. setDefaultCandidateProviders(): void;
  89219. /**
  89220. * Gets the mesh that is currently under the pointer
  89221. */
  89222. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89223. /**
  89224. * Gets or sets the current on-screen X position of the pointer
  89225. */
  89226. pointerX: number;
  89227. /**
  89228. * Gets or sets the current on-screen Y position of the pointer
  89229. */
  89230. pointerY: number;
  89231. /**
  89232. * Gets the cached material (ie. the latest rendered one)
  89233. * @returns the cached material
  89234. */
  89235. getCachedMaterial(): Nullable<Material>;
  89236. /**
  89237. * Gets the cached effect (ie. the latest rendered one)
  89238. * @returns the cached effect
  89239. */
  89240. getCachedEffect(): Nullable<Effect>;
  89241. /**
  89242. * Gets the cached visibility state (ie. the latest rendered one)
  89243. * @returns the cached visibility state
  89244. */
  89245. getCachedVisibility(): Nullable<number>;
  89246. /**
  89247. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89248. * @param material defines the current material
  89249. * @param effect defines the current effect
  89250. * @param visibility defines the current visibility state
  89251. * @returns true if one parameter is not cached
  89252. */
  89253. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89254. /**
  89255. * Gets the engine associated with the scene
  89256. * @returns an Engine
  89257. */
  89258. getEngine(): Engine;
  89259. /**
  89260. * Gets the total number of vertices rendered per frame
  89261. * @returns the total number of vertices rendered per frame
  89262. */
  89263. getTotalVertices(): number;
  89264. /**
  89265. * Gets the performance counter for total vertices
  89266. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89267. */
  89268. readonly totalVerticesPerfCounter: PerfCounter;
  89269. /**
  89270. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89271. * @returns the total number of active indices rendered per frame
  89272. */
  89273. getActiveIndices(): number;
  89274. /**
  89275. * Gets the performance counter for active indices
  89276. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89277. */
  89278. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89279. /**
  89280. * Gets the total number of active particles rendered per frame
  89281. * @returns the total number of active particles rendered per frame
  89282. */
  89283. getActiveParticles(): number;
  89284. /**
  89285. * Gets the performance counter for active particles
  89286. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89287. */
  89288. readonly activeParticlesPerfCounter: PerfCounter;
  89289. /**
  89290. * Gets the total number of active bones rendered per frame
  89291. * @returns the total number of active bones rendered per frame
  89292. */
  89293. getActiveBones(): number;
  89294. /**
  89295. * Gets the performance counter for active bones
  89296. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89297. */
  89298. readonly activeBonesPerfCounter: PerfCounter;
  89299. /**
  89300. * Gets the array of active meshes
  89301. * @returns an array of AbstractMesh
  89302. */
  89303. getActiveMeshes(): SmartArray<AbstractMesh>;
  89304. /**
  89305. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89306. * @returns a number
  89307. */
  89308. getAnimationRatio(): number;
  89309. /**
  89310. * Gets an unique Id for the current render phase
  89311. * @returns a number
  89312. */
  89313. getRenderId(): number;
  89314. /**
  89315. * Gets an unique Id for the current frame
  89316. * @returns a number
  89317. */
  89318. getFrameId(): number;
  89319. /** Call this function if you want to manually increment the render Id*/
  89320. incrementRenderId(): void;
  89321. private _updatePointerPosition;
  89322. private _createUbo;
  89323. private _createAlternateUbo;
  89324. private _setRayOnPointerInfo;
  89325. /**
  89326. * Use this method to simulate a pointer move on a mesh
  89327. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89328. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89329. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89330. * @returns the current scene
  89331. */
  89332. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89333. private _processPointerMove;
  89334. private _checkPrePointerObservable;
  89335. /**
  89336. * Use this method to simulate a pointer down on a mesh
  89337. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89338. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89339. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89340. * @returns the current scene
  89341. */
  89342. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89343. private _processPointerDown;
  89344. /**
  89345. * Use this method to simulate a pointer up on a mesh
  89346. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89347. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89348. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89349. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89350. * @returns the current scene
  89351. */
  89352. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89353. private _processPointerUp;
  89354. /**
  89355. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89356. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89357. * @returns true if the pointer was captured
  89358. */
  89359. isPointerCaptured(pointerId?: number): boolean;
  89360. /** @hidden */
  89361. _isPointerSwiping(): boolean;
  89362. /**
  89363. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89364. * @param attachUp defines if you want to attach events to pointerup
  89365. * @param attachDown defines if you want to attach events to pointerdown
  89366. * @param attachMove defines if you want to attach events to pointermove
  89367. */
  89368. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89369. /** Detaches all event handlers*/
  89370. detachControl(): void;
  89371. /**
  89372. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89373. * Delay loaded resources are not taking in account
  89374. * @return true if all required resources are ready
  89375. */
  89376. isReady(): boolean;
  89377. /** Resets all cached information relative to material (including effect and visibility) */
  89378. resetCachedMaterial(): void;
  89379. /**
  89380. * Registers a function to be called before every frame render
  89381. * @param func defines the function to register
  89382. */
  89383. registerBeforeRender(func: () => void): void;
  89384. /**
  89385. * Unregisters a function called before every frame render
  89386. * @param func defines the function to unregister
  89387. */
  89388. unregisterBeforeRender(func: () => void): void;
  89389. /**
  89390. * Registers a function to be called after every frame render
  89391. * @param func defines the function to register
  89392. */
  89393. registerAfterRender(func: () => void): void;
  89394. /**
  89395. * Unregisters a function called after every frame render
  89396. * @param func defines the function to unregister
  89397. */
  89398. unregisterAfterRender(func: () => void): void;
  89399. private _executeOnceBeforeRender;
  89400. /**
  89401. * The provided function will run before render once and will be disposed afterwards.
  89402. * A timeout delay can be provided so that the function will be executed in N ms.
  89403. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89404. * @param func The function to be executed.
  89405. * @param timeout optional delay in ms
  89406. */
  89407. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89408. /** @hidden */
  89409. _addPendingData(data: any): void;
  89410. /** @hidden */
  89411. _removePendingData(data: any): void;
  89412. /**
  89413. * Returns the number of items waiting to be loaded
  89414. * @returns the number of items waiting to be loaded
  89415. */
  89416. getWaitingItemsCount(): number;
  89417. /**
  89418. * Returns a boolean indicating if the scene is still loading data
  89419. */
  89420. readonly isLoading: boolean;
  89421. /**
  89422. * Registers a function to be executed when the scene is ready
  89423. * @param {Function} func - the function to be executed
  89424. */
  89425. executeWhenReady(func: () => void): void;
  89426. /**
  89427. * Returns a promise that resolves when the scene is ready
  89428. * @returns A promise that resolves when the scene is ready
  89429. */
  89430. whenReadyAsync(): Promise<void>;
  89431. /** @hidden */
  89432. _checkIsReady(): void;
  89433. /**
  89434. * Gets all animatable attached to the scene
  89435. */
  89436. readonly animatables: Animatable[];
  89437. /**
  89438. * Resets the last animation time frame.
  89439. * Useful to override when animations start running when loading a scene for the first time.
  89440. */
  89441. resetLastAnimationTimeFrame(): void;
  89442. /** @hidden */
  89443. _switchToAlternateCameraConfiguration(active: boolean): void;
  89444. /**
  89445. * Gets the current view matrix
  89446. * @returns a Matrix
  89447. */
  89448. getViewMatrix(): Matrix;
  89449. /**
  89450. * Gets the current projection matrix
  89451. * @returns a Matrix
  89452. */
  89453. getProjectionMatrix(): Matrix;
  89454. /**
  89455. * Gets the current transform matrix
  89456. * @returns a Matrix made of View * Projection
  89457. */
  89458. getTransformMatrix(): Matrix;
  89459. /**
  89460. * Sets the current transform matrix
  89461. * @param view defines the View matrix to use
  89462. * @param projection defines the Projection matrix to use
  89463. */
  89464. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89465. /** @hidden */
  89466. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89467. /**
  89468. * Gets the uniform buffer used to store scene data
  89469. * @returns a UniformBuffer
  89470. */
  89471. getSceneUniformBuffer(): UniformBuffer;
  89472. /**
  89473. * Gets an unique (relatively to the current scene) Id
  89474. * @returns an unique number for the scene
  89475. */
  89476. getUniqueId(): number;
  89477. /**
  89478. * Add a mesh to the list of scene's meshes
  89479. * @param newMesh defines the mesh to add
  89480. * @param recursive if all child meshes should also be added to the scene
  89481. */
  89482. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89483. /**
  89484. * Remove a mesh for the list of scene's meshes
  89485. * @param toRemove defines the mesh to remove
  89486. * @param recursive if all child meshes should also be removed from the scene
  89487. * @returns the index where the mesh was in the mesh list
  89488. */
  89489. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89490. /**
  89491. * Add a transform node to the list of scene's transform nodes
  89492. * @param newTransformNode defines the transform node to add
  89493. */
  89494. addTransformNode(newTransformNode: TransformNode): void;
  89495. /**
  89496. * Remove a transform node for the list of scene's transform nodes
  89497. * @param toRemove defines the transform node to remove
  89498. * @returns the index where the transform node was in the transform node list
  89499. */
  89500. removeTransformNode(toRemove: TransformNode): number;
  89501. /**
  89502. * Remove a skeleton for the list of scene's skeletons
  89503. * @param toRemove defines the skeleton to remove
  89504. * @returns the index where the skeleton was in the skeleton list
  89505. */
  89506. removeSkeleton(toRemove: Skeleton): number;
  89507. /**
  89508. * Remove a morph target for the list of scene's morph targets
  89509. * @param toRemove defines the morph target to remove
  89510. * @returns the index where the morph target was in the morph target list
  89511. */
  89512. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  89513. /**
  89514. * Remove a light for the list of scene's lights
  89515. * @param toRemove defines the light to remove
  89516. * @returns the index where the light was in the light list
  89517. */
  89518. removeLight(toRemove: Light): number;
  89519. /**
  89520. * Remove a camera for the list of scene's cameras
  89521. * @param toRemove defines the camera to remove
  89522. * @returns the index where the camera was in the camera list
  89523. */
  89524. removeCamera(toRemove: Camera): number;
  89525. /**
  89526. * Remove a particle system for the list of scene's particle systems
  89527. * @param toRemove defines the particle system to remove
  89528. * @returns the index where the particle system was in the particle system list
  89529. */
  89530. removeParticleSystem(toRemove: IParticleSystem): number;
  89531. /**
  89532. * Remove a animation for the list of scene's animations
  89533. * @param toRemove defines the animation to remove
  89534. * @returns the index where the animation was in the animation list
  89535. */
  89536. removeAnimation(toRemove: Animation): number;
  89537. /**
  89538. * Removes the given animation group from this scene.
  89539. * @param toRemove The animation group to remove
  89540. * @returns The index of the removed animation group
  89541. */
  89542. removeAnimationGroup(toRemove: AnimationGroup): number;
  89543. /**
  89544. * Removes the given multi-material from this scene.
  89545. * @param toRemove The multi-material to remove
  89546. * @returns The index of the removed multi-material
  89547. */
  89548. removeMultiMaterial(toRemove: MultiMaterial): number;
  89549. /**
  89550. * Removes the given material from this scene.
  89551. * @param toRemove The material to remove
  89552. * @returns The index of the removed material
  89553. */
  89554. removeMaterial(toRemove: Material): number;
  89555. /**
  89556. * Removes the given action manager from this scene.
  89557. * @param toRemove The action manager to remove
  89558. * @returns The index of the removed action manager
  89559. */
  89560. removeActionManager(toRemove: AbstractActionManager): number;
  89561. /**
  89562. * Removes the given texture from this scene.
  89563. * @param toRemove The texture to remove
  89564. * @returns The index of the removed texture
  89565. */
  89566. removeTexture(toRemove: BaseTexture): number;
  89567. /**
  89568. * Adds the given light to this scene
  89569. * @param newLight The light to add
  89570. */
  89571. addLight(newLight: Light): void;
  89572. /**
  89573. * Sorts the list list based on light priorities
  89574. */
  89575. sortLightsByPriority(): void;
  89576. /**
  89577. * Adds the given camera to this scene
  89578. * @param newCamera The camera to add
  89579. */
  89580. addCamera(newCamera: Camera): void;
  89581. /**
  89582. * Adds the given skeleton to this scene
  89583. * @param newSkeleton The skeleton to add
  89584. */
  89585. addSkeleton(newSkeleton: Skeleton): void;
  89586. /**
  89587. * Adds the given particle system to this scene
  89588. * @param newParticleSystem The particle system to add
  89589. */
  89590. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89591. /**
  89592. * Adds the given animation to this scene
  89593. * @param newAnimation The animation to add
  89594. */
  89595. addAnimation(newAnimation: Animation): void;
  89596. /**
  89597. * Adds the given animation group to this scene.
  89598. * @param newAnimationGroup The animation group to add
  89599. */
  89600. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89601. /**
  89602. * Adds the given multi-material to this scene
  89603. * @param newMultiMaterial The multi-material to add
  89604. */
  89605. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89606. /**
  89607. * Adds the given material to this scene
  89608. * @param newMaterial The material to add
  89609. */
  89610. addMaterial(newMaterial: Material): void;
  89611. /**
  89612. * Adds the given morph target to this scene
  89613. * @param newMorphTargetManager The morph target to add
  89614. */
  89615. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89616. /**
  89617. * Adds the given geometry to this scene
  89618. * @param newGeometry The geometry to add
  89619. */
  89620. addGeometry(newGeometry: Geometry): void;
  89621. /**
  89622. * Adds the given action manager to this scene
  89623. * @param newActionManager The action manager to add
  89624. */
  89625. addActionManager(newActionManager: AbstractActionManager): void;
  89626. /**
  89627. * Adds the given texture to this scene.
  89628. * @param newTexture The texture to add
  89629. */
  89630. addTexture(newTexture: BaseTexture): void;
  89631. /**
  89632. * Switch active camera
  89633. * @param newCamera defines the new active camera
  89634. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89635. */
  89636. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89637. /**
  89638. * sets the active camera of the scene using its ID
  89639. * @param id defines the camera's ID
  89640. * @return the new active camera or null if none found.
  89641. */
  89642. setActiveCameraByID(id: string): Nullable<Camera>;
  89643. /**
  89644. * sets the active camera of the scene using its name
  89645. * @param name defines the camera's name
  89646. * @returns the new active camera or null if none found.
  89647. */
  89648. setActiveCameraByName(name: string): Nullable<Camera>;
  89649. /**
  89650. * get an animation group using its name
  89651. * @param name defines the material's name
  89652. * @return the animation group or null if none found.
  89653. */
  89654. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89655. /**
  89656. * get a material using its id
  89657. * @param id defines the material's ID
  89658. * @return the material or null if none found.
  89659. */
  89660. getMaterialByID(id: string): Nullable<Material>;
  89661. /**
  89662. * Gets a material using its name
  89663. * @param name defines the material's name
  89664. * @return the material or null if none found.
  89665. */
  89666. getMaterialByName(name: string): Nullable<Material>;
  89667. /**
  89668. * Gets a camera using its id
  89669. * @param id defines the id to look for
  89670. * @returns the camera or null if not found
  89671. */
  89672. getCameraByID(id: string): Nullable<Camera>;
  89673. /**
  89674. * Gets a camera using its unique id
  89675. * @param uniqueId defines the unique id to look for
  89676. * @returns the camera or null if not found
  89677. */
  89678. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89679. /**
  89680. * Gets a camera using its name
  89681. * @param name defines the camera's name
  89682. * @return the camera or null if none found.
  89683. */
  89684. getCameraByName(name: string): Nullable<Camera>;
  89685. /**
  89686. * Gets a bone using its id
  89687. * @param id defines the bone's id
  89688. * @return the bone or null if not found
  89689. */
  89690. getBoneByID(id: string): Nullable<Bone>;
  89691. /**
  89692. * Gets a bone using its id
  89693. * @param name defines the bone's name
  89694. * @return the bone or null if not found
  89695. */
  89696. getBoneByName(name: string): Nullable<Bone>;
  89697. /**
  89698. * Gets a light node using its name
  89699. * @param name defines the the light's name
  89700. * @return the light or null if none found.
  89701. */
  89702. getLightByName(name: string): Nullable<Light>;
  89703. /**
  89704. * Gets a light node using its id
  89705. * @param id defines the light's id
  89706. * @return the light or null if none found.
  89707. */
  89708. getLightByID(id: string): Nullable<Light>;
  89709. /**
  89710. * Gets a light node using its scene-generated unique ID
  89711. * @param uniqueId defines the light's unique id
  89712. * @return the light or null if none found.
  89713. */
  89714. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89715. /**
  89716. * Gets a particle system by id
  89717. * @param id defines the particle system id
  89718. * @return the corresponding system or null if none found
  89719. */
  89720. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  89721. /**
  89722. * Gets a geometry using its ID
  89723. * @param id defines the geometry's id
  89724. * @return the geometry or null if none found.
  89725. */
  89726. getGeometryByID(id: string): Nullable<Geometry>;
  89727. private _getGeometryByUniqueID;
  89728. /**
  89729. * Add a new geometry to this scene
  89730. * @param geometry defines the geometry to be added to the scene.
  89731. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  89732. * @return a boolean defining if the geometry was added or not
  89733. */
  89734. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  89735. /**
  89736. * Removes an existing geometry
  89737. * @param geometry defines the geometry to be removed from the scene
  89738. * @return a boolean defining if the geometry was removed or not
  89739. */
  89740. removeGeometry(geometry: Geometry): boolean;
  89741. /**
  89742. * Gets the list of geometries attached to the scene
  89743. * @returns an array of Geometry
  89744. */
  89745. getGeometries(): Geometry[];
  89746. /**
  89747. * Gets the first added mesh found of a given ID
  89748. * @param id defines the id to search for
  89749. * @return the mesh found or null if not found at all
  89750. */
  89751. getMeshByID(id: string): Nullable<AbstractMesh>;
  89752. /**
  89753. * Gets a list of meshes using their id
  89754. * @param id defines the id to search for
  89755. * @returns a list of meshes
  89756. */
  89757. getMeshesByID(id: string): Array<AbstractMesh>;
  89758. /**
  89759. * Gets the first added transform node found of a given ID
  89760. * @param id defines the id to search for
  89761. * @return the found transform node or null if not found at all.
  89762. */
  89763. getTransformNodeByID(id: string): Nullable<TransformNode>;
  89764. /**
  89765. * Gets a list of transform nodes using their id
  89766. * @param id defines the id to search for
  89767. * @returns a list of transform nodes
  89768. */
  89769. getTransformNodesByID(id: string): Array<TransformNode>;
  89770. /**
  89771. * Gets a mesh with its auto-generated unique id
  89772. * @param uniqueId defines the unique id to search for
  89773. * @return the found mesh or null if not found at all.
  89774. */
  89775. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  89776. /**
  89777. * Gets a the last added mesh using a given id
  89778. * @param id defines the id to search for
  89779. * @return the found mesh or null if not found at all.
  89780. */
  89781. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  89782. /**
  89783. * Gets a the last added node (Mesh, Camera, Light) using a given id
  89784. * @param id defines the id to search for
  89785. * @return the found node or null if not found at all
  89786. */
  89787. getLastEntryByID(id: string): Nullable<Node>;
  89788. /**
  89789. * Gets a node (Mesh, Camera, Light) using a given id
  89790. * @param id defines the id to search for
  89791. * @return the found node or null if not found at all
  89792. */
  89793. getNodeByID(id: string): Nullable<Node>;
  89794. /**
  89795. * Gets a node (Mesh, Camera, Light) using a given name
  89796. * @param name defines the name to search for
  89797. * @return the found node or null if not found at all.
  89798. */
  89799. getNodeByName(name: string): Nullable<Node>;
  89800. /**
  89801. * Gets a mesh using a given name
  89802. * @param name defines the name to search for
  89803. * @return the found mesh or null if not found at all.
  89804. */
  89805. getMeshByName(name: string): Nullable<AbstractMesh>;
  89806. /**
  89807. * Gets a transform node using a given name
  89808. * @param name defines the name to search for
  89809. * @return the found transform node or null if not found at all.
  89810. */
  89811. getTransformNodeByName(name: string): Nullable<TransformNode>;
  89812. /**
  89813. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  89814. * @param id defines the id to search for
  89815. * @return the found skeleton or null if not found at all.
  89816. */
  89817. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  89818. /**
  89819. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  89820. * @param id defines the id to search for
  89821. * @return the found skeleton or null if not found at all.
  89822. */
  89823. getSkeletonById(id: string): Nullable<Skeleton>;
  89824. /**
  89825. * Gets a skeleton using a given name
  89826. * @param name defines the name to search for
  89827. * @return the found skeleton or null if not found at all.
  89828. */
  89829. getSkeletonByName(name: string): Nullable<Skeleton>;
  89830. /**
  89831. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  89832. * @param id defines the id to search for
  89833. * @return the found morph target manager or null if not found at all.
  89834. */
  89835. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  89836. /**
  89837. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  89838. * @param id defines the id to search for
  89839. * @return the found morph target or null if not found at all.
  89840. */
  89841. getMorphTargetById(id: string): Nullable<MorphTarget>;
  89842. /**
  89843. * Gets a boolean indicating if the given mesh is active
  89844. * @param mesh defines the mesh to look for
  89845. * @returns true if the mesh is in the active list
  89846. */
  89847. isActiveMesh(mesh: AbstractMesh): boolean;
  89848. /**
  89849. * Return a unique id as a string which can serve as an identifier for the scene
  89850. */
  89851. readonly uid: string;
  89852. /**
  89853. * Add an externaly attached data from its key.
  89854. * This method call will fail and return false, if such key already exists.
  89855. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  89856. * @param key the unique key that identifies the data
  89857. * @param data the data object to associate to the key for this Engine instance
  89858. * @return true if no such key were already present and the data was added successfully, false otherwise
  89859. */
  89860. addExternalData<T>(key: string, data: T): boolean;
  89861. /**
  89862. * Get an externaly attached data from its key
  89863. * @param key the unique key that identifies the data
  89864. * @return the associated data, if present (can be null), or undefined if not present
  89865. */
  89866. getExternalData<T>(key: string): Nullable<T>;
  89867. /**
  89868. * Get an externaly attached data from its key, create it using a factory if it's not already present
  89869. * @param key the unique key that identifies the data
  89870. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  89871. * @return the associated data, can be null if the factory returned null.
  89872. */
  89873. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  89874. /**
  89875. * Remove an externaly attached data from the Engine instance
  89876. * @param key the unique key that identifies the data
  89877. * @return true if the data was successfully removed, false if it doesn't exist
  89878. */
  89879. removeExternalData(key: string): boolean;
  89880. private _evaluateSubMesh;
  89881. /**
  89882. * Clear the processed materials smart array preventing retention point in material dispose.
  89883. */
  89884. freeProcessedMaterials(): void;
  89885. private _preventFreeActiveMeshesAndRenderingGroups;
  89886. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  89887. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  89888. * when disposing several meshes in a row or a hierarchy of meshes.
  89889. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  89890. */
  89891. blockfreeActiveMeshesAndRenderingGroups: boolean;
  89892. /**
  89893. * Clear the active meshes smart array preventing retention point in mesh dispose.
  89894. */
  89895. freeActiveMeshes(): void;
  89896. /**
  89897. * Clear the info related to rendering groups preventing retention points during dispose.
  89898. */
  89899. freeRenderingGroups(): void;
  89900. /** @hidden */
  89901. _isInIntermediateRendering(): boolean;
  89902. /**
  89903. * Lambda returning the list of potentially active meshes.
  89904. */
  89905. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  89906. /**
  89907. * Lambda returning the list of potentially active sub meshes.
  89908. */
  89909. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  89910. /**
  89911. * Lambda returning the list of potentially intersecting sub meshes.
  89912. */
  89913. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  89914. /**
  89915. * Lambda returning the list of potentially colliding sub meshes.
  89916. */
  89917. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  89918. private _activeMeshesFrozen;
  89919. /**
  89920. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  89921. * @returns the current scene
  89922. */
  89923. freezeActiveMeshes(): Scene;
  89924. /**
  89925. * Use this function to restart evaluating active meshes on every frame
  89926. * @returns the current scene
  89927. */
  89928. unfreezeActiveMeshes(): Scene;
  89929. private _evaluateActiveMeshes;
  89930. private _activeMesh;
  89931. /**
  89932. * Update the transform matrix to update from the current active camera
  89933. * @param force defines a boolean used to force the update even if cache is up to date
  89934. */
  89935. updateTransformMatrix(force?: boolean): void;
  89936. /**
  89937. * 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)
  89938. * @param alternateCamera defines the camera to use
  89939. */
  89940. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  89941. /** @hidden */
  89942. _allowPostProcessClearColor: boolean;
  89943. private _renderForCamera;
  89944. private _processSubCameras;
  89945. private _checkIntersections;
  89946. /** @hidden */
  89947. _advancePhysicsEngineStep(step: number): void;
  89948. /**
  89949. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  89950. */
  89951. getDeterministicFrameTime: () => number;
  89952. /** @hidden */
  89953. _animate(): void;
  89954. /**
  89955. * Render the scene
  89956. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  89957. */
  89958. render(updateCameras?: boolean): void;
  89959. /**
  89960. * Freeze all materials
  89961. * A frozen material will not be updatable but should be faster to render
  89962. */
  89963. freezeMaterials(): void;
  89964. /**
  89965. * Unfreeze all materials
  89966. * A frozen material will not be updatable but should be faster to render
  89967. */
  89968. unfreezeMaterials(): void;
  89969. /**
  89970. * Releases all held ressources
  89971. */
  89972. dispose(): void;
  89973. /**
  89974. * Gets if the scene is already disposed
  89975. */
  89976. readonly isDisposed: boolean;
  89977. /**
  89978. * Call this function to reduce memory footprint of the scene.
  89979. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  89980. */
  89981. clearCachedVertexData(): void;
  89982. /**
  89983. * This function will remove the local cached buffer data from texture.
  89984. * It will save memory but will prevent the texture from being rebuilt
  89985. */
  89986. cleanCachedTextureBuffer(): void;
  89987. /**
  89988. * Get the world extend vectors with an optional filter
  89989. *
  89990. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  89991. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  89992. */
  89993. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  89994. min: Vector3;
  89995. max: Vector3;
  89996. };
  89997. /**
  89998. * Creates a ray that can be used to pick in the scene
  89999. * @param x defines the x coordinate of the origin (on-screen)
  90000. * @param y defines the y coordinate of the origin (on-screen)
  90001. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90002. * @param camera defines the camera to use for the picking
  90003. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90004. * @returns a Ray
  90005. */
  90006. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90007. /**
  90008. * Creates a ray that can be used to pick in the scene
  90009. * @param x defines the x coordinate of the origin (on-screen)
  90010. * @param y defines the y coordinate of the origin (on-screen)
  90011. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90012. * @param result defines the ray where to store the picking ray
  90013. * @param camera defines the camera to use for the picking
  90014. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90015. * @returns the current scene
  90016. */
  90017. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90018. /**
  90019. * Creates a ray that can be used to pick in the scene
  90020. * @param x defines the x coordinate of the origin (on-screen)
  90021. * @param y defines the y coordinate of the origin (on-screen)
  90022. * @param camera defines the camera to use for the picking
  90023. * @returns a Ray
  90024. */
  90025. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90026. /**
  90027. * Creates a ray that can be used to pick in the scene
  90028. * @param x defines the x coordinate of the origin (on-screen)
  90029. * @param y defines the y coordinate of the origin (on-screen)
  90030. * @param result defines the ray where to store the picking ray
  90031. * @param camera defines the camera to use for the picking
  90032. * @returns the current scene
  90033. */
  90034. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90035. /** Launch a ray to try to pick a mesh in the scene
  90036. * @param x position on screen
  90037. * @param y position on screen
  90038. * @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
  90039. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90040. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90041. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90042. * @returns a PickingInfo
  90043. */
  90044. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90045. /** Use the given ray to pick a mesh in the scene
  90046. * @param ray The ray to use to pick meshes
  90047. * @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
  90048. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90049. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90050. * @returns a PickingInfo
  90051. */
  90052. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90053. /**
  90054. * Launch a ray to try to pick a mesh in the scene
  90055. * @param x X position on screen
  90056. * @param y Y position on screen
  90057. * @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
  90058. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90059. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90060. * @returns an array of PickingInfo
  90061. */
  90062. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90063. /**
  90064. * Launch a ray to try to pick a mesh in the scene
  90065. * @param ray Ray to use
  90066. * @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
  90067. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90068. * @returns an array of PickingInfo
  90069. */
  90070. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90071. /**
  90072. * Force the value of meshUnderPointer
  90073. * @param mesh defines the mesh to use
  90074. */
  90075. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90076. /**
  90077. * Gets the mesh under the pointer
  90078. * @returns a Mesh or null if no mesh is under the pointer
  90079. */
  90080. getPointerOverMesh(): Nullable<AbstractMesh>;
  90081. /** @hidden */
  90082. _rebuildGeometries(): void;
  90083. /** @hidden */
  90084. _rebuildTextures(): void;
  90085. private _getByTags;
  90086. /**
  90087. * Get a list of meshes by tags
  90088. * @param tagsQuery defines the tags query to use
  90089. * @param forEach defines a predicate used to filter results
  90090. * @returns an array of Mesh
  90091. */
  90092. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90093. /**
  90094. * Get a list of cameras by tags
  90095. * @param tagsQuery defines the tags query to use
  90096. * @param forEach defines a predicate used to filter results
  90097. * @returns an array of Camera
  90098. */
  90099. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90100. /**
  90101. * Get a list of lights by tags
  90102. * @param tagsQuery defines the tags query to use
  90103. * @param forEach defines a predicate used to filter results
  90104. * @returns an array of Light
  90105. */
  90106. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90107. /**
  90108. * Get a list of materials by tags
  90109. * @param tagsQuery defines the tags query to use
  90110. * @param forEach defines a predicate used to filter results
  90111. * @returns an array of Material
  90112. */
  90113. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90114. /**
  90115. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90116. * This allowed control for front to back rendering or reversly depending of the special needs.
  90117. *
  90118. * @param renderingGroupId The rendering group id corresponding to its index
  90119. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90120. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90121. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90122. */
  90123. 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;
  90124. /**
  90125. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90126. *
  90127. * @param renderingGroupId The rendering group id corresponding to its index
  90128. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90129. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90130. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90131. */
  90132. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90133. /**
  90134. * Gets the current auto clear configuration for one rendering group of the rendering
  90135. * manager.
  90136. * @param index the rendering group index to get the information for
  90137. * @returns The auto clear setup for the requested rendering group
  90138. */
  90139. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90140. private _blockMaterialDirtyMechanism;
  90141. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90142. blockMaterialDirtyMechanism: boolean;
  90143. /**
  90144. * Will flag all materials as dirty to trigger new shader compilation
  90145. * @param flag defines the flag used to specify which material part must be marked as dirty
  90146. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90147. */
  90148. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90149. /** @hidden */
  90150. _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;
  90151. /** @hidden */
  90152. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90153. }
  90154. }
  90155. declare module BABYLON {
  90156. /**
  90157. * Set of assets to keep when moving a scene into an asset container.
  90158. */
  90159. export class KeepAssets extends AbstractScene {
  90160. }
  90161. /**
  90162. * Container with a set of assets that can be added or removed from a scene.
  90163. */
  90164. export class AssetContainer extends AbstractScene {
  90165. /**
  90166. * The scene the AssetContainer belongs to.
  90167. */
  90168. scene: Scene;
  90169. /**
  90170. * Instantiates an AssetContainer.
  90171. * @param scene The scene the AssetContainer belongs to.
  90172. */
  90173. constructor(scene: Scene);
  90174. /**
  90175. * Adds all the assets from the container to the scene.
  90176. */
  90177. addAllToScene(): void;
  90178. /**
  90179. * Removes all the assets in the container from the scene
  90180. */
  90181. removeAllFromScene(): void;
  90182. /**
  90183. * Disposes all the assets in the container
  90184. */
  90185. dispose(): void;
  90186. private _moveAssets;
  90187. /**
  90188. * Removes all the assets contained in the scene and adds them to the container.
  90189. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90190. */
  90191. moveAllFromScene(keepAssets?: KeepAssets): void;
  90192. /**
  90193. * 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.
  90194. * @returns the root mesh
  90195. */
  90196. createRootMesh(): Mesh;
  90197. }
  90198. }
  90199. declare module BABYLON {
  90200. /**
  90201. * Defines how the parser contract is defined.
  90202. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90203. */
  90204. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90205. /**
  90206. * Defines how the individual parser contract is defined.
  90207. * These parser can parse an individual asset
  90208. */
  90209. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90210. /**
  90211. * Base class of the scene acting as a container for the different elements composing a scene.
  90212. * This class is dynamically extended by the different components of the scene increasing
  90213. * flexibility and reducing coupling
  90214. */
  90215. export abstract class AbstractScene {
  90216. /**
  90217. * Stores the list of available parsers in the application.
  90218. */
  90219. private static _BabylonFileParsers;
  90220. /**
  90221. * Stores the list of available individual parsers in the application.
  90222. */
  90223. private static _IndividualBabylonFileParsers;
  90224. /**
  90225. * Adds a parser in the list of available ones
  90226. * @param name Defines the name of the parser
  90227. * @param parser Defines the parser to add
  90228. */
  90229. static AddParser(name: string, parser: BabylonFileParser): void;
  90230. /**
  90231. * Gets a general parser from the list of avaialble ones
  90232. * @param name Defines the name of the parser
  90233. * @returns the requested parser or null
  90234. */
  90235. static GetParser(name: string): Nullable<BabylonFileParser>;
  90236. /**
  90237. * Adds n individual parser in the list of available ones
  90238. * @param name Defines the name of the parser
  90239. * @param parser Defines the parser to add
  90240. */
  90241. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90242. /**
  90243. * Gets an individual parser from the list of avaialble ones
  90244. * @param name Defines the name of the parser
  90245. * @returns the requested parser or null
  90246. */
  90247. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90248. /**
  90249. * Parser json data and populate both a scene and its associated container object
  90250. * @param jsonData Defines the data to parse
  90251. * @param scene Defines the scene to parse the data for
  90252. * @param container Defines the container attached to the parsing sequence
  90253. * @param rootUrl Defines the root url of the data
  90254. */
  90255. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90256. /**
  90257. * Gets the list of root nodes (ie. nodes with no parent)
  90258. */
  90259. rootNodes: Node[];
  90260. /** All of the cameras added to this scene
  90261. * @see http://doc.babylonjs.com/babylon101/cameras
  90262. */
  90263. cameras: Camera[];
  90264. /**
  90265. * All of the lights added to this scene
  90266. * @see http://doc.babylonjs.com/babylon101/lights
  90267. */
  90268. lights: Light[];
  90269. /**
  90270. * All of the (abstract) meshes added to this scene
  90271. */
  90272. meshes: AbstractMesh[];
  90273. /**
  90274. * The list of skeletons added to the scene
  90275. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90276. */
  90277. skeletons: Skeleton[];
  90278. /**
  90279. * All of the particle systems added to this scene
  90280. * @see http://doc.babylonjs.com/babylon101/particles
  90281. */
  90282. particleSystems: IParticleSystem[];
  90283. /**
  90284. * Gets a list of Animations associated with the scene
  90285. */
  90286. animations: Animation[];
  90287. /**
  90288. * All of the animation groups added to this scene
  90289. * @see http://doc.babylonjs.com/how_to/group
  90290. */
  90291. animationGroups: AnimationGroup[];
  90292. /**
  90293. * All of the multi-materials added to this scene
  90294. * @see http://doc.babylonjs.com/how_to/multi_materials
  90295. */
  90296. multiMaterials: MultiMaterial[];
  90297. /**
  90298. * All of the materials added to this scene
  90299. * In the context of a Scene, it is not supposed to be modified manually.
  90300. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90301. * Note also that the order of the Material wihin the array is not significant and might change.
  90302. * @see http://doc.babylonjs.com/babylon101/materials
  90303. */
  90304. materials: Material[];
  90305. /**
  90306. * The list of morph target managers added to the scene
  90307. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90308. */
  90309. morphTargetManagers: MorphTargetManager[];
  90310. /**
  90311. * The list of geometries used in the scene.
  90312. */
  90313. geometries: Geometry[];
  90314. /**
  90315. * All of the tranform nodes added to this scene
  90316. * In the context of a Scene, it is not supposed to be modified manually.
  90317. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90318. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90319. * @see http://doc.babylonjs.com/how_to/transformnode
  90320. */
  90321. transformNodes: TransformNode[];
  90322. /**
  90323. * ActionManagers available on the scene.
  90324. */
  90325. actionManagers: AbstractActionManager[];
  90326. /**
  90327. * Textures to keep.
  90328. */
  90329. textures: BaseTexture[];
  90330. }
  90331. }
  90332. declare module BABYLON {
  90333. /**
  90334. * Defines a sound that can be played in the application.
  90335. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90337. */
  90338. export class Sound {
  90339. /**
  90340. * The name of the sound in the scene.
  90341. */
  90342. name: string;
  90343. /**
  90344. * Does the sound autoplay once loaded.
  90345. */
  90346. autoplay: boolean;
  90347. /**
  90348. * Does the sound loop after it finishes playing once.
  90349. */
  90350. loop: boolean;
  90351. /**
  90352. * Does the sound use a custom attenuation curve to simulate the falloff
  90353. * happening when the source gets further away from the camera.
  90354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90355. */
  90356. useCustomAttenuation: boolean;
  90357. /**
  90358. * The sound track id this sound belongs to.
  90359. */
  90360. soundTrackId: number;
  90361. /**
  90362. * Is this sound currently played.
  90363. */
  90364. isPlaying: boolean;
  90365. /**
  90366. * Is this sound currently paused.
  90367. */
  90368. isPaused: boolean;
  90369. /**
  90370. * Does this sound enables spatial sound.
  90371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90372. */
  90373. spatialSound: boolean;
  90374. /**
  90375. * Define the reference distance the sound should be heard perfectly.
  90376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90377. */
  90378. refDistance: number;
  90379. /**
  90380. * Define the roll off factor of spatial sounds.
  90381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90382. */
  90383. rolloffFactor: number;
  90384. /**
  90385. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90387. */
  90388. maxDistance: number;
  90389. /**
  90390. * Define the distance attenuation model the sound will follow.
  90391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90392. */
  90393. distanceModel: string;
  90394. /**
  90395. * @hidden
  90396. * Back Compat
  90397. **/
  90398. onended: () => any;
  90399. /**
  90400. * Observable event when the current playing sound finishes.
  90401. */
  90402. onEndedObservable: Observable<Sound>;
  90403. private _panningModel;
  90404. private _playbackRate;
  90405. private _streaming;
  90406. private _startTime;
  90407. private _startOffset;
  90408. private _position;
  90409. /** @hidden */
  90410. _positionInEmitterSpace: boolean;
  90411. private _localDirection;
  90412. private _volume;
  90413. private _isReadyToPlay;
  90414. private _isDirectional;
  90415. private _readyToPlayCallback;
  90416. private _audioBuffer;
  90417. private _soundSource;
  90418. private _streamingSource;
  90419. private _soundPanner;
  90420. private _soundGain;
  90421. private _inputAudioNode;
  90422. private _outputAudioNode;
  90423. private _coneInnerAngle;
  90424. private _coneOuterAngle;
  90425. private _coneOuterGain;
  90426. private _scene;
  90427. private _connectedTransformNode;
  90428. private _customAttenuationFunction;
  90429. private _registerFunc;
  90430. private _isOutputConnected;
  90431. private _htmlAudioElement;
  90432. private _urlType;
  90433. /** @hidden */
  90434. static _SceneComponentInitialization: (scene: Scene) => void;
  90435. /**
  90436. * Create a sound and attach it to a scene
  90437. * @param name Name of your sound
  90438. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90439. * @param scene defines the scene the sound belongs to
  90440. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90441. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90442. */
  90443. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90444. /**
  90445. * Release the sound and its associated resources
  90446. */
  90447. dispose(): void;
  90448. /**
  90449. * Gets if the sounds is ready to be played or not.
  90450. * @returns true if ready, otherwise false
  90451. */
  90452. isReady(): boolean;
  90453. private _soundLoaded;
  90454. /**
  90455. * Sets the data of the sound from an audiobuffer
  90456. * @param audioBuffer The audioBuffer containing the data
  90457. */
  90458. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90459. /**
  90460. * Updates the current sounds options such as maxdistance, loop...
  90461. * @param options A JSON object containing values named as the object properties
  90462. */
  90463. updateOptions(options: any): void;
  90464. private _createSpatialParameters;
  90465. private _updateSpatialParameters;
  90466. /**
  90467. * Switch the panning model to HRTF:
  90468. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90469. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90470. */
  90471. switchPanningModelToHRTF(): void;
  90472. /**
  90473. * Switch the panning model to Equal Power:
  90474. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90476. */
  90477. switchPanningModelToEqualPower(): void;
  90478. private _switchPanningModel;
  90479. /**
  90480. * Connect this sound to a sound track audio node like gain...
  90481. * @param soundTrackAudioNode the sound track audio node to connect to
  90482. */
  90483. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90484. /**
  90485. * Transform this sound into a directional source
  90486. * @param coneInnerAngle Size of the inner cone in degree
  90487. * @param coneOuterAngle Size of the outer cone in degree
  90488. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90489. */
  90490. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90491. /**
  90492. * Gets or sets the inner angle for the directional cone.
  90493. */
  90494. /**
  90495. * Gets or sets the inner angle for the directional cone.
  90496. */
  90497. directionalConeInnerAngle: number;
  90498. /**
  90499. * Gets or sets the outer angle for the directional cone.
  90500. */
  90501. /**
  90502. * Gets or sets the outer angle for the directional cone.
  90503. */
  90504. directionalConeOuterAngle: number;
  90505. /**
  90506. * Sets the position of the emitter if spatial sound is enabled
  90507. * @param newPosition Defines the new posisiton
  90508. */
  90509. setPosition(newPosition: Vector3): void;
  90510. /**
  90511. * Sets the local direction of the emitter if spatial sound is enabled
  90512. * @param newLocalDirection Defines the new local direction
  90513. */
  90514. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  90515. private _updateDirection;
  90516. /** @hidden */
  90517. updateDistanceFromListener(): void;
  90518. /**
  90519. * Sets a new custom attenuation function for the sound.
  90520. * @param callback Defines the function used for the attenuation
  90521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90522. */
  90523. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90524. /**
  90525. * Play the sound
  90526. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90527. * @param offset (optional) Start the sound setting it at a specific time
  90528. */
  90529. play(time?: number, offset?: number): void;
  90530. private _onended;
  90531. /**
  90532. * Stop the sound
  90533. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90534. */
  90535. stop(time?: number): void;
  90536. /**
  90537. * Put the sound in pause
  90538. */
  90539. pause(): void;
  90540. /**
  90541. * Sets a dedicated volume for this sounds
  90542. * @param newVolume Define the new volume of the sound
  90543. * @param time Define in how long the sound should be at this value
  90544. */
  90545. setVolume(newVolume: number, time?: number): void;
  90546. /**
  90547. * Set the sound play back rate
  90548. * @param newPlaybackRate Define the playback rate the sound should be played at
  90549. */
  90550. setPlaybackRate(newPlaybackRate: number): void;
  90551. /**
  90552. * Gets the volume of the sound.
  90553. * @returns the volume of the sound
  90554. */
  90555. getVolume(): number;
  90556. /**
  90557. * Attach the sound to a dedicated mesh
  90558. * @param transformNode The transform node to connect the sound with
  90559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90560. */
  90561. attachToMesh(transformNode: TransformNode): void;
  90562. /**
  90563. * Detach the sound from the previously attached mesh
  90564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90565. */
  90566. detachFromMesh(): void;
  90567. private _onRegisterAfterWorldMatrixUpdate;
  90568. /**
  90569. * Clone the current sound in the scene.
  90570. * @returns the new sound clone
  90571. */
  90572. clone(): Nullable<Sound>;
  90573. /**
  90574. * Gets the current underlying audio buffer containing the data
  90575. * @returns the audio buffer
  90576. */
  90577. getAudioBuffer(): Nullable<AudioBuffer>;
  90578. /**
  90579. * Serializes the Sound in a JSON representation
  90580. * @returns the JSON representation of the sound
  90581. */
  90582. serialize(): any;
  90583. /**
  90584. * Parse a JSON representation of a sound to innstantiate in a given scene
  90585. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90586. * @param scene Define the scene the new parsed sound should be created in
  90587. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90588. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90589. * @returns the newly parsed sound
  90590. */
  90591. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90592. }
  90593. }
  90594. declare module BABYLON {
  90595. /**
  90596. * This defines an action helpful to play a defined sound on a triggered action.
  90597. */
  90598. export class PlaySoundAction extends Action {
  90599. private _sound;
  90600. /**
  90601. * Instantiate the action
  90602. * @param triggerOptions defines the trigger options
  90603. * @param sound defines the sound to play
  90604. * @param condition defines the trigger related conditions
  90605. */
  90606. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90607. /** @hidden */
  90608. _prepare(): void;
  90609. /**
  90610. * Execute the action and play the sound.
  90611. */
  90612. execute(): void;
  90613. /**
  90614. * Serializes the actions and its related information.
  90615. * @param parent defines the object to serialize in
  90616. * @returns the serialized object
  90617. */
  90618. serialize(parent: any): any;
  90619. }
  90620. /**
  90621. * This defines an action helpful to stop a defined sound on a triggered action.
  90622. */
  90623. export class StopSoundAction extends Action {
  90624. private _sound;
  90625. /**
  90626. * Instantiate the action
  90627. * @param triggerOptions defines the trigger options
  90628. * @param sound defines the sound to stop
  90629. * @param condition defines the trigger related conditions
  90630. */
  90631. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90632. /** @hidden */
  90633. _prepare(): void;
  90634. /**
  90635. * Execute the action and stop the sound.
  90636. */
  90637. execute(): void;
  90638. /**
  90639. * Serializes the actions and its related information.
  90640. * @param parent defines the object to serialize in
  90641. * @returns the serialized object
  90642. */
  90643. serialize(parent: any): any;
  90644. }
  90645. }
  90646. declare module BABYLON {
  90647. /**
  90648. * This defines an action responsible to change the value of a property
  90649. * by interpolating between its current value and the newly set one once triggered.
  90650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90651. */
  90652. export class InterpolateValueAction extends Action {
  90653. /**
  90654. * Defines the path of the property where the value should be interpolated
  90655. */
  90656. propertyPath: string;
  90657. /**
  90658. * Defines the target value at the end of the interpolation.
  90659. */
  90660. value: any;
  90661. /**
  90662. * Defines the time it will take for the property to interpolate to the value.
  90663. */
  90664. duration: number;
  90665. /**
  90666. * Defines if the other scene animations should be stopped when the action has been triggered
  90667. */
  90668. stopOtherAnimations?: boolean;
  90669. /**
  90670. * Defines a callback raised once the interpolation animation has been done.
  90671. */
  90672. onInterpolationDone?: () => void;
  90673. /**
  90674. * Observable triggered once the interpolation animation has been done.
  90675. */
  90676. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90677. private _target;
  90678. private _effectiveTarget;
  90679. private _property;
  90680. /**
  90681. * Instantiate the action
  90682. * @param triggerOptions defines the trigger options
  90683. * @param target defines the object containing the value to interpolate
  90684. * @param propertyPath defines the path to the property in the target object
  90685. * @param value defines the target value at the end of the interpolation
  90686. * @param duration deines the time it will take for the property to interpolate to the value.
  90687. * @param condition defines the trigger related conditions
  90688. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90689. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90690. */
  90691. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90692. /** @hidden */
  90693. _prepare(): void;
  90694. /**
  90695. * Execute the action starts the value interpolation.
  90696. */
  90697. execute(): void;
  90698. /**
  90699. * Serializes the actions and its related information.
  90700. * @param parent defines the object to serialize in
  90701. * @returns the serialized object
  90702. */
  90703. serialize(parent: any): any;
  90704. }
  90705. }
  90706. declare module BABYLON {
  90707. /**
  90708. * Options allowed during the creation of a sound track.
  90709. */
  90710. export interface ISoundTrackOptions {
  90711. /**
  90712. * The volume the sound track should take during creation
  90713. */
  90714. volume?: number;
  90715. /**
  90716. * Define if the sound track is the main sound track of the scene
  90717. */
  90718. mainTrack?: boolean;
  90719. }
  90720. /**
  90721. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  90722. * It will be also used in a future release to apply effects on a specific track.
  90723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90724. */
  90725. export class SoundTrack {
  90726. /**
  90727. * The unique identifier of the sound track in the scene.
  90728. */
  90729. id: number;
  90730. /**
  90731. * The list of sounds included in the sound track.
  90732. */
  90733. soundCollection: Array<Sound>;
  90734. private _outputAudioNode;
  90735. private _scene;
  90736. private _isMainTrack;
  90737. private _connectedAnalyser;
  90738. private _options;
  90739. private _isInitialized;
  90740. /**
  90741. * Creates a new sound track.
  90742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90743. * @param scene Define the scene the sound track belongs to
  90744. * @param options
  90745. */
  90746. constructor(scene: Scene, options?: ISoundTrackOptions);
  90747. private _initializeSoundTrackAudioGraph;
  90748. /**
  90749. * Release the sound track and its associated resources
  90750. */
  90751. dispose(): void;
  90752. /**
  90753. * Adds a sound to this sound track
  90754. * @param sound define the cound to add
  90755. * @ignoreNaming
  90756. */
  90757. AddSound(sound: Sound): void;
  90758. /**
  90759. * Removes a sound to this sound track
  90760. * @param sound define the cound to remove
  90761. * @ignoreNaming
  90762. */
  90763. RemoveSound(sound: Sound): void;
  90764. /**
  90765. * Set a global volume for the full sound track.
  90766. * @param newVolume Define the new volume of the sound track
  90767. */
  90768. setVolume(newVolume: number): void;
  90769. /**
  90770. * Switch the panning model to HRTF:
  90771. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90773. */
  90774. switchPanningModelToHRTF(): void;
  90775. /**
  90776. * Switch the panning model to Equal Power:
  90777. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90779. */
  90780. switchPanningModelToEqualPower(): void;
  90781. /**
  90782. * Connect the sound track to an audio analyser allowing some amazing
  90783. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90785. * @param analyser The analyser to connect to the engine
  90786. */
  90787. connectToAnalyser(analyser: Analyser): void;
  90788. }
  90789. }
  90790. declare module BABYLON {
  90791. interface AbstractScene {
  90792. /**
  90793. * The list of sounds used in the scene.
  90794. */
  90795. sounds: Nullable<Array<Sound>>;
  90796. }
  90797. interface Scene {
  90798. /**
  90799. * @hidden
  90800. * Backing field
  90801. */
  90802. _mainSoundTrack: SoundTrack;
  90803. /**
  90804. * The main sound track played by the scene.
  90805. * It cotains your primary collection of sounds.
  90806. */
  90807. mainSoundTrack: SoundTrack;
  90808. /**
  90809. * The list of sound tracks added to the scene
  90810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90811. */
  90812. soundTracks: Nullable<Array<SoundTrack>>;
  90813. /**
  90814. * Gets a sound using a given name
  90815. * @param name defines the name to search for
  90816. * @return the found sound or null if not found at all.
  90817. */
  90818. getSoundByName(name: string): Nullable<Sound>;
  90819. /**
  90820. * Gets or sets if audio support is enabled
  90821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90822. */
  90823. audioEnabled: boolean;
  90824. /**
  90825. * Gets or sets if audio will be output to headphones
  90826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90827. */
  90828. headphone: boolean;
  90829. }
  90830. /**
  90831. * Defines the sound scene component responsible to manage any sounds
  90832. * in a given scene.
  90833. */
  90834. export class AudioSceneComponent implements ISceneSerializableComponent {
  90835. /**
  90836. * The component name helpfull to identify the component in the list of scene components.
  90837. */
  90838. readonly name: string;
  90839. /**
  90840. * The scene the component belongs to.
  90841. */
  90842. scene: Scene;
  90843. private _audioEnabled;
  90844. /**
  90845. * Gets whether audio is enabled or not.
  90846. * Please use related enable/disable method to switch state.
  90847. */
  90848. readonly audioEnabled: boolean;
  90849. private _headphone;
  90850. /**
  90851. * Gets whether audio is outputing to headphone or not.
  90852. * Please use the according Switch methods to change output.
  90853. */
  90854. readonly headphone: boolean;
  90855. /**
  90856. * Creates a new instance of the component for the given scene
  90857. * @param scene Defines the scene to register the component in
  90858. */
  90859. constructor(scene: Scene);
  90860. /**
  90861. * Registers the component in a given scene
  90862. */
  90863. register(): void;
  90864. /**
  90865. * Rebuilds the elements related to this component in case of
  90866. * context lost for instance.
  90867. */
  90868. rebuild(): void;
  90869. /**
  90870. * Serializes the component data to the specified json object
  90871. * @param serializationObject The object to serialize to
  90872. */
  90873. serialize(serializationObject: any): void;
  90874. /**
  90875. * Adds all the element from the container to the scene
  90876. * @param container the container holding the elements
  90877. */
  90878. addFromContainer(container: AbstractScene): void;
  90879. /**
  90880. * Removes all the elements in the container from the scene
  90881. * @param container contains the elements to remove
  90882. */
  90883. removeFromContainer(container: AbstractScene): void;
  90884. /**
  90885. * Disposes the component and the associated ressources.
  90886. */
  90887. dispose(): void;
  90888. /**
  90889. * Disables audio in the associated scene.
  90890. */
  90891. disableAudio(): void;
  90892. /**
  90893. * Enables audio in the associated scene.
  90894. */
  90895. enableAudio(): void;
  90896. /**
  90897. * Switch audio to headphone output.
  90898. */
  90899. switchAudioModeForHeadphones(): void;
  90900. /**
  90901. * Switch audio to normal speakers.
  90902. */
  90903. switchAudioModeForNormalSpeakers(): void;
  90904. private _afterRender;
  90905. }
  90906. }
  90907. declare module BABYLON {
  90908. /**
  90909. * Wraps one or more Sound objects and selects one with random weight for playback.
  90910. */
  90911. export class WeightedSound {
  90912. /** When true a Sound will be selected and played when the current playing Sound completes. */
  90913. loop: boolean;
  90914. private _coneInnerAngle;
  90915. private _coneOuterAngle;
  90916. private _volume;
  90917. /** A Sound is currently playing. */
  90918. isPlaying: boolean;
  90919. /** A Sound is currently paused. */
  90920. isPaused: boolean;
  90921. private _sounds;
  90922. private _weights;
  90923. private _currentIndex?;
  90924. /**
  90925. * Creates a new WeightedSound from the list of sounds given.
  90926. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  90927. * @param sounds Array of Sounds that will be selected from.
  90928. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  90929. */
  90930. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  90931. /**
  90932. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  90933. */
  90934. /**
  90935. * The size of cone in degress for a directional sound in which there will be no attenuation.
  90936. */
  90937. directionalConeInnerAngle: number;
  90938. /**
  90939. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90940. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90941. */
  90942. /**
  90943. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90944. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90945. */
  90946. directionalConeOuterAngle: number;
  90947. /**
  90948. * Playback volume.
  90949. */
  90950. /**
  90951. * Playback volume.
  90952. */
  90953. volume: number;
  90954. private _onended;
  90955. /**
  90956. * Suspend playback
  90957. */
  90958. pause(): void;
  90959. /**
  90960. * Stop playback
  90961. */
  90962. stop(): void;
  90963. /**
  90964. * Start playback.
  90965. * @param startOffset Position the clip head at a specific time in seconds.
  90966. */
  90967. play(startOffset?: number): void;
  90968. }
  90969. }
  90970. declare module BABYLON {
  90971. /**
  90972. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  90973. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90974. */
  90975. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  90976. /**
  90977. * Gets the name of the behavior.
  90978. */
  90979. readonly name: string;
  90980. /**
  90981. * The easing function used by animations
  90982. */
  90983. static EasingFunction: BackEase;
  90984. /**
  90985. * The easing mode used by animations
  90986. */
  90987. static EasingMode: number;
  90988. /**
  90989. * The duration of the animation, in milliseconds
  90990. */
  90991. transitionDuration: number;
  90992. /**
  90993. * Length of the distance animated by the transition when lower radius is reached
  90994. */
  90995. lowerRadiusTransitionRange: number;
  90996. /**
  90997. * Length of the distance animated by the transition when upper radius is reached
  90998. */
  90999. upperRadiusTransitionRange: number;
  91000. private _autoTransitionRange;
  91001. /**
  91002. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91003. */
  91004. /**
  91005. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91006. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91007. */
  91008. autoTransitionRange: boolean;
  91009. private _attachedCamera;
  91010. private _onAfterCheckInputsObserver;
  91011. private _onMeshTargetChangedObserver;
  91012. /**
  91013. * Initializes the behavior.
  91014. */
  91015. init(): void;
  91016. /**
  91017. * Attaches the behavior to its arc rotate camera.
  91018. * @param camera Defines the camera to attach the behavior to
  91019. */
  91020. attach(camera: ArcRotateCamera): void;
  91021. /**
  91022. * Detaches the behavior from its current arc rotate camera.
  91023. */
  91024. detach(): void;
  91025. private _radiusIsAnimating;
  91026. private _radiusBounceTransition;
  91027. private _animatables;
  91028. private _cachedWheelPrecision;
  91029. /**
  91030. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91031. * @param radiusLimit The limit to check against.
  91032. * @return Bool to indicate if at limit.
  91033. */
  91034. private _isRadiusAtLimit;
  91035. /**
  91036. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91037. * @param radiusDelta The delta by which to animate to. Can be negative.
  91038. */
  91039. private _applyBoundRadiusAnimation;
  91040. /**
  91041. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91042. */
  91043. protected _clearAnimationLocks(): void;
  91044. /**
  91045. * Stops and removes all animations that have been applied to the camera
  91046. */
  91047. stopAllAnimations(): void;
  91048. }
  91049. }
  91050. declare module BABYLON {
  91051. /**
  91052. * 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.
  91053. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91054. */
  91055. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91056. /**
  91057. * Gets the name of the behavior.
  91058. */
  91059. readonly name: string;
  91060. private _mode;
  91061. private _radiusScale;
  91062. private _positionScale;
  91063. private _defaultElevation;
  91064. private _elevationReturnTime;
  91065. private _elevationReturnWaitTime;
  91066. private _zoomStopsAnimation;
  91067. private _framingTime;
  91068. /**
  91069. * The easing function used by animations
  91070. */
  91071. static EasingFunction: ExponentialEase;
  91072. /**
  91073. * The easing mode used by animations
  91074. */
  91075. static EasingMode: number;
  91076. /**
  91077. * Sets the current mode used by the behavior
  91078. */
  91079. /**
  91080. * Gets current mode used by the behavior.
  91081. */
  91082. mode: number;
  91083. /**
  91084. * Sets the scale applied to the radius (1 by default)
  91085. */
  91086. /**
  91087. * Gets the scale applied to the radius
  91088. */
  91089. radiusScale: number;
  91090. /**
  91091. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91092. */
  91093. /**
  91094. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91095. */
  91096. positionScale: number;
  91097. /**
  91098. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91099. * behaviour is triggered, in radians.
  91100. */
  91101. /**
  91102. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91103. * behaviour is triggered, in radians.
  91104. */
  91105. defaultElevation: number;
  91106. /**
  91107. * Sets the time (in milliseconds) taken to return to the default beta position.
  91108. * Negative value indicates camera should not return to default.
  91109. */
  91110. /**
  91111. * Gets the time (in milliseconds) taken to return to the default beta position.
  91112. * Negative value indicates camera should not return to default.
  91113. */
  91114. elevationReturnTime: number;
  91115. /**
  91116. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91117. */
  91118. /**
  91119. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91120. */
  91121. elevationReturnWaitTime: number;
  91122. /**
  91123. * Sets the flag that indicates if user zooming should stop animation.
  91124. */
  91125. /**
  91126. * Gets the flag that indicates if user zooming should stop animation.
  91127. */
  91128. zoomStopsAnimation: boolean;
  91129. /**
  91130. * Sets the transition time when framing the mesh, in milliseconds
  91131. */
  91132. /**
  91133. * Gets the transition time when framing the mesh, in milliseconds
  91134. */
  91135. framingTime: number;
  91136. /**
  91137. * Define if the behavior should automatically change the configured
  91138. * camera limits and sensibilities.
  91139. */
  91140. autoCorrectCameraLimitsAndSensibility: boolean;
  91141. private _onPrePointerObservableObserver;
  91142. private _onAfterCheckInputsObserver;
  91143. private _onMeshTargetChangedObserver;
  91144. private _attachedCamera;
  91145. private _isPointerDown;
  91146. private _lastInteractionTime;
  91147. /**
  91148. * Initializes the behavior.
  91149. */
  91150. init(): void;
  91151. /**
  91152. * Attaches the behavior to its arc rotate camera.
  91153. * @param camera Defines the camera to attach the behavior to
  91154. */
  91155. attach(camera: ArcRotateCamera): void;
  91156. /**
  91157. * Detaches the behavior from its current arc rotate camera.
  91158. */
  91159. detach(): void;
  91160. private _animatables;
  91161. private _betaIsAnimating;
  91162. private _betaTransition;
  91163. private _radiusTransition;
  91164. private _vectorTransition;
  91165. /**
  91166. * Targets the given mesh and updates zoom level accordingly.
  91167. * @param mesh The mesh to target.
  91168. * @param radius Optional. If a cached radius position already exists, overrides default.
  91169. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91170. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91171. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91172. */
  91173. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91174. /**
  91175. * Targets the given mesh with its children and updates zoom level accordingly.
  91176. * @param mesh The mesh to target.
  91177. * @param radius Optional. If a cached radius position already exists, overrides default.
  91178. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91179. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91180. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91181. */
  91182. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91183. /**
  91184. * Targets the given meshes with their children and updates zoom level accordingly.
  91185. * @param meshes The mesh to target.
  91186. * @param radius Optional. If a cached radius position already exists, overrides default.
  91187. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91188. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91189. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91190. */
  91191. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91192. /**
  91193. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91194. * @param minimumWorld Determines the smaller position of the bounding box extend
  91195. * @param maximumWorld Determines the bigger position of the bounding box extend
  91196. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91197. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91198. */
  91199. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91200. /**
  91201. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91202. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91203. * frustum width.
  91204. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91205. * to fully enclose the mesh in the viewing frustum.
  91206. */
  91207. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91208. /**
  91209. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91210. * is automatically returned to its default position (expected to be above ground plane).
  91211. */
  91212. private _maintainCameraAboveGround;
  91213. /**
  91214. * Returns the frustum slope based on the canvas ratio and camera FOV
  91215. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91216. */
  91217. private _getFrustumSlope;
  91218. /**
  91219. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91220. */
  91221. private _clearAnimationLocks;
  91222. /**
  91223. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91224. */
  91225. private _applyUserInteraction;
  91226. /**
  91227. * Stops and removes all animations that have been applied to the camera
  91228. */
  91229. stopAllAnimations(): void;
  91230. /**
  91231. * Gets a value indicating if the user is moving the camera
  91232. */
  91233. readonly isUserIsMoving: boolean;
  91234. /**
  91235. * The camera can move all the way towards the mesh.
  91236. */
  91237. static IgnoreBoundsSizeMode: number;
  91238. /**
  91239. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91240. */
  91241. static FitFrustumSidesMode: number;
  91242. }
  91243. }
  91244. declare module BABYLON {
  91245. /**
  91246. * Base class for Camera Pointer Inputs.
  91247. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91248. * for example usage.
  91249. */
  91250. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91251. /**
  91252. * Defines the camera the input is attached to.
  91253. */
  91254. abstract camera: Camera;
  91255. /**
  91256. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91257. */
  91258. protected _altKey: boolean;
  91259. protected _ctrlKey: boolean;
  91260. protected _metaKey: boolean;
  91261. protected _shiftKey: boolean;
  91262. /**
  91263. * Which mouse buttons were pressed at time of last mouse event.
  91264. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91265. */
  91266. protected _buttonsPressed: number;
  91267. /**
  91268. * Defines the buttons associated with the input to handle camera move.
  91269. */
  91270. buttons: number[];
  91271. /**
  91272. * Attach the input controls to a specific dom element to get the input from.
  91273. * @param element Defines the element the controls should be listened from
  91274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91275. */
  91276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91277. /**
  91278. * Detach the current controls from the specified dom element.
  91279. * @param element Defines the element to stop listening the inputs from
  91280. */
  91281. detachControl(element: Nullable<HTMLElement>): void;
  91282. /**
  91283. * Gets the class name of the current input.
  91284. * @returns the class name
  91285. */
  91286. getClassName(): string;
  91287. /**
  91288. * Get the friendly name associated with the input class.
  91289. * @returns the input friendly name
  91290. */
  91291. getSimpleName(): string;
  91292. /**
  91293. * Called on pointer POINTERDOUBLETAP event.
  91294. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91295. */
  91296. protected onDoubleTap(type: string): void;
  91297. /**
  91298. * Called on pointer POINTERMOVE event if only a single touch is active.
  91299. * Override this method to provide functionality.
  91300. */
  91301. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91302. /**
  91303. * Called on pointer POINTERMOVE event if multiple touches are active.
  91304. * Override this method to provide functionality.
  91305. */
  91306. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91307. /**
  91308. * Called on JS contextmenu event.
  91309. * Override this method to provide functionality.
  91310. */
  91311. protected onContextMenu(evt: PointerEvent): void;
  91312. /**
  91313. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91314. * press.
  91315. * Override this method to provide functionality.
  91316. */
  91317. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91318. /**
  91319. * Called each time a new POINTERUP event occurs. Ie, for each button
  91320. * release.
  91321. * Override this method to provide functionality.
  91322. */
  91323. protected onButtonUp(evt: PointerEvent): void;
  91324. /**
  91325. * Called when window becomes inactive.
  91326. * Override this method to provide functionality.
  91327. */
  91328. protected onLostFocus(): void;
  91329. private _pointerInput;
  91330. private _observer;
  91331. private _onLostFocus;
  91332. }
  91333. }
  91334. declare module BABYLON {
  91335. /**
  91336. * Manage the pointers inputs to control an arc rotate camera.
  91337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91338. */
  91339. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91340. /**
  91341. * Defines the camera the input is attached to.
  91342. */
  91343. camera: ArcRotateCamera;
  91344. /**
  91345. * Gets the class name of the current input.
  91346. * @returns the class name
  91347. */
  91348. getClassName(): string;
  91349. /**
  91350. * Defines the buttons associated with the input to handle camera move.
  91351. */
  91352. buttons: number[];
  91353. /**
  91354. * Defines the pointer angular sensibility along the X axis or how fast is
  91355. * the camera rotating.
  91356. */
  91357. angularSensibilityX: number;
  91358. /**
  91359. * Defines the pointer angular sensibility along the Y axis or how fast is
  91360. * the camera rotating.
  91361. */
  91362. angularSensibilityY: number;
  91363. /**
  91364. * Defines the pointer pinch precision or how fast is the camera zooming.
  91365. */
  91366. pinchPrecision: number;
  91367. /**
  91368. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91369. * from 0.
  91370. * It defines the percentage of current camera.radius to use as delta when
  91371. * pinch zoom is used.
  91372. */
  91373. pinchDeltaPercentage: number;
  91374. /**
  91375. * Defines the pointer panning sensibility or how fast is the camera moving.
  91376. */
  91377. panningSensibility: number;
  91378. /**
  91379. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91380. */
  91381. multiTouchPanning: boolean;
  91382. /**
  91383. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91384. * zoom (pinch) through multitouch.
  91385. */
  91386. multiTouchPanAndZoom: boolean;
  91387. /**
  91388. * Revers pinch action direction.
  91389. */
  91390. pinchInwards: boolean;
  91391. private _isPanClick;
  91392. private _twoFingerActivityCount;
  91393. private _isPinching;
  91394. /**
  91395. * Called on pointer POINTERMOVE event if only a single touch is active.
  91396. */
  91397. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91398. /**
  91399. * Called on pointer POINTERDOUBLETAP event.
  91400. */
  91401. protected onDoubleTap(type: string): void;
  91402. /**
  91403. * Called on pointer POINTERMOVE event if multiple touches are active.
  91404. */
  91405. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91406. /**
  91407. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91408. * press.
  91409. */
  91410. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91411. /**
  91412. * Called each time a new POINTERUP event occurs. Ie, for each button
  91413. * release.
  91414. */
  91415. protected onButtonUp(evt: PointerEvent): void;
  91416. /**
  91417. * Called when window becomes inactive.
  91418. */
  91419. protected onLostFocus(): void;
  91420. }
  91421. }
  91422. declare module BABYLON {
  91423. /**
  91424. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91426. */
  91427. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91428. /**
  91429. * Defines the camera the input is attached to.
  91430. */
  91431. camera: ArcRotateCamera;
  91432. /**
  91433. * Defines the list of key codes associated with the up action (increase alpha)
  91434. */
  91435. keysUp: number[];
  91436. /**
  91437. * Defines the list of key codes associated with the down action (decrease alpha)
  91438. */
  91439. keysDown: number[];
  91440. /**
  91441. * Defines the list of key codes associated with the left action (increase beta)
  91442. */
  91443. keysLeft: number[];
  91444. /**
  91445. * Defines the list of key codes associated with the right action (decrease beta)
  91446. */
  91447. keysRight: number[];
  91448. /**
  91449. * Defines the list of key codes associated with the reset action.
  91450. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91451. */
  91452. keysReset: number[];
  91453. /**
  91454. * Defines the panning sensibility of the inputs.
  91455. * (How fast is the camera paning)
  91456. */
  91457. panningSensibility: number;
  91458. /**
  91459. * Defines the zooming sensibility of the inputs.
  91460. * (How fast is the camera zooming)
  91461. */
  91462. zoomingSensibility: number;
  91463. /**
  91464. * Defines wether maintaining the alt key down switch the movement mode from
  91465. * orientation to zoom.
  91466. */
  91467. useAltToZoom: boolean;
  91468. /**
  91469. * Rotation speed of the camera
  91470. */
  91471. angularSpeed: number;
  91472. private _keys;
  91473. private _ctrlPressed;
  91474. private _altPressed;
  91475. private _onCanvasBlurObserver;
  91476. private _onKeyboardObserver;
  91477. private _engine;
  91478. private _scene;
  91479. /**
  91480. * Attach the input controls to a specific dom element to get the input from.
  91481. * @param element Defines the element the controls should be listened from
  91482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91483. */
  91484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91485. /**
  91486. * Detach the current controls from the specified dom element.
  91487. * @param element Defines the element to stop listening the inputs from
  91488. */
  91489. detachControl(element: Nullable<HTMLElement>): void;
  91490. /**
  91491. * Update the current camera state depending on the inputs that have been used this frame.
  91492. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91493. */
  91494. checkInputs(): void;
  91495. /**
  91496. * Gets the class name of the current intput.
  91497. * @returns the class name
  91498. */
  91499. getClassName(): string;
  91500. /**
  91501. * Get the friendly name associated with the input class.
  91502. * @returns the input friendly name
  91503. */
  91504. getSimpleName(): string;
  91505. }
  91506. }
  91507. declare module BABYLON {
  91508. /**
  91509. * Manage the mouse wheel inputs to control an arc rotate camera.
  91510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91511. */
  91512. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  91513. /**
  91514. * Defines the camera the input is attached to.
  91515. */
  91516. camera: ArcRotateCamera;
  91517. /**
  91518. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91519. */
  91520. wheelPrecision: number;
  91521. /**
  91522. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  91523. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  91524. */
  91525. wheelDeltaPercentage: number;
  91526. private _wheel;
  91527. private _observer;
  91528. /**
  91529. * Attach the input controls to a specific dom element to get the input from.
  91530. * @param element Defines the element the controls should be listened from
  91531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91532. */
  91533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91534. /**
  91535. * Detach the current controls from the specified dom element.
  91536. * @param element Defines the element to stop listening the inputs from
  91537. */
  91538. detachControl(element: Nullable<HTMLElement>): void;
  91539. /**
  91540. * Gets the class name of the current intput.
  91541. * @returns the class name
  91542. */
  91543. getClassName(): string;
  91544. /**
  91545. * Get the friendly name associated with the input class.
  91546. * @returns the input friendly name
  91547. */
  91548. getSimpleName(): string;
  91549. }
  91550. }
  91551. declare module BABYLON {
  91552. /**
  91553. * Default Inputs manager for the ArcRotateCamera.
  91554. * It groups all the default supported inputs for ease of use.
  91555. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91556. */
  91557. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  91558. /**
  91559. * Instantiates a new ArcRotateCameraInputsManager.
  91560. * @param camera Defines the camera the inputs belong to
  91561. */
  91562. constructor(camera: ArcRotateCamera);
  91563. /**
  91564. * Add mouse wheel input support to the input manager.
  91565. * @returns the current input manager
  91566. */
  91567. addMouseWheel(): ArcRotateCameraInputsManager;
  91568. /**
  91569. * Add pointers input support to the input manager.
  91570. * @returns the current input manager
  91571. */
  91572. addPointers(): ArcRotateCameraInputsManager;
  91573. /**
  91574. * Add keyboard input support to the input manager.
  91575. * @returns the current input manager
  91576. */
  91577. addKeyboard(): ArcRotateCameraInputsManager;
  91578. }
  91579. }
  91580. declare module BABYLON {
  91581. /**
  91582. * This represents an orbital type of camera.
  91583. *
  91584. * 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.
  91585. * 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.
  91586. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  91587. */
  91588. export class ArcRotateCamera extends TargetCamera {
  91589. /**
  91590. * Defines the rotation angle of the camera along the longitudinal axis.
  91591. */
  91592. alpha: number;
  91593. /**
  91594. * Defines the rotation angle of the camera along the latitudinal axis.
  91595. */
  91596. beta: number;
  91597. /**
  91598. * Defines the radius of the camera from it s target point.
  91599. */
  91600. radius: number;
  91601. protected _target: Vector3;
  91602. protected _targetHost: Nullable<AbstractMesh>;
  91603. /**
  91604. * Defines the target point of the camera.
  91605. * The camera looks towards it form the radius distance.
  91606. */
  91607. target: Vector3;
  91608. /**
  91609. * Define the current local position of the camera in the scene
  91610. */
  91611. position: Vector3;
  91612. /**
  91613. * Current inertia value on the longitudinal axis.
  91614. * The bigger this number the longer it will take for the camera to stop.
  91615. */
  91616. inertialAlphaOffset: number;
  91617. /**
  91618. * Current inertia value on the latitudinal axis.
  91619. * The bigger this number the longer it will take for the camera to stop.
  91620. */
  91621. inertialBetaOffset: number;
  91622. /**
  91623. * Current inertia value on the radius axis.
  91624. * The bigger this number the longer it will take for the camera to stop.
  91625. */
  91626. inertialRadiusOffset: number;
  91627. /**
  91628. * Minimum allowed angle on the longitudinal axis.
  91629. * This can help limiting how the Camera is able to move in the scene.
  91630. */
  91631. lowerAlphaLimit: Nullable<number>;
  91632. /**
  91633. * Maximum allowed angle on the longitudinal axis.
  91634. * This can help limiting how the Camera is able to move in the scene.
  91635. */
  91636. upperAlphaLimit: Nullable<number>;
  91637. /**
  91638. * Minimum allowed angle on the latitudinal axis.
  91639. * This can help limiting how the Camera is able to move in the scene.
  91640. */
  91641. lowerBetaLimit: number;
  91642. /**
  91643. * Maximum allowed angle on the latitudinal axis.
  91644. * This can help limiting how the Camera is able to move in the scene.
  91645. */
  91646. upperBetaLimit: number;
  91647. /**
  91648. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91649. * This can help limiting how the Camera is able to move in the scene.
  91650. */
  91651. lowerRadiusLimit: Nullable<number>;
  91652. /**
  91653. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91654. * This can help limiting how the Camera is able to move in the scene.
  91655. */
  91656. upperRadiusLimit: Nullable<number>;
  91657. /**
  91658. * Defines the current inertia value used during panning of the camera along the X axis.
  91659. */
  91660. inertialPanningX: number;
  91661. /**
  91662. * Defines the current inertia value used during panning of the camera along the Y axis.
  91663. */
  91664. inertialPanningY: number;
  91665. /**
  91666. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91667. * Basically if your fingers moves away from more than this distance you will be considered
  91668. * in pinch mode.
  91669. */
  91670. pinchToPanMaxDistance: number;
  91671. /**
  91672. * Defines the maximum distance the camera can pan.
  91673. * This could help keeping the cammera always in your scene.
  91674. */
  91675. panningDistanceLimit: Nullable<number>;
  91676. /**
  91677. * Defines the target of the camera before paning.
  91678. */
  91679. panningOriginTarget: Vector3;
  91680. /**
  91681. * Defines the value of the inertia used during panning.
  91682. * 0 would mean stop inertia and one would mean no decelleration at all.
  91683. */
  91684. panningInertia: number;
  91685. /**
  91686. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91687. */
  91688. angularSensibilityX: number;
  91689. /**
  91690. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91691. */
  91692. angularSensibilityY: number;
  91693. /**
  91694. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91695. */
  91696. pinchPrecision: number;
  91697. /**
  91698. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91699. * It will be used instead of pinchDeltaPrecision if different from 0.
  91700. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91701. */
  91702. pinchDeltaPercentage: number;
  91703. /**
  91704. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  91705. */
  91706. panningSensibility: number;
  91707. /**
  91708. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  91709. */
  91710. keysUp: number[];
  91711. /**
  91712. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  91713. */
  91714. keysDown: number[];
  91715. /**
  91716. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  91717. */
  91718. keysLeft: number[];
  91719. /**
  91720. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  91721. */
  91722. keysRight: number[];
  91723. /**
  91724. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91725. */
  91726. wheelPrecision: number;
  91727. /**
  91728. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  91729. * It will be used instead of pinchDeltaPrecision if different from 0.
  91730. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91731. */
  91732. wheelDeltaPercentage: number;
  91733. /**
  91734. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  91735. */
  91736. zoomOnFactor: number;
  91737. /**
  91738. * Defines a screen offset for the camera position.
  91739. */
  91740. targetScreenOffset: Vector2;
  91741. /**
  91742. * Allows the camera to be completely reversed.
  91743. * If false the camera can not arrive upside down.
  91744. */
  91745. allowUpsideDown: boolean;
  91746. /**
  91747. * Define if double tap/click is used to restore the previously saved state of the camera.
  91748. */
  91749. useInputToRestoreState: boolean;
  91750. /** @hidden */
  91751. _viewMatrix: Matrix;
  91752. /** @hidden */
  91753. _useCtrlForPanning: boolean;
  91754. /** @hidden */
  91755. _panningMouseButton: number;
  91756. /**
  91757. * Defines the input associated to the camera.
  91758. */
  91759. inputs: ArcRotateCameraInputsManager;
  91760. /** @hidden */
  91761. _reset: () => void;
  91762. /**
  91763. * Defines the allowed panning axis.
  91764. */
  91765. panningAxis: Vector3;
  91766. protected _localDirection: Vector3;
  91767. protected _transformedDirection: Vector3;
  91768. private _bouncingBehavior;
  91769. /**
  91770. * Gets the bouncing behavior of the camera if it has been enabled.
  91771. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91772. */
  91773. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  91774. /**
  91775. * Defines if the bouncing behavior of the camera is enabled on the camera.
  91776. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91777. */
  91778. useBouncingBehavior: boolean;
  91779. private _framingBehavior;
  91780. /**
  91781. * Gets the framing behavior of the camera if it has been enabled.
  91782. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91783. */
  91784. readonly framingBehavior: Nullable<FramingBehavior>;
  91785. /**
  91786. * Defines if the framing behavior of the camera is enabled on the camera.
  91787. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91788. */
  91789. useFramingBehavior: boolean;
  91790. private _autoRotationBehavior;
  91791. /**
  91792. * Gets the auto rotation behavior of the camera if it has been enabled.
  91793. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91794. */
  91795. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  91796. /**
  91797. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  91798. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91799. */
  91800. useAutoRotationBehavior: boolean;
  91801. /**
  91802. * Observable triggered when the mesh target has been changed on the camera.
  91803. */
  91804. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  91805. /**
  91806. * Event raised when the camera is colliding with a mesh.
  91807. */
  91808. onCollide: (collidedMesh: AbstractMesh) => void;
  91809. /**
  91810. * Defines whether the camera should check collision with the objects oh the scene.
  91811. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  91812. */
  91813. checkCollisions: boolean;
  91814. /**
  91815. * Defines the collision radius of the camera.
  91816. * This simulates a sphere around the camera.
  91817. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91818. */
  91819. collisionRadius: Vector3;
  91820. protected _collider: Collider;
  91821. protected _previousPosition: Vector3;
  91822. protected _collisionVelocity: Vector3;
  91823. protected _newPosition: Vector3;
  91824. protected _previousAlpha: number;
  91825. protected _previousBeta: number;
  91826. protected _previousRadius: number;
  91827. protected _collisionTriggered: boolean;
  91828. protected _targetBoundingCenter: Nullable<Vector3>;
  91829. private _computationVector;
  91830. private _tempAxisVector;
  91831. private _tempAxisRotationMatrix;
  91832. /**
  91833. * Instantiates a new ArcRotateCamera in a given scene
  91834. * @param name Defines the name of the camera
  91835. * @param alpha Defines the camera rotation along the logitudinal axis
  91836. * @param beta Defines the camera rotation along the latitudinal axis
  91837. * @param radius Defines the camera distance from its target
  91838. * @param target Defines the camera target
  91839. * @param scene Defines the scene the camera belongs to
  91840. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91841. */
  91842. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91843. /** @hidden */
  91844. _initCache(): void;
  91845. /** @hidden */
  91846. _updateCache(ignoreParentClass?: boolean): void;
  91847. protected _getTargetPosition(): Vector3;
  91848. private _storedAlpha;
  91849. private _storedBeta;
  91850. private _storedRadius;
  91851. private _storedTarget;
  91852. /**
  91853. * Stores the current state of the camera (alpha, beta, radius and target)
  91854. * @returns the camera itself
  91855. */
  91856. storeState(): Camera;
  91857. /**
  91858. * @hidden
  91859. * Restored camera state. You must call storeState() first
  91860. */
  91861. _restoreStateValues(): boolean;
  91862. /** @hidden */
  91863. _isSynchronizedViewMatrix(): boolean;
  91864. /**
  91865. * Attached controls to the current camera.
  91866. * @param element Defines the element the controls should be listened from
  91867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91868. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  91869. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  91870. */
  91871. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  91872. /**
  91873. * Detach the current controls from the camera.
  91874. * The camera will stop reacting to inputs.
  91875. * @param element Defines the element to stop listening the inputs from
  91876. */
  91877. detachControl(element: HTMLElement): void;
  91878. /** @hidden */
  91879. _checkInputs(): void;
  91880. protected _checkLimits(): void;
  91881. /**
  91882. * Rebuilds angles (alpha, beta) and radius from the give position and target
  91883. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  91884. */
  91885. rebuildAnglesAndRadius(updateView?: boolean): void;
  91886. /**
  91887. * Use a position to define the current camera related information like aplha, beta and radius
  91888. * @param position Defines the position to set the camera at
  91889. */
  91890. setPosition(position: Vector3): void;
  91891. /**
  91892. * Defines the target the camera should look at.
  91893. * This will automatically adapt alpha beta and radius to fit within the new target.
  91894. * @param target Defines the new target as a Vector or a mesh
  91895. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  91896. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  91897. */
  91898. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  91899. /** @hidden */
  91900. _getViewMatrix(): Matrix;
  91901. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  91902. /**
  91903. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  91904. * @param meshes Defines the mesh to zoom on
  91905. * @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)
  91906. */
  91907. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  91908. /**
  91909. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  91910. * The target will be changed but the radius
  91911. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  91912. * @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)
  91913. */
  91914. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  91915. min: Vector3;
  91916. max: Vector3;
  91917. distance: number;
  91918. }, doNotUpdateMaxZ?: boolean): void;
  91919. /**
  91920. * @override
  91921. * Override Camera.createRigCamera
  91922. */
  91923. createRigCamera(name: string, cameraIndex: number): Camera;
  91924. /**
  91925. * @hidden
  91926. * @override
  91927. * Override Camera._updateRigCameras
  91928. */
  91929. _updateRigCameras(): void;
  91930. /**
  91931. * Destroy the camera and release the current resources hold by it.
  91932. */
  91933. dispose(): void;
  91934. /**
  91935. * Gets the current object class name.
  91936. * @return the class name
  91937. */
  91938. getClassName(): string;
  91939. }
  91940. }
  91941. declare module BABYLON {
  91942. /**
  91943. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  91944. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91945. */
  91946. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  91947. /**
  91948. * Gets the name of the behavior.
  91949. */
  91950. readonly name: string;
  91951. private _zoomStopsAnimation;
  91952. private _idleRotationSpeed;
  91953. private _idleRotationWaitTime;
  91954. private _idleRotationSpinupTime;
  91955. /**
  91956. * Sets the flag that indicates if user zooming should stop animation.
  91957. */
  91958. /**
  91959. * Gets the flag that indicates if user zooming should stop animation.
  91960. */
  91961. zoomStopsAnimation: boolean;
  91962. /**
  91963. * Sets the default speed at which the camera rotates around the model.
  91964. */
  91965. /**
  91966. * Gets the default speed at which the camera rotates around the model.
  91967. */
  91968. idleRotationSpeed: number;
  91969. /**
  91970. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  91971. */
  91972. /**
  91973. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  91974. */
  91975. idleRotationWaitTime: number;
  91976. /**
  91977. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91978. */
  91979. /**
  91980. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91981. */
  91982. idleRotationSpinupTime: number;
  91983. /**
  91984. * Gets a value indicating if the camera is currently rotating because of this behavior
  91985. */
  91986. readonly rotationInProgress: boolean;
  91987. private _onPrePointerObservableObserver;
  91988. private _onAfterCheckInputsObserver;
  91989. private _attachedCamera;
  91990. private _isPointerDown;
  91991. private _lastFrameTime;
  91992. private _lastInteractionTime;
  91993. private _cameraRotationSpeed;
  91994. /**
  91995. * Initializes the behavior.
  91996. */
  91997. init(): void;
  91998. /**
  91999. * Attaches the behavior to its arc rotate camera.
  92000. * @param camera Defines the camera to attach the behavior to
  92001. */
  92002. attach(camera: ArcRotateCamera): void;
  92003. /**
  92004. * Detaches the behavior from its current arc rotate camera.
  92005. */
  92006. detach(): void;
  92007. /**
  92008. * Returns true if user is scrolling.
  92009. * @return true if user is scrolling.
  92010. */
  92011. private _userIsZooming;
  92012. private _lastFrameRadius;
  92013. private _shouldAnimationStopForInteraction;
  92014. /**
  92015. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92016. */
  92017. private _applyUserInteraction;
  92018. private _userIsMoving;
  92019. }
  92020. }
  92021. declare module BABYLON {
  92022. /**
  92023. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92024. */
  92025. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92026. private ui;
  92027. /**
  92028. * The name of the behavior
  92029. */
  92030. name: string;
  92031. /**
  92032. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92033. */
  92034. distanceAwayFromFace: number;
  92035. /**
  92036. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92037. */
  92038. distanceAwayFromBottomOfFace: number;
  92039. private _faceVectors;
  92040. private _target;
  92041. private _scene;
  92042. private _onRenderObserver;
  92043. private _tmpMatrix;
  92044. private _tmpVector;
  92045. /**
  92046. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92047. * @param ui The transform node that should be attched to the mesh
  92048. */
  92049. constructor(ui: TransformNode);
  92050. /**
  92051. * Initializes the behavior
  92052. */
  92053. init(): void;
  92054. private _closestFace;
  92055. private _zeroVector;
  92056. private _lookAtTmpMatrix;
  92057. private _lookAtToRef;
  92058. /**
  92059. * Attaches the AttachToBoxBehavior to the passed in mesh
  92060. * @param target The mesh that the specified node will be attached to
  92061. */
  92062. attach(target: Mesh): void;
  92063. /**
  92064. * Detaches the behavior from the mesh
  92065. */
  92066. detach(): void;
  92067. }
  92068. }
  92069. declare module BABYLON {
  92070. /**
  92071. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92072. */
  92073. export class FadeInOutBehavior implements Behavior<Mesh> {
  92074. /**
  92075. * Time in milliseconds to delay before fading in (Default: 0)
  92076. */
  92077. delay: number;
  92078. /**
  92079. * Time in milliseconds for the mesh to fade in (Default: 300)
  92080. */
  92081. fadeInTime: number;
  92082. private _millisecondsPerFrame;
  92083. private _hovered;
  92084. private _hoverValue;
  92085. private _ownerNode;
  92086. /**
  92087. * Instatiates the FadeInOutBehavior
  92088. */
  92089. constructor();
  92090. /**
  92091. * The name of the behavior
  92092. */
  92093. readonly name: string;
  92094. /**
  92095. * Initializes the behavior
  92096. */
  92097. init(): void;
  92098. /**
  92099. * Attaches the fade behavior on the passed in mesh
  92100. * @param ownerNode The mesh that will be faded in/out once attached
  92101. */
  92102. attach(ownerNode: Mesh): void;
  92103. /**
  92104. * Detaches the behavior from the mesh
  92105. */
  92106. detach(): void;
  92107. /**
  92108. * Triggers the mesh to begin fading in or out
  92109. * @param value if the object should fade in or out (true to fade in)
  92110. */
  92111. fadeIn(value: boolean): void;
  92112. private _update;
  92113. private _setAllVisibility;
  92114. }
  92115. }
  92116. declare module BABYLON {
  92117. /**
  92118. * Class containing a set of static utilities functions for managing Pivots
  92119. * @hidden
  92120. */
  92121. export class PivotTools {
  92122. private static _PivotCached;
  92123. private static _OldPivotPoint;
  92124. private static _PivotTranslation;
  92125. private static _PivotTmpVector;
  92126. /** @hidden */
  92127. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92128. /** @hidden */
  92129. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92130. }
  92131. }
  92132. declare module BABYLON {
  92133. /**
  92134. * Class containing static functions to help procedurally build meshes
  92135. */
  92136. export class PlaneBuilder {
  92137. /**
  92138. * Creates a plane mesh
  92139. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92140. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92141. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92143. * * If you create a double-sided mesh, you can choose what parts of 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
  92144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92145. * @param name defines the name of the mesh
  92146. * @param options defines the options used to create the mesh
  92147. * @param scene defines the hosting scene
  92148. * @returns the plane mesh
  92149. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92150. */
  92151. static CreatePlane(name: string, options: {
  92152. size?: number;
  92153. width?: number;
  92154. height?: number;
  92155. sideOrientation?: number;
  92156. frontUVs?: Vector4;
  92157. backUVs?: Vector4;
  92158. updatable?: boolean;
  92159. sourcePlane?: Plane;
  92160. }, scene: Scene): Mesh;
  92161. }
  92162. }
  92163. declare module BABYLON {
  92164. /**
  92165. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92166. */
  92167. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92168. private static _AnyMouseID;
  92169. private _attachedNode;
  92170. private _dragPlane;
  92171. private _scene;
  92172. private _pointerObserver;
  92173. private _beforeRenderObserver;
  92174. private static _planeScene;
  92175. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92176. /**
  92177. * 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)
  92178. */
  92179. maxDragAngle: number;
  92180. /**
  92181. * @hidden
  92182. */
  92183. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92184. /**
  92185. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92186. */
  92187. currentDraggingPointerID: number;
  92188. /**
  92189. * The last position where the pointer hit the drag plane in world space
  92190. */
  92191. lastDragPosition: Vector3;
  92192. /**
  92193. * If the behavior is currently in a dragging state
  92194. */
  92195. dragging: boolean;
  92196. /**
  92197. * 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)
  92198. */
  92199. dragDeltaRatio: number;
  92200. /**
  92201. * If the drag plane orientation should be updated during the dragging (Default: true)
  92202. */
  92203. updateDragPlane: boolean;
  92204. private _debugMode;
  92205. private _moving;
  92206. /**
  92207. * Fires each time the attached mesh is dragged with the pointer
  92208. * * delta between last drag position and current drag position in world space
  92209. * * dragDistance along the drag axis
  92210. * * dragPlaneNormal normal of the current drag plane used during the drag
  92211. * * dragPlanePoint in world space where the drag intersects the drag plane
  92212. */
  92213. onDragObservable: Observable<{
  92214. delta: Vector3;
  92215. dragPlanePoint: Vector3;
  92216. dragPlaneNormal: Vector3;
  92217. dragDistance: number;
  92218. pointerId: number;
  92219. }>;
  92220. /**
  92221. * Fires each time a drag begins (eg. mouse down on mesh)
  92222. */
  92223. onDragStartObservable: Observable<{
  92224. dragPlanePoint: Vector3;
  92225. pointerId: number;
  92226. }>;
  92227. /**
  92228. * Fires each time a drag ends (eg. mouse release after drag)
  92229. */
  92230. onDragEndObservable: Observable<{
  92231. dragPlanePoint: Vector3;
  92232. pointerId: number;
  92233. }>;
  92234. /**
  92235. * If the attached mesh should be moved when dragged
  92236. */
  92237. moveAttached: boolean;
  92238. /**
  92239. * If the drag behavior will react to drag events (Default: true)
  92240. */
  92241. enabled: boolean;
  92242. /**
  92243. * If camera controls should be detached during the drag
  92244. */
  92245. detachCameraControls: boolean;
  92246. /**
  92247. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92248. */
  92249. useObjectOrienationForDragging: boolean;
  92250. private _options;
  92251. /**
  92252. * Creates a pointer drag behavior that can be attached to a mesh
  92253. * @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)
  92254. */
  92255. constructor(options?: {
  92256. dragAxis?: Vector3;
  92257. dragPlaneNormal?: Vector3;
  92258. });
  92259. /**
  92260. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92261. */
  92262. validateDrag: (targetPosition: Vector3) => boolean;
  92263. /**
  92264. * The name of the behavior
  92265. */
  92266. readonly name: string;
  92267. /**
  92268. * Initializes the behavior
  92269. */
  92270. init(): void;
  92271. private _tmpVector;
  92272. private _alternatePickedPoint;
  92273. private _worldDragAxis;
  92274. private _targetPosition;
  92275. private _attachedElement;
  92276. /**
  92277. * Attaches the drag behavior the passed in mesh
  92278. * @param ownerNode The mesh that will be dragged around once attached
  92279. */
  92280. attach(ownerNode: AbstractMesh): void;
  92281. /**
  92282. * Force relase the drag action by code.
  92283. */
  92284. releaseDrag(): void;
  92285. private _startDragRay;
  92286. private _lastPointerRay;
  92287. /**
  92288. * Simulates the start of a pointer drag event on the behavior
  92289. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92290. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92291. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92292. */
  92293. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92294. private _startDrag;
  92295. private _dragDelta;
  92296. private _moveDrag;
  92297. private _pickWithRayOnDragPlane;
  92298. private _pointA;
  92299. private _pointB;
  92300. private _pointC;
  92301. private _lineA;
  92302. private _lineB;
  92303. private _localAxis;
  92304. private _lookAt;
  92305. private _updateDragPlanePosition;
  92306. /**
  92307. * Detaches the behavior from the mesh
  92308. */
  92309. detach(): void;
  92310. }
  92311. }
  92312. declare module BABYLON {
  92313. /**
  92314. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92315. */
  92316. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92317. private _dragBehaviorA;
  92318. private _dragBehaviorB;
  92319. private _startDistance;
  92320. private _initialScale;
  92321. private _targetScale;
  92322. private _ownerNode;
  92323. private _sceneRenderObserver;
  92324. /**
  92325. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92326. */
  92327. constructor();
  92328. /**
  92329. * The name of the behavior
  92330. */
  92331. readonly name: string;
  92332. /**
  92333. * Initializes the behavior
  92334. */
  92335. init(): void;
  92336. private _getCurrentDistance;
  92337. /**
  92338. * Attaches the scale behavior the passed in mesh
  92339. * @param ownerNode The mesh that will be scaled around once attached
  92340. */
  92341. attach(ownerNode: Mesh): void;
  92342. /**
  92343. * Detaches the behavior from the mesh
  92344. */
  92345. detach(): void;
  92346. }
  92347. }
  92348. declare module BABYLON {
  92349. /**
  92350. * 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
  92351. */
  92352. export class SixDofDragBehavior implements Behavior<Mesh> {
  92353. private static _virtualScene;
  92354. private _ownerNode;
  92355. private _sceneRenderObserver;
  92356. private _scene;
  92357. private _targetPosition;
  92358. private _virtualOriginMesh;
  92359. private _virtualDragMesh;
  92360. private _pointerObserver;
  92361. private _moving;
  92362. private _startingOrientation;
  92363. /**
  92364. * 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)
  92365. */
  92366. private zDragFactor;
  92367. /**
  92368. * If the object should rotate to face the drag origin
  92369. */
  92370. rotateDraggedObject: boolean;
  92371. /**
  92372. * If the behavior is currently in a dragging state
  92373. */
  92374. dragging: boolean;
  92375. /**
  92376. * 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)
  92377. */
  92378. dragDeltaRatio: number;
  92379. /**
  92380. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92381. */
  92382. currentDraggingPointerID: number;
  92383. /**
  92384. * If camera controls should be detached during the drag
  92385. */
  92386. detachCameraControls: boolean;
  92387. /**
  92388. * Fires each time a drag starts
  92389. */
  92390. onDragStartObservable: Observable<{}>;
  92391. /**
  92392. * Fires each time a drag ends (eg. mouse release after drag)
  92393. */
  92394. onDragEndObservable: Observable<{}>;
  92395. /**
  92396. * 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
  92397. */
  92398. constructor();
  92399. /**
  92400. * The name of the behavior
  92401. */
  92402. readonly name: string;
  92403. /**
  92404. * Initializes the behavior
  92405. */
  92406. init(): void;
  92407. /**
  92408. * Attaches the scale behavior the passed in mesh
  92409. * @param ownerNode The mesh that will be scaled around once attached
  92410. */
  92411. attach(ownerNode: Mesh): void;
  92412. /**
  92413. * Detaches the behavior from the mesh
  92414. */
  92415. detach(): void;
  92416. }
  92417. }
  92418. declare module BABYLON {
  92419. /**
  92420. * Class used to apply inverse kinematics to bones
  92421. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92422. */
  92423. export class BoneIKController {
  92424. private static _tmpVecs;
  92425. private static _tmpQuat;
  92426. private static _tmpMats;
  92427. /**
  92428. * Gets or sets the target mesh
  92429. */
  92430. targetMesh: AbstractMesh;
  92431. /** Gets or sets the mesh used as pole */
  92432. poleTargetMesh: AbstractMesh;
  92433. /**
  92434. * Gets or sets the bone used as pole
  92435. */
  92436. poleTargetBone: Nullable<Bone>;
  92437. /**
  92438. * Gets or sets the target position
  92439. */
  92440. targetPosition: Vector3;
  92441. /**
  92442. * Gets or sets the pole target position
  92443. */
  92444. poleTargetPosition: Vector3;
  92445. /**
  92446. * Gets or sets the pole target local offset
  92447. */
  92448. poleTargetLocalOffset: Vector3;
  92449. /**
  92450. * Gets or sets the pole angle
  92451. */
  92452. poleAngle: number;
  92453. /**
  92454. * Gets or sets the mesh associated with the controller
  92455. */
  92456. mesh: AbstractMesh;
  92457. /**
  92458. * 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)
  92459. */
  92460. slerpAmount: number;
  92461. private _bone1Quat;
  92462. private _bone1Mat;
  92463. private _bone2Ang;
  92464. private _bone1;
  92465. private _bone2;
  92466. private _bone1Length;
  92467. private _bone2Length;
  92468. private _maxAngle;
  92469. private _maxReach;
  92470. private _rightHandedSystem;
  92471. private _bendAxis;
  92472. private _slerping;
  92473. private _adjustRoll;
  92474. /**
  92475. * Gets or sets maximum allowed angle
  92476. */
  92477. maxAngle: number;
  92478. /**
  92479. * Creates a new BoneIKController
  92480. * @param mesh defines the mesh to control
  92481. * @param bone defines the bone to control
  92482. * @param options defines options to set up the controller
  92483. */
  92484. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  92485. targetMesh?: AbstractMesh;
  92486. poleTargetMesh?: AbstractMesh;
  92487. poleTargetBone?: Bone;
  92488. poleTargetLocalOffset?: Vector3;
  92489. poleAngle?: number;
  92490. bendAxis?: Vector3;
  92491. maxAngle?: number;
  92492. slerpAmount?: number;
  92493. });
  92494. private _setMaxAngle;
  92495. /**
  92496. * Force the controller to update the bones
  92497. */
  92498. update(): void;
  92499. }
  92500. }
  92501. declare module BABYLON {
  92502. /**
  92503. * Class used to make a bone look toward a point in space
  92504. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  92505. */
  92506. export class BoneLookController {
  92507. private static _tmpVecs;
  92508. private static _tmpQuat;
  92509. private static _tmpMats;
  92510. /**
  92511. * The target Vector3 that the bone will look at
  92512. */
  92513. target: Vector3;
  92514. /**
  92515. * The mesh that the bone is attached to
  92516. */
  92517. mesh: AbstractMesh;
  92518. /**
  92519. * The bone that will be looking to the target
  92520. */
  92521. bone: Bone;
  92522. /**
  92523. * The up axis of the coordinate system that is used when the bone is rotated
  92524. */
  92525. upAxis: Vector3;
  92526. /**
  92527. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  92528. */
  92529. upAxisSpace: Space;
  92530. /**
  92531. * Used to make an adjustment to the yaw of the bone
  92532. */
  92533. adjustYaw: number;
  92534. /**
  92535. * Used to make an adjustment to the pitch of the bone
  92536. */
  92537. adjustPitch: number;
  92538. /**
  92539. * Used to make an adjustment to the roll of the bone
  92540. */
  92541. adjustRoll: number;
  92542. /**
  92543. * 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)
  92544. */
  92545. slerpAmount: number;
  92546. private _minYaw;
  92547. private _maxYaw;
  92548. private _minPitch;
  92549. private _maxPitch;
  92550. private _minYawSin;
  92551. private _minYawCos;
  92552. private _maxYawSin;
  92553. private _maxYawCos;
  92554. private _midYawConstraint;
  92555. private _minPitchTan;
  92556. private _maxPitchTan;
  92557. private _boneQuat;
  92558. private _slerping;
  92559. private _transformYawPitch;
  92560. private _transformYawPitchInv;
  92561. private _firstFrameSkipped;
  92562. private _yawRange;
  92563. private _fowardAxis;
  92564. /**
  92565. * Gets or sets the minimum yaw angle that the bone can look to
  92566. */
  92567. minYaw: number;
  92568. /**
  92569. * Gets or sets the maximum yaw angle that the bone can look to
  92570. */
  92571. maxYaw: number;
  92572. /**
  92573. * Gets or sets the minimum pitch angle that the bone can look to
  92574. */
  92575. minPitch: number;
  92576. /**
  92577. * Gets or sets the maximum pitch angle that the bone can look to
  92578. */
  92579. maxPitch: number;
  92580. /**
  92581. * Create a BoneLookController
  92582. * @param mesh the mesh that the bone belongs to
  92583. * @param bone the bone that will be looking to the target
  92584. * @param target the target Vector3 to look at
  92585. * @param options optional settings:
  92586. * * maxYaw: the maximum angle the bone will yaw to
  92587. * * minYaw: the minimum angle the bone will yaw to
  92588. * * maxPitch: the maximum angle the bone will pitch to
  92589. * * minPitch: the minimum angle the bone will yaw to
  92590. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  92591. * * upAxis: the up axis of the coordinate system
  92592. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  92593. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  92594. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  92595. * * adjustYaw: used to make an adjustment to the yaw of the bone
  92596. * * adjustPitch: used to make an adjustment to the pitch of the bone
  92597. * * adjustRoll: used to make an adjustment to the roll of the bone
  92598. **/
  92599. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  92600. maxYaw?: number;
  92601. minYaw?: number;
  92602. maxPitch?: number;
  92603. minPitch?: number;
  92604. slerpAmount?: number;
  92605. upAxis?: Vector3;
  92606. upAxisSpace?: Space;
  92607. yawAxis?: Vector3;
  92608. pitchAxis?: Vector3;
  92609. adjustYaw?: number;
  92610. adjustPitch?: number;
  92611. adjustRoll?: number;
  92612. });
  92613. /**
  92614. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  92615. */
  92616. update(): void;
  92617. private _getAngleDiff;
  92618. private _getAngleBetween;
  92619. private _isAngleBetween;
  92620. }
  92621. }
  92622. declare module BABYLON {
  92623. /**
  92624. * Manage the gamepad inputs to control an arc rotate camera.
  92625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92626. */
  92627. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92628. /**
  92629. * Defines the camera the input is attached to.
  92630. */
  92631. camera: ArcRotateCamera;
  92632. /**
  92633. * Defines the gamepad the input is gathering event from.
  92634. */
  92635. gamepad: Nullable<Gamepad>;
  92636. /**
  92637. * Defines the gamepad rotation sensiblity.
  92638. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92639. */
  92640. gamepadRotationSensibility: number;
  92641. /**
  92642. * Defines the gamepad move sensiblity.
  92643. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92644. */
  92645. gamepadMoveSensibility: number;
  92646. private _onGamepadConnectedObserver;
  92647. private _onGamepadDisconnectedObserver;
  92648. /**
  92649. * Attach the input controls to a specific dom element to get the input from.
  92650. * @param element Defines the element the controls should be listened from
  92651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92652. */
  92653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92654. /**
  92655. * Detach the current controls from the specified dom element.
  92656. * @param element Defines the element to stop listening the inputs from
  92657. */
  92658. detachControl(element: Nullable<HTMLElement>): void;
  92659. /**
  92660. * Update the current camera state depending on the inputs that have been used this frame.
  92661. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92662. */
  92663. checkInputs(): void;
  92664. /**
  92665. * Gets the class name of the current intput.
  92666. * @returns the class name
  92667. */
  92668. getClassName(): string;
  92669. /**
  92670. * Get the friendly name associated with the input class.
  92671. * @returns the input friendly name
  92672. */
  92673. getSimpleName(): string;
  92674. }
  92675. }
  92676. declare module BABYLON {
  92677. interface ArcRotateCameraInputsManager {
  92678. /**
  92679. * Add orientation input support to the input manager.
  92680. * @returns the current input manager
  92681. */
  92682. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92683. }
  92684. /**
  92685. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92687. */
  92688. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92689. /**
  92690. * Defines the camera the input is attached to.
  92691. */
  92692. camera: ArcRotateCamera;
  92693. /**
  92694. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92695. */
  92696. alphaCorrection: number;
  92697. /**
  92698. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92699. */
  92700. gammaCorrection: number;
  92701. private _alpha;
  92702. private _gamma;
  92703. private _dirty;
  92704. private _deviceOrientationHandler;
  92705. /**
  92706. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  92707. */
  92708. constructor();
  92709. /**
  92710. * Attach the input controls to a specific dom element to get the input from.
  92711. * @param element Defines the element the controls should be listened from
  92712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92713. */
  92714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92715. /** @hidden */
  92716. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  92717. /**
  92718. * Update the current camera state depending on the inputs that have been used this frame.
  92719. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92720. */
  92721. checkInputs(): void;
  92722. /**
  92723. * Detach the current controls from the specified dom element.
  92724. * @param element Defines the element to stop listening the inputs from
  92725. */
  92726. detachControl(element: Nullable<HTMLElement>): void;
  92727. /**
  92728. * Gets the class name of the current intput.
  92729. * @returns the class name
  92730. */
  92731. getClassName(): string;
  92732. /**
  92733. * Get the friendly name associated with the input class.
  92734. * @returns the input friendly name
  92735. */
  92736. getSimpleName(): string;
  92737. }
  92738. }
  92739. declare module BABYLON {
  92740. /**
  92741. * Listen to mouse events to control the camera.
  92742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92743. */
  92744. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  92745. /**
  92746. * Defines the camera the input is attached to.
  92747. */
  92748. camera: FlyCamera;
  92749. /**
  92750. * Defines if touch is enabled. (Default is true.)
  92751. */
  92752. touchEnabled: boolean;
  92753. /**
  92754. * Defines the buttons associated with the input to handle camera rotation.
  92755. */
  92756. buttons: number[];
  92757. /**
  92758. * Assign buttons for Yaw control.
  92759. */
  92760. buttonsYaw: number[];
  92761. /**
  92762. * Assign buttons for Pitch control.
  92763. */
  92764. buttonsPitch: number[];
  92765. /**
  92766. * Assign buttons for Roll control.
  92767. */
  92768. buttonsRoll: number[];
  92769. /**
  92770. * Detect if any button is being pressed while mouse is moved.
  92771. * -1 = Mouse locked.
  92772. * 0 = Left button.
  92773. * 1 = Middle Button.
  92774. * 2 = Right Button.
  92775. */
  92776. activeButton: number;
  92777. /**
  92778. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  92779. * Higher values reduce its sensitivity.
  92780. */
  92781. angularSensibility: number;
  92782. private _mousemoveCallback;
  92783. private _observer;
  92784. private _rollObserver;
  92785. private previousPosition;
  92786. private noPreventDefault;
  92787. private element;
  92788. /**
  92789. * Listen to mouse events to control the camera.
  92790. * @param touchEnabled Define if touch is enabled. (Default is true.)
  92791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92792. */
  92793. constructor(touchEnabled?: boolean);
  92794. /**
  92795. * Attach the mouse control to the HTML DOM element.
  92796. * @param element Defines the element that listens to the input events.
  92797. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  92798. */
  92799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92800. /**
  92801. * Detach the current controls from the specified dom element.
  92802. * @param element Defines the element to stop listening the inputs from
  92803. */
  92804. detachControl(element: Nullable<HTMLElement>): void;
  92805. /**
  92806. * Gets the class name of the current input.
  92807. * @returns the class name.
  92808. */
  92809. getClassName(): string;
  92810. /**
  92811. * Get the friendly name associated with the input class.
  92812. * @returns the input's friendly name.
  92813. */
  92814. getSimpleName(): string;
  92815. private _pointerInput;
  92816. private _onMouseMove;
  92817. /**
  92818. * Rotate camera by mouse offset.
  92819. */
  92820. private rotateCamera;
  92821. }
  92822. }
  92823. declare module BABYLON {
  92824. /**
  92825. * Default Inputs manager for the FlyCamera.
  92826. * It groups all the default supported inputs for ease of use.
  92827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92828. */
  92829. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  92830. /**
  92831. * Instantiates a new FlyCameraInputsManager.
  92832. * @param camera Defines the camera the inputs belong to.
  92833. */
  92834. constructor(camera: FlyCamera);
  92835. /**
  92836. * Add keyboard input support to the input manager.
  92837. * @returns the new FlyCameraKeyboardMoveInput().
  92838. */
  92839. addKeyboard(): FlyCameraInputsManager;
  92840. /**
  92841. * Add mouse input support to the input manager.
  92842. * @param touchEnabled Enable touch screen support.
  92843. * @returns the new FlyCameraMouseInput().
  92844. */
  92845. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  92846. }
  92847. }
  92848. declare module BABYLON {
  92849. /**
  92850. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92851. * such as in a 3D Space Shooter or a Flight Simulator.
  92852. */
  92853. export class FlyCamera extends TargetCamera {
  92854. /**
  92855. * Define the collision ellipsoid of the camera.
  92856. * This is helpful for simulating a camera body, like a player's body.
  92857. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92858. */
  92859. ellipsoid: Vector3;
  92860. /**
  92861. * Define an offset for the position of the ellipsoid around the camera.
  92862. * This can be helpful if the camera is attached away from the player's body center,
  92863. * such as at its head.
  92864. */
  92865. ellipsoidOffset: Vector3;
  92866. /**
  92867. * Enable or disable collisions of the camera with the rest of the scene objects.
  92868. */
  92869. checkCollisions: boolean;
  92870. /**
  92871. * Enable or disable gravity on the camera.
  92872. */
  92873. applyGravity: boolean;
  92874. /**
  92875. * Define the current direction the camera is moving to.
  92876. */
  92877. cameraDirection: Vector3;
  92878. /**
  92879. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  92880. * This overrides and empties cameraRotation.
  92881. */
  92882. rotationQuaternion: Quaternion;
  92883. /**
  92884. * Track Roll to maintain the wanted Rolling when looking around.
  92885. */
  92886. _trackRoll: number;
  92887. /**
  92888. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  92889. */
  92890. rollCorrect: number;
  92891. /**
  92892. * Mimic a banked turn, Rolling the camera when Yawing.
  92893. * It's recommended to use rollCorrect = 10 for faster banking correction.
  92894. */
  92895. bankedTurn: boolean;
  92896. /**
  92897. * Limit in radians for how much Roll banking will add. (Default: 90°)
  92898. */
  92899. bankedTurnLimit: number;
  92900. /**
  92901. * Value of 0 disables the banked Roll.
  92902. * Value of 1 is equal to the Yaw angle in radians.
  92903. */
  92904. bankedTurnMultiplier: number;
  92905. /**
  92906. * The inputs manager loads all the input sources, such as keyboard and mouse.
  92907. */
  92908. inputs: FlyCameraInputsManager;
  92909. /**
  92910. * Gets the input sensibility for mouse input.
  92911. * Higher values reduce sensitivity.
  92912. */
  92913. /**
  92914. * Sets the input sensibility for a mouse input.
  92915. * Higher values reduce sensitivity.
  92916. */
  92917. angularSensibility: number;
  92918. /**
  92919. * Get the keys for camera movement forward.
  92920. */
  92921. /**
  92922. * Set the keys for camera movement forward.
  92923. */
  92924. keysForward: number[];
  92925. /**
  92926. * Get the keys for camera movement backward.
  92927. */
  92928. keysBackward: number[];
  92929. /**
  92930. * Get the keys for camera movement up.
  92931. */
  92932. /**
  92933. * Set the keys for camera movement up.
  92934. */
  92935. keysUp: number[];
  92936. /**
  92937. * Get the keys for camera movement down.
  92938. */
  92939. /**
  92940. * Set the keys for camera movement down.
  92941. */
  92942. keysDown: number[];
  92943. /**
  92944. * Get the keys for camera movement left.
  92945. */
  92946. /**
  92947. * Set the keys for camera movement left.
  92948. */
  92949. keysLeft: number[];
  92950. /**
  92951. * Set the keys for camera movement right.
  92952. */
  92953. /**
  92954. * Set the keys for camera movement right.
  92955. */
  92956. keysRight: number[];
  92957. /**
  92958. * Event raised when the camera collides with a mesh in the scene.
  92959. */
  92960. onCollide: (collidedMesh: AbstractMesh) => void;
  92961. private _collider;
  92962. private _needMoveForGravity;
  92963. private _oldPosition;
  92964. private _diffPosition;
  92965. private _newPosition;
  92966. /** @hidden */
  92967. _localDirection: Vector3;
  92968. /** @hidden */
  92969. _transformedDirection: Vector3;
  92970. /**
  92971. * Instantiates a FlyCamera.
  92972. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92973. * such as in a 3D Space Shooter or a Flight Simulator.
  92974. * @param name Define the name of the camera in the scene.
  92975. * @param position Define the starting position of the camera in the scene.
  92976. * @param scene Define the scene the camera belongs to.
  92977. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  92978. */
  92979. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92980. /**
  92981. * Attach a control to the HTML DOM element.
  92982. * @param element Defines the element that listens to the input events.
  92983. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  92984. */
  92985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92986. /**
  92987. * Detach a control from the HTML DOM element.
  92988. * The camera will stop reacting to that input.
  92989. * @param element Defines the element that listens to the input events.
  92990. */
  92991. detachControl(element: HTMLElement): void;
  92992. private _collisionMask;
  92993. /**
  92994. * Get the mask that the camera ignores in collision events.
  92995. */
  92996. /**
  92997. * Set the mask that the camera ignores in collision events.
  92998. */
  92999. collisionMask: number;
  93000. /** @hidden */
  93001. _collideWithWorld(displacement: Vector3): void;
  93002. /** @hidden */
  93003. private _onCollisionPositionChange;
  93004. /** @hidden */
  93005. _checkInputs(): void;
  93006. /** @hidden */
  93007. _decideIfNeedsToMove(): boolean;
  93008. /** @hidden */
  93009. _updatePosition(): void;
  93010. /**
  93011. * Restore the Roll to its target value at the rate specified.
  93012. * @param rate - Higher means slower restoring.
  93013. * @hidden
  93014. */
  93015. restoreRoll(rate: number): void;
  93016. /**
  93017. * Destroy the camera and release the current resources held by it.
  93018. */
  93019. dispose(): void;
  93020. /**
  93021. * Get the current object class name.
  93022. * @returns the class name.
  93023. */
  93024. getClassName(): string;
  93025. }
  93026. }
  93027. declare module BABYLON {
  93028. /**
  93029. * Listen to keyboard events to control the camera.
  93030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93031. */
  93032. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93033. /**
  93034. * Defines the camera the input is attached to.
  93035. */
  93036. camera: FlyCamera;
  93037. /**
  93038. * The list of keyboard keys used to control the forward move of the camera.
  93039. */
  93040. keysForward: number[];
  93041. /**
  93042. * The list of keyboard keys used to control the backward move of the camera.
  93043. */
  93044. keysBackward: number[];
  93045. /**
  93046. * The list of keyboard keys used to control the forward move of the camera.
  93047. */
  93048. keysUp: number[];
  93049. /**
  93050. * The list of keyboard keys used to control the backward move of the camera.
  93051. */
  93052. keysDown: number[];
  93053. /**
  93054. * The list of keyboard keys used to control the right strafe move of the camera.
  93055. */
  93056. keysRight: number[];
  93057. /**
  93058. * The list of keyboard keys used to control the left strafe move of the camera.
  93059. */
  93060. keysLeft: number[];
  93061. private _keys;
  93062. private _onCanvasBlurObserver;
  93063. private _onKeyboardObserver;
  93064. private _engine;
  93065. private _scene;
  93066. /**
  93067. * Attach the input controls to a specific dom element to get the input from.
  93068. * @param element Defines the element the controls should be listened from
  93069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93070. */
  93071. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93072. /**
  93073. * Detach the current controls from the specified dom element.
  93074. * @param element Defines the element to stop listening the inputs from
  93075. */
  93076. detachControl(element: Nullable<HTMLElement>): void;
  93077. /**
  93078. * Gets the class name of the current intput.
  93079. * @returns the class name
  93080. */
  93081. getClassName(): string;
  93082. /** @hidden */
  93083. _onLostFocus(e: FocusEvent): void;
  93084. /**
  93085. * Get the friendly name associated with the input class.
  93086. * @returns the input friendly name
  93087. */
  93088. getSimpleName(): string;
  93089. /**
  93090. * Update the current camera state depending on the inputs that have been used this frame.
  93091. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93092. */
  93093. checkInputs(): void;
  93094. }
  93095. }
  93096. declare module BABYLON {
  93097. /**
  93098. * Manage the mouse wheel inputs to control a follow camera.
  93099. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93100. */
  93101. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93102. /**
  93103. * Defines the camera the input is attached to.
  93104. */
  93105. camera: FollowCamera;
  93106. /**
  93107. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93108. */
  93109. axisControlRadius: boolean;
  93110. /**
  93111. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93112. */
  93113. axisControlHeight: boolean;
  93114. /**
  93115. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93116. */
  93117. axisControlRotation: boolean;
  93118. /**
  93119. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93120. * relation to mouseWheel events.
  93121. */
  93122. wheelPrecision: number;
  93123. /**
  93124. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93125. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93126. */
  93127. wheelDeltaPercentage: number;
  93128. private _wheel;
  93129. private _observer;
  93130. /**
  93131. * Attach the input controls to a specific dom element to get the input from.
  93132. * @param element Defines the element the controls should be listened from
  93133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93134. */
  93135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93136. /**
  93137. * Detach the current controls from the specified dom element.
  93138. * @param element Defines the element to stop listening the inputs from
  93139. */
  93140. detachControl(element: Nullable<HTMLElement>): void;
  93141. /**
  93142. * Gets the class name of the current intput.
  93143. * @returns the class name
  93144. */
  93145. getClassName(): string;
  93146. /**
  93147. * Get the friendly name associated with the input class.
  93148. * @returns the input friendly name
  93149. */
  93150. getSimpleName(): string;
  93151. }
  93152. }
  93153. declare module BABYLON {
  93154. /**
  93155. * Manage the pointers inputs to control an follow camera.
  93156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93157. */
  93158. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93159. /**
  93160. * Defines the camera the input is attached to.
  93161. */
  93162. camera: FollowCamera;
  93163. /**
  93164. * Gets the class name of the current input.
  93165. * @returns the class name
  93166. */
  93167. getClassName(): string;
  93168. /**
  93169. * Defines the pointer angular sensibility along the X axis or how fast is
  93170. * the camera rotating.
  93171. * A negative number will reverse the axis direction.
  93172. */
  93173. angularSensibilityX: number;
  93174. /**
  93175. * Defines the pointer angular sensibility along the Y axis or how fast is
  93176. * the camera rotating.
  93177. * A negative number will reverse the axis direction.
  93178. */
  93179. angularSensibilityY: number;
  93180. /**
  93181. * Defines the pointer pinch precision or how fast is the camera zooming.
  93182. * A negative number will reverse the axis direction.
  93183. */
  93184. pinchPrecision: number;
  93185. /**
  93186. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93187. * from 0.
  93188. * It defines the percentage of current camera.radius to use as delta when
  93189. * pinch zoom is used.
  93190. */
  93191. pinchDeltaPercentage: number;
  93192. /**
  93193. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93194. */
  93195. axisXControlRadius: boolean;
  93196. /**
  93197. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93198. */
  93199. axisXControlHeight: boolean;
  93200. /**
  93201. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93202. */
  93203. axisXControlRotation: boolean;
  93204. /**
  93205. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93206. */
  93207. axisYControlRadius: boolean;
  93208. /**
  93209. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93210. */
  93211. axisYControlHeight: boolean;
  93212. /**
  93213. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93214. */
  93215. axisYControlRotation: boolean;
  93216. /**
  93217. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93218. */
  93219. axisPinchControlRadius: boolean;
  93220. /**
  93221. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93222. */
  93223. axisPinchControlHeight: boolean;
  93224. /**
  93225. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93226. */
  93227. axisPinchControlRotation: boolean;
  93228. /**
  93229. * Log error messages if basic misconfiguration has occurred.
  93230. */
  93231. warningEnable: boolean;
  93232. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93233. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93234. private _warningCounter;
  93235. private _warning;
  93236. }
  93237. }
  93238. declare module BABYLON {
  93239. /**
  93240. * Default Inputs manager for the FollowCamera.
  93241. * It groups all the default supported inputs for ease of use.
  93242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93243. */
  93244. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93245. /**
  93246. * Instantiates a new FollowCameraInputsManager.
  93247. * @param camera Defines the camera the inputs belong to
  93248. */
  93249. constructor(camera: FollowCamera);
  93250. /**
  93251. * Add keyboard input support to the input manager.
  93252. * @returns the current input manager
  93253. */
  93254. addKeyboard(): FollowCameraInputsManager;
  93255. /**
  93256. * Add mouse wheel input support to the input manager.
  93257. * @returns the current input manager
  93258. */
  93259. addMouseWheel(): FollowCameraInputsManager;
  93260. /**
  93261. * Add pointers input support to the input manager.
  93262. * @returns the current input manager
  93263. */
  93264. addPointers(): FollowCameraInputsManager;
  93265. /**
  93266. * Add orientation input support to the input manager.
  93267. * @returns the current input manager
  93268. */
  93269. addVRDeviceOrientation(): FollowCameraInputsManager;
  93270. }
  93271. }
  93272. declare module BABYLON {
  93273. /**
  93274. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93275. * an arc rotate version arcFollowCamera are available.
  93276. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93277. */
  93278. export class FollowCamera extends TargetCamera {
  93279. /**
  93280. * Distance the follow camera should follow an object at
  93281. */
  93282. radius: number;
  93283. /**
  93284. * Minimum allowed distance of the camera to the axis of rotation
  93285. * (The camera can not get closer).
  93286. * This can help limiting how the Camera is able to move in the scene.
  93287. */
  93288. lowerRadiusLimit: Nullable<number>;
  93289. /**
  93290. * Maximum allowed distance of the camera to the axis of rotation
  93291. * (The camera can not get further).
  93292. * This can help limiting how the Camera is able to move in the scene.
  93293. */
  93294. upperRadiusLimit: Nullable<number>;
  93295. /**
  93296. * Define a rotation offset between the camera and the object it follows
  93297. */
  93298. rotationOffset: number;
  93299. /**
  93300. * Minimum allowed angle to camera position relative to target object.
  93301. * This can help limiting how the Camera is able to move in the scene.
  93302. */
  93303. lowerRotationOffsetLimit: Nullable<number>;
  93304. /**
  93305. * Maximum allowed angle to camera position relative to target object.
  93306. * This can help limiting how the Camera is able to move in the scene.
  93307. */
  93308. upperRotationOffsetLimit: Nullable<number>;
  93309. /**
  93310. * Define a height offset between the camera and the object it follows.
  93311. * It can help following an object from the top (like a car chaing a plane)
  93312. */
  93313. heightOffset: number;
  93314. /**
  93315. * Minimum allowed height of camera position relative to target object.
  93316. * This can help limiting how the Camera is able to move in the scene.
  93317. */
  93318. lowerHeightOffsetLimit: Nullable<number>;
  93319. /**
  93320. * Maximum allowed height of camera position relative to target object.
  93321. * This can help limiting how the Camera is able to move in the scene.
  93322. */
  93323. upperHeightOffsetLimit: Nullable<number>;
  93324. /**
  93325. * Define how fast the camera can accelerate to follow it s target.
  93326. */
  93327. cameraAcceleration: number;
  93328. /**
  93329. * Define the speed limit of the camera following an object.
  93330. */
  93331. maxCameraSpeed: number;
  93332. /**
  93333. * Define the target of the camera.
  93334. */
  93335. lockedTarget: Nullable<AbstractMesh>;
  93336. /**
  93337. * Defines the input associated with the camera.
  93338. */
  93339. inputs: FollowCameraInputsManager;
  93340. /**
  93341. * Instantiates the follow camera.
  93342. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93343. * @param name Define the name of the camera in the scene
  93344. * @param position Define the position of the camera
  93345. * @param scene Define the scene the camera belong to
  93346. * @param lockedTarget Define the target of the camera
  93347. */
  93348. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93349. private _follow;
  93350. /**
  93351. * Attached controls to the current camera.
  93352. * @param element Defines the element the controls should be listened from
  93353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93354. */
  93355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93356. /**
  93357. * Detach the current controls from the camera.
  93358. * The camera will stop reacting to inputs.
  93359. * @param element Defines the element to stop listening the inputs from
  93360. */
  93361. detachControl(element: HTMLElement): void;
  93362. /** @hidden */
  93363. _checkInputs(): void;
  93364. private _checkLimits;
  93365. /**
  93366. * Gets the camera class name.
  93367. * @returns the class name
  93368. */
  93369. getClassName(): string;
  93370. }
  93371. /**
  93372. * Arc Rotate version of the follow camera.
  93373. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93374. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93375. */
  93376. export class ArcFollowCamera extends TargetCamera {
  93377. /** The longitudinal angle of the camera */
  93378. alpha: number;
  93379. /** The latitudinal angle of the camera */
  93380. beta: number;
  93381. /** The radius of the camera from its target */
  93382. radius: number;
  93383. /** Define the camera target (the messh it should follow) */
  93384. target: Nullable<AbstractMesh>;
  93385. private _cartesianCoordinates;
  93386. /**
  93387. * Instantiates a new ArcFollowCamera
  93388. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93389. * @param name Define the name of the camera
  93390. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93391. * @param beta Define the rotation angle of the camera around the elevation axis
  93392. * @param radius Define the radius of the camera from its target point
  93393. * @param target Define the target of the camera
  93394. * @param scene Define the scene the camera belongs to
  93395. */
  93396. constructor(name: string,
  93397. /** The longitudinal angle of the camera */
  93398. alpha: number,
  93399. /** The latitudinal angle of the camera */
  93400. beta: number,
  93401. /** The radius of the camera from its target */
  93402. radius: number,
  93403. /** Define the camera target (the messh it should follow) */
  93404. target: Nullable<AbstractMesh>, scene: Scene);
  93405. private _follow;
  93406. /** @hidden */
  93407. _checkInputs(): void;
  93408. /**
  93409. * Returns the class name of the object.
  93410. * It is mostly used internally for serialization purposes.
  93411. */
  93412. getClassName(): string;
  93413. }
  93414. }
  93415. declare module BABYLON {
  93416. /**
  93417. * Manage the keyboard inputs to control the movement of a follow camera.
  93418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93419. */
  93420. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93421. /**
  93422. * Defines the camera the input is attached to.
  93423. */
  93424. camera: FollowCamera;
  93425. /**
  93426. * Defines the list of key codes associated with the up action (increase heightOffset)
  93427. */
  93428. keysHeightOffsetIncr: number[];
  93429. /**
  93430. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93431. */
  93432. keysHeightOffsetDecr: number[];
  93433. /**
  93434. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93435. */
  93436. keysHeightOffsetModifierAlt: boolean;
  93437. /**
  93438. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93439. */
  93440. keysHeightOffsetModifierCtrl: boolean;
  93441. /**
  93442. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93443. */
  93444. keysHeightOffsetModifierShift: boolean;
  93445. /**
  93446. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93447. */
  93448. keysRotationOffsetIncr: number[];
  93449. /**
  93450. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93451. */
  93452. keysRotationOffsetDecr: number[];
  93453. /**
  93454. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93455. */
  93456. keysRotationOffsetModifierAlt: boolean;
  93457. /**
  93458. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93459. */
  93460. keysRotationOffsetModifierCtrl: boolean;
  93461. /**
  93462. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93463. */
  93464. keysRotationOffsetModifierShift: boolean;
  93465. /**
  93466. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93467. */
  93468. keysRadiusIncr: number[];
  93469. /**
  93470. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93471. */
  93472. keysRadiusDecr: number[];
  93473. /**
  93474. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93475. */
  93476. keysRadiusModifierAlt: boolean;
  93477. /**
  93478. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93479. */
  93480. keysRadiusModifierCtrl: boolean;
  93481. /**
  93482. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93483. */
  93484. keysRadiusModifierShift: boolean;
  93485. /**
  93486. * Defines the rate of change of heightOffset.
  93487. */
  93488. heightSensibility: number;
  93489. /**
  93490. * Defines the rate of change of rotationOffset.
  93491. */
  93492. rotationSensibility: number;
  93493. /**
  93494. * Defines the rate of change of radius.
  93495. */
  93496. radiusSensibility: number;
  93497. private _keys;
  93498. private _ctrlPressed;
  93499. private _altPressed;
  93500. private _shiftPressed;
  93501. private _onCanvasBlurObserver;
  93502. private _onKeyboardObserver;
  93503. private _engine;
  93504. private _scene;
  93505. /**
  93506. * Attach the input controls to a specific dom element to get the input from.
  93507. * @param element Defines the element the controls should be listened from
  93508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93509. */
  93510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93511. /**
  93512. * Detach the current controls from the specified dom element.
  93513. * @param element Defines the element to stop listening the inputs from
  93514. */
  93515. detachControl(element: Nullable<HTMLElement>): void;
  93516. /**
  93517. * Update the current camera state depending on the inputs that have been used this frame.
  93518. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93519. */
  93520. checkInputs(): void;
  93521. /**
  93522. * Gets the class name of the current input.
  93523. * @returns the class name
  93524. */
  93525. getClassName(): string;
  93526. /**
  93527. * Get the friendly name associated with the input class.
  93528. * @returns the input friendly name
  93529. */
  93530. getSimpleName(): string;
  93531. /**
  93532. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93533. * allow modification of the heightOffset value.
  93534. */
  93535. private _modifierHeightOffset;
  93536. /**
  93537. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93538. * allow modification of the rotationOffset value.
  93539. */
  93540. private _modifierRotationOffset;
  93541. /**
  93542. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93543. * allow modification of the radius value.
  93544. */
  93545. private _modifierRadius;
  93546. }
  93547. }
  93548. declare module BABYLON {
  93549. interface FreeCameraInputsManager {
  93550. /**
  93551. * Add orientation input support to the input manager.
  93552. * @returns the current input manager
  93553. */
  93554. addDeviceOrientation(): FreeCameraInputsManager;
  93555. }
  93556. /**
  93557. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  93558. * Screen rotation is taken into account.
  93559. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93560. */
  93561. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  93562. private _camera;
  93563. private _screenOrientationAngle;
  93564. private _constantTranform;
  93565. private _screenQuaternion;
  93566. private _alpha;
  93567. private _beta;
  93568. private _gamma;
  93569. /**
  93570. * Instantiates a new input
  93571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93572. */
  93573. constructor();
  93574. /**
  93575. * Define the camera controlled by the input.
  93576. */
  93577. camera: FreeCamera;
  93578. /**
  93579. * Attach the input controls to a specific dom element to get the input from.
  93580. * @param element Defines the element the controls should be listened from
  93581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93582. */
  93583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93584. private _orientationChanged;
  93585. private _deviceOrientation;
  93586. /**
  93587. * Detach the current controls from the specified dom element.
  93588. * @param element Defines the element to stop listening the inputs from
  93589. */
  93590. detachControl(element: Nullable<HTMLElement>): void;
  93591. /**
  93592. * Update the current camera state depending on the inputs that have been used this frame.
  93593. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93594. */
  93595. checkInputs(): void;
  93596. /**
  93597. * Gets the class name of the current intput.
  93598. * @returns the class name
  93599. */
  93600. getClassName(): string;
  93601. /**
  93602. * Get the friendly name associated with the input class.
  93603. * @returns the input friendly name
  93604. */
  93605. getSimpleName(): string;
  93606. }
  93607. }
  93608. declare module BABYLON {
  93609. /**
  93610. * Manage the gamepad inputs to control a free camera.
  93611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93612. */
  93613. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  93614. /**
  93615. * Define the camera the input is attached to.
  93616. */
  93617. camera: FreeCamera;
  93618. /**
  93619. * Define the Gamepad controlling the input
  93620. */
  93621. gamepad: Nullable<Gamepad>;
  93622. /**
  93623. * Defines the gamepad rotation sensiblity.
  93624. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93625. */
  93626. gamepadAngularSensibility: number;
  93627. /**
  93628. * Defines the gamepad move sensiblity.
  93629. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93630. */
  93631. gamepadMoveSensibility: number;
  93632. private _onGamepadConnectedObserver;
  93633. private _onGamepadDisconnectedObserver;
  93634. private _cameraTransform;
  93635. private _deltaTransform;
  93636. private _vector3;
  93637. private _vector2;
  93638. /**
  93639. * Attach the input controls to a specific dom element to get the input from.
  93640. * @param element Defines the element the controls should be listened from
  93641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93642. */
  93643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93644. /**
  93645. * Detach the current controls from the specified dom element.
  93646. * @param element Defines the element to stop listening the inputs from
  93647. */
  93648. detachControl(element: Nullable<HTMLElement>): void;
  93649. /**
  93650. * Update the current camera state depending on the inputs that have been used this frame.
  93651. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93652. */
  93653. checkInputs(): void;
  93654. /**
  93655. * Gets the class name of the current intput.
  93656. * @returns the class name
  93657. */
  93658. getClassName(): string;
  93659. /**
  93660. * Get the friendly name associated with the input class.
  93661. * @returns the input friendly name
  93662. */
  93663. getSimpleName(): string;
  93664. }
  93665. }
  93666. declare module BABYLON {
  93667. /**
  93668. * Defines the potential axis of a Joystick
  93669. */
  93670. export enum JoystickAxis {
  93671. /** X axis */
  93672. X = 0,
  93673. /** Y axis */
  93674. Y = 1,
  93675. /** Z axis */
  93676. Z = 2
  93677. }
  93678. /**
  93679. * Class used to define virtual joystick (used in touch mode)
  93680. */
  93681. export class VirtualJoystick {
  93682. /**
  93683. * Gets or sets a boolean indicating that left and right values must be inverted
  93684. */
  93685. reverseLeftRight: boolean;
  93686. /**
  93687. * Gets or sets a boolean indicating that up and down values must be inverted
  93688. */
  93689. reverseUpDown: boolean;
  93690. /**
  93691. * Gets the offset value for the position (ie. the change of the position value)
  93692. */
  93693. deltaPosition: Vector3;
  93694. /**
  93695. * Gets a boolean indicating if the virtual joystick was pressed
  93696. */
  93697. pressed: boolean;
  93698. /**
  93699. * Canvas the virtual joystick will render onto, default z-index of this is 5
  93700. */
  93701. static Canvas: Nullable<HTMLCanvasElement>;
  93702. private static _globalJoystickIndex;
  93703. private static vjCanvasContext;
  93704. private static vjCanvasWidth;
  93705. private static vjCanvasHeight;
  93706. private static halfWidth;
  93707. private _action;
  93708. private _axisTargetedByLeftAndRight;
  93709. private _axisTargetedByUpAndDown;
  93710. private _joystickSensibility;
  93711. private _inversedSensibility;
  93712. private _joystickPointerID;
  93713. private _joystickColor;
  93714. private _joystickPointerPos;
  93715. private _joystickPreviousPointerPos;
  93716. private _joystickPointerStartPos;
  93717. private _deltaJoystickVector;
  93718. private _leftJoystick;
  93719. private _touches;
  93720. private _onPointerDownHandlerRef;
  93721. private _onPointerMoveHandlerRef;
  93722. private _onPointerUpHandlerRef;
  93723. private _onResize;
  93724. /**
  93725. * Creates a new virtual joystick
  93726. * @param leftJoystick defines that the joystick is for left hand (false by default)
  93727. */
  93728. constructor(leftJoystick?: boolean);
  93729. /**
  93730. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  93731. * @param newJoystickSensibility defines the new sensibility
  93732. */
  93733. setJoystickSensibility(newJoystickSensibility: number): void;
  93734. private _onPointerDown;
  93735. private _onPointerMove;
  93736. private _onPointerUp;
  93737. /**
  93738. * Change the color of the virtual joystick
  93739. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  93740. */
  93741. setJoystickColor(newColor: string): void;
  93742. /**
  93743. * Defines a callback to call when the joystick is touched
  93744. * @param action defines the callback
  93745. */
  93746. setActionOnTouch(action: () => any): void;
  93747. /**
  93748. * Defines which axis you'd like to control for left & right
  93749. * @param axis defines the axis to use
  93750. */
  93751. setAxisForLeftRight(axis: JoystickAxis): void;
  93752. /**
  93753. * Defines which axis you'd like to control for up & down
  93754. * @param axis defines the axis to use
  93755. */
  93756. setAxisForUpDown(axis: JoystickAxis): void;
  93757. private _drawVirtualJoystick;
  93758. /**
  93759. * Release internal HTML canvas
  93760. */
  93761. releaseCanvas(): void;
  93762. }
  93763. }
  93764. declare module BABYLON {
  93765. interface FreeCameraInputsManager {
  93766. /**
  93767. * Add virtual joystick input support to the input manager.
  93768. * @returns the current input manager
  93769. */
  93770. addVirtualJoystick(): FreeCameraInputsManager;
  93771. }
  93772. /**
  93773. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  93774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93775. */
  93776. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  93777. /**
  93778. * Defines the camera the input is attached to.
  93779. */
  93780. camera: FreeCamera;
  93781. private _leftjoystick;
  93782. private _rightjoystick;
  93783. /**
  93784. * Gets the left stick of the virtual joystick.
  93785. * @returns The virtual Joystick
  93786. */
  93787. getLeftJoystick(): VirtualJoystick;
  93788. /**
  93789. * Gets the right stick of the virtual joystick.
  93790. * @returns The virtual Joystick
  93791. */
  93792. getRightJoystick(): VirtualJoystick;
  93793. /**
  93794. * Update the current camera state depending on the inputs that have been used this frame.
  93795. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93796. */
  93797. checkInputs(): void;
  93798. /**
  93799. * Attach the input controls to a specific dom element to get the input from.
  93800. * @param element Defines the element the controls should be listened from
  93801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93802. */
  93803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93804. /**
  93805. * Detach the current controls from the specified dom element.
  93806. * @param element Defines the element to stop listening the inputs from
  93807. */
  93808. detachControl(element: Nullable<HTMLElement>): void;
  93809. /**
  93810. * Gets the class name of the current intput.
  93811. * @returns the class name
  93812. */
  93813. getClassName(): string;
  93814. /**
  93815. * Get the friendly name associated with the input class.
  93816. * @returns the input friendly name
  93817. */
  93818. getSimpleName(): string;
  93819. }
  93820. }
  93821. declare module BABYLON {
  93822. /**
  93823. * This represents a FPS type of camera controlled by touch.
  93824. * This is like a universal camera minus the Gamepad controls.
  93825. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93826. */
  93827. export class TouchCamera extends FreeCamera {
  93828. /**
  93829. * Defines the touch sensibility for rotation.
  93830. * The higher the faster.
  93831. */
  93832. touchAngularSensibility: number;
  93833. /**
  93834. * Defines the touch sensibility for move.
  93835. * The higher the faster.
  93836. */
  93837. touchMoveSensibility: number;
  93838. /**
  93839. * Instantiates a new touch camera.
  93840. * This represents a FPS type of camera controlled by touch.
  93841. * This is like a universal camera minus the Gamepad controls.
  93842. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93843. * @param name Define the name of the camera in the scene
  93844. * @param position Define the start position of the camera in the scene
  93845. * @param scene Define the scene the camera belongs to
  93846. */
  93847. constructor(name: string, position: Vector3, scene: Scene);
  93848. /**
  93849. * Gets the current object class name.
  93850. * @return the class name
  93851. */
  93852. getClassName(): string;
  93853. /** @hidden */
  93854. _setupInputs(): void;
  93855. }
  93856. }
  93857. declare module BABYLON {
  93858. /**
  93859. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  93860. * being tilted forward or back and left or right.
  93861. */
  93862. export class DeviceOrientationCamera extends FreeCamera {
  93863. private _initialQuaternion;
  93864. private _quaternionCache;
  93865. /**
  93866. * Creates a new device orientation camera
  93867. * @param name The name of the camera
  93868. * @param position The start position camera
  93869. * @param scene The scene the camera belongs to
  93870. */
  93871. constructor(name: string, position: Vector3, scene: Scene);
  93872. /**
  93873. * Gets the current instance class name ("DeviceOrientationCamera").
  93874. * This helps avoiding instanceof at run time.
  93875. * @returns the class name
  93876. */
  93877. getClassName(): string;
  93878. /**
  93879. * @hidden
  93880. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  93881. */
  93882. _checkInputs(): void;
  93883. /**
  93884. * Reset the camera to its default orientation on the specified axis only.
  93885. * @param axis The axis to reset
  93886. */
  93887. resetToCurrentRotation(axis?: Axis): void;
  93888. }
  93889. }
  93890. declare module BABYLON {
  93891. /**
  93892. * 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,
  93893. * which still works and will still be found in many Playgrounds.
  93894. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93895. */
  93896. export class UniversalCamera extends TouchCamera {
  93897. /**
  93898. * Defines the gamepad rotation sensiblity.
  93899. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93900. */
  93901. gamepadAngularSensibility: number;
  93902. /**
  93903. * Defines the gamepad move sensiblity.
  93904. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93905. */
  93906. gamepadMoveSensibility: number;
  93907. /**
  93908. * 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,
  93909. * which still works and will still be found in many Playgrounds.
  93910. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93911. * @param name Define the name of the camera in the scene
  93912. * @param position Define the start position of the camera in the scene
  93913. * @param scene Define the scene the camera belongs to
  93914. */
  93915. constructor(name: string, position: Vector3, scene: Scene);
  93916. /**
  93917. * Gets the current object class name.
  93918. * @return the class name
  93919. */
  93920. getClassName(): string;
  93921. }
  93922. }
  93923. declare module BABYLON {
  93924. /**
  93925. * This represents a FPS type of camera. This is only here for back compat purpose.
  93926. * Please use the UniversalCamera instead as both are identical.
  93927. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93928. */
  93929. export class GamepadCamera extends UniversalCamera {
  93930. /**
  93931. * Instantiates a new Gamepad Camera
  93932. * This represents a FPS type of camera. This is only here for back compat purpose.
  93933. * Please use the UniversalCamera instead as both are identical.
  93934. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93935. * @param name Define the name of the camera in the scene
  93936. * @param position Define the start position of the camera in the scene
  93937. * @param scene Define the scene the camera belongs to
  93938. */
  93939. constructor(name: string, position: Vector3, scene: Scene);
  93940. /**
  93941. * Gets the current object class name.
  93942. * @return the class name
  93943. */
  93944. getClassName(): string;
  93945. }
  93946. }
  93947. declare module BABYLON {
  93948. /** @hidden */
  93949. export var passPixelShader: {
  93950. name: string;
  93951. shader: string;
  93952. };
  93953. }
  93954. declare module BABYLON {
  93955. /** @hidden */
  93956. export var passCubePixelShader: {
  93957. name: string;
  93958. shader: string;
  93959. };
  93960. }
  93961. declare module BABYLON {
  93962. /**
  93963. * PassPostProcess which produces an output the same as it's input
  93964. */
  93965. export class PassPostProcess extends PostProcess {
  93966. /**
  93967. * Creates the PassPostProcess
  93968. * @param name The name of the effect.
  93969. * @param options The required width/height ratio to downsize to before computing the render pass.
  93970. * @param camera The camera to apply the render pass to.
  93971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93972. * @param engine The engine which the post process will be applied. (default: current engine)
  93973. * @param reusable If the post process can be reused on the same frame. (default: false)
  93974. * @param textureType The type of texture to be used when performing the post processing.
  93975. * @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)
  93976. */
  93977. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93978. }
  93979. /**
  93980. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  93981. */
  93982. export class PassCubePostProcess extends PostProcess {
  93983. private _face;
  93984. /**
  93985. * Gets or sets the cube face to display.
  93986. * * 0 is +X
  93987. * * 1 is -X
  93988. * * 2 is +Y
  93989. * * 3 is -Y
  93990. * * 4 is +Z
  93991. * * 5 is -Z
  93992. */
  93993. face: number;
  93994. /**
  93995. * Creates the PassCubePostProcess
  93996. * @param name The name of the effect.
  93997. * @param options The required width/height ratio to downsize to before computing the render pass.
  93998. * @param camera The camera to apply the render pass to.
  93999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94000. * @param engine The engine which the post process will be applied. (default: current engine)
  94001. * @param reusable If the post process can be reused on the same frame. (default: false)
  94002. * @param textureType The type of texture to be used when performing the post processing.
  94003. * @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)
  94004. */
  94005. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94006. }
  94007. }
  94008. declare module BABYLON {
  94009. /** @hidden */
  94010. export var anaglyphPixelShader: {
  94011. name: string;
  94012. shader: string;
  94013. };
  94014. }
  94015. declare module BABYLON {
  94016. /**
  94017. * Postprocess used to generate anaglyphic rendering
  94018. */
  94019. export class AnaglyphPostProcess extends PostProcess {
  94020. private _passedProcess;
  94021. /**
  94022. * Creates a new AnaglyphPostProcess
  94023. * @param name defines postprocess name
  94024. * @param options defines creation options or target ratio scale
  94025. * @param rigCameras defines cameras using this postprocess
  94026. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94027. * @param engine defines hosting engine
  94028. * @param reusable defines if the postprocess will be reused multiple times per frame
  94029. */
  94030. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94031. }
  94032. }
  94033. declare module BABYLON {
  94034. /**
  94035. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94036. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94037. */
  94038. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94039. /**
  94040. * Creates a new AnaglyphArcRotateCamera
  94041. * @param name defines camera name
  94042. * @param alpha defines alpha angle (in radians)
  94043. * @param beta defines beta angle (in radians)
  94044. * @param radius defines radius
  94045. * @param target defines camera target
  94046. * @param interaxialDistance defines distance between each color axis
  94047. * @param scene defines the hosting scene
  94048. */
  94049. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94050. /**
  94051. * Gets camera class name
  94052. * @returns AnaglyphArcRotateCamera
  94053. */
  94054. getClassName(): string;
  94055. }
  94056. }
  94057. declare module BABYLON {
  94058. /**
  94059. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94060. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94061. */
  94062. export class AnaglyphFreeCamera extends FreeCamera {
  94063. /**
  94064. * Creates a new AnaglyphFreeCamera
  94065. * @param name defines camera name
  94066. * @param position defines initial position
  94067. * @param interaxialDistance defines distance between each color axis
  94068. * @param scene defines the hosting scene
  94069. */
  94070. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94071. /**
  94072. * Gets camera class name
  94073. * @returns AnaglyphFreeCamera
  94074. */
  94075. getClassName(): string;
  94076. }
  94077. }
  94078. declare module BABYLON {
  94079. /**
  94080. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94081. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94082. */
  94083. export class AnaglyphGamepadCamera extends GamepadCamera {
  94084. /**
  94085. * Creates a new AnaglyphGamepadCamera
  94086. * @param name defines camera name
  94087. * @param position defines initial position
  94088. * @param interaxialDistance defines distance between each color axis
  94089. * @param scene defines the hosting scene
  94090. */
  94091. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94092. /**
  94093. * Gets camera class name
  94094. * @returns AnaglyphGamepadCamera
  94095. */
  94096. getClassName(): string;
  94097. }
  94098. }
  94099. declare module BABYLON {
  94100. /**
  94101. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94102. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94103. */
  94104. export class AnaglyphUniversalCamera extends UniversalCamera {
  94105. /**
  94106. * Creates a new AnaglyphUniversalCamera
  94107. * @param name defines camera name
  94108. * @param position defines initial position
  94109. * @param interaxialDistance defines distance between each color axis
  94110. * @param scene defines the hosting scene
  94111. */
  94112. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94113. /**
  94114. * Gets camera class name
  94115. * @returns AnaglyphUniversalCamera
  94116. */
  94117. getClassName(): string;
  94118. }
  94119. }
  94120. declare module BABYLON {
  94121. /** @hidden */
  94122. export var stereoscopicInterlacePixelShader: {
  94123. name: string;
  94124. shader: string;
  94125. };
  94126. }
  94127. declare module BABYLON {
  94128. /**
  94129. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94130. */
  94131. export class StereoscopicInterlacePostProcess extends PostProcess {
  94132. private _stepSize;
  94133. private _passedProcess;
  94134. /**
  94135. * Initializes a StereoscopicInterlacePostProcess
  94136. * @param name The name of the effect.
  94137. * @param rigCameras The rig cameras to be appled to the post process
  94138. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94140. * @param engine The engine which the post process will be applied. (default: current engine)
  94141. * @param reusable If the post process can be reused on the same frame. (default: false)
  94142. */
  94143. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94144. }
  94145. }
  94146. declare module BABYLON {
  94147. /**
  94148. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94149. * @see http://doc.babylonjs.com/features/cameras
  94150. */
  94151. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94152. /**
  94153. * Creates a new StereoscopicArcRotateCamera
  94154. * @param name defines camera name
  94155. * @param alpha defines alpha angle (in radians)
  94156. * @param beta defines beta angle (in radians)
  94157. * @param radius defines radius
  94158. * @param target defines camera target
  94159. * @param interaxialDistance defines distance between each color axis
  94160. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94161. * @param scene defines the hosting scene
  94162. */
  94163. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94164. /**
  94165. * Gets camera class name
  94166. * @returns StereoscopicArcRotateCamera
  94167. */
  94168. getClassName(): string;
  94169. }
  94170. }
  94171. declare module BABYLON {
  94172. /**
  94173. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94174. * @see http://doc.babylonjs.com/features/cameras
  94175. */
  94176. export class StereoscopicFreeCamera extends FreeCamera {
  94177. /**
  94178. * Creates a new StereoscopicFreeCamera
  94179. * @param name defines camera name
  94180. * @param position defines initial position
  94181. * @param interaxialDistance defines distance between each color axis
  94182. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94183. * @param scene defines the hosting scene
  94184. */
  94185. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94186. /**
  94187. * Gets camera class name
  94188. * @returns StereoscopicFreeCamera
  94189. */
  94190. getClassName(): string;
  94191. }
  94192. }
  94193. declare module BABYLON {
  94194. /**
  94195. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94196. * @see http://doc.babylonjs.com/features/cameras
  94197. */
  94198. export class StereoscopicGamepadCamera extends GamepadCamera {
  94199. /**
  94200. * Creates a new StereoscopicGamepadCamera
  94201. * @param name defines camera name
  94202. * @param position defines initial position
  94203. * @param interaxialDistance defines distance between each color axis
  94204. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94205. * @param scene defines the hosting scene
  94206. */
  94207. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94208. /**
  94209. * Gets camera class name
  94210. * @returns StereoscopicGamepadCamera
  94211. */
  94212. getClassName(): string;
  94213. }
  94214. }
  94215. declare module BABYLON {
  94216. /**
  94217. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94218. * @see http://doc.babylonjs.com/features/cameras
  94219. */
  94220. export class StereoscopicUniversalCamera extends UniversalCamera {
  94221. /**
  94222. * Creates a new StereoscopicUniversalCamera
  94223. * @param name defines camera name
  94224. * @param position defines initial position
  94225. * @param interaxialDistance defines distance between each color axis
  94226. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94227. * @param scene defines the hosting scene
  94228. */
  94229. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94230. /**
  94231. * Gets camera class name
  94232. * @returns StereoscopicUniversalCamera
  94233. */
  94234. getClassName(): string;
  94235. }
  94236. }
  94237. declare module BABYLON {
  94238. /**
  94239. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94240. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94241. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94242. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94243. */
  94244. export class VirtualJoysticksCamera extends FreeCamera {
  94245. /**
  94246. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94247. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94248. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94249. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94250. * @param name Define the name of the camera in the scene
  94251. * @param position Define the start position of the camera in the scene
  94252. * @param scene Define the scene the camera belongs to
  94253. */
  94254. constructor(name: string, position: Vector3, scene: Scene);
  94255. /**
  94256. * Gets the current object class name.
  94257. * @return the class name
  94258. */
  94259. getClassName(): string;
  94260. }
  94261. }
  94262. declare module BABYLON {
  94263. /**
  94264. * This represents all the required metrics to create a VR camera.
  94265. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94266. */
  94267. export class VRCameraMetrics {
  94268. /**
  94269. * Define the horizontal resolution off the screen.
  94270. */
  94271. hResolution: number;
  94272. /**
  94273. * Define the vertical resolution off the screen.
  94274. */
  94275. vResolution: number;
  94276. /**
  94277. * Define the horizontal screen size.
  94278. */
  94279. hScreenSize: number;
  94280. /**
  94281. * Define the vertical screen size.
  94282. */
  94283. vScreenSize: number;
  94284. /**
  94285. * Define the vertical screen center position.
  94286. */
  94287. vScreenCenter: number;
  94288. /**
  94289. * Define the distance of the eyes to the screen.
  94290. */
  94291. eyeToScreenDistance: number;
  94292. /**
  94293. * Define the distance between both lenses
  94294. */
  94295. lensSeparationDistance: number;
  94296. /**
  94297. * Define the distance between both viewer's eyes.
  94298. */
  94299. interpupillaryDistance: number;
  94300. /**
  94301. * Define the distortion factor of the VR postprocess.
  94302. * Please, touch with care.
  94303. */
  94304. distortionK: number[];
  94305. /**
  94306. * Define the chromatic aberration correction factors for the VR post process.
  94307. */
  94308. chromaAbCorrection: number[];
  94309. /**
  94310. * Define the scale factor of the post process.
  94311. * The smaller the better but the slower.
  94312. */
  94313. postProcessScaleFactor: number;
  94314. /**
  94315. * Define an offset for the lens center.
  94316. */
  94317. lensCenterOffset: number;
  94318. /**
  94319. * Define if the current vr camera should compensate the distortion of the lense or not.
  94320. */
  94321. compensateDistortion: boolean;
  94322. /**
  94323. * Gets the rendering aspect ratio based on the provided resolutions.
  94324. */
  94325. readonly aspectRatio: number;
  94326. /**
  94327. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94328. */
  94329. readonly aspectRatioFov: number;
  94330. /**
  94331. * @hidden
  94332. */
  94333. readonly leftHMatrix: Matrix;
  94334. /**
  94335. * @hidden
  94336. */
  94337. readonly rightHMatrix: Matrix;
  94338. /**
  94339. * @hidden
  94340. */
  94341. readonly leftPreViewMatrix: Matrix;
  94342. /**
  94343. * @hidden
  94344. */
  94345. readonly rightPreViewMatrix: Matrix;
  94346. /**
  94347. * Get the default VRMetrics based on the most generic setup.
  94348. * @returns the default vr metrics
  94349. */
  94350. static GetDefault(): VRCameraMetrics;
  94351. }
  94352. }
  94353. declare module BABYLON {
  94354. /** @hidden */
  94355. export var vrDistortionCorrectionPixelShader: {
  94356. name: string;
  94357. shader: string;
  94358. };
  94359. }
  94360. declare module BABYLON {
  94361. /**
  94362. * VRDistortionCorrectionPostProcess used for mobile VR
  94363. */
  94364. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94365. private _isRightEye;
  94366. private _distortionFactors;
  94367. private _postProcessScaleFactor;
  94368. private _lensCenterOffset;
  94369. private _scaleIn;
  94370. private _scaleFactor;
  94371. private _lensCenter;
  94372. /**
  94373. * Initializes the VRDistortionCorrectionPostProcess
  94374. * @param name The name of the effect.
  94375. * @param camera The camera to apply the render pass to.
  94376. * @param isRightEye If this is for the right eye distortion
  94377. * @param vrMetrics All the required metrics for the VR camera
  94378. */
  94379. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94380. }
  94381. }
  94382. declare module BABYLON {
  94383. /**
  94384. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94385. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94386. */
  94387. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94388. /**
  94389. * Creates a new VRDeviceOrientationArcRotateCamera
  94390. * @param name defines camera name
  94391. * @param alpha defines the camera rotation along the logitudinal axis
  94392. * @param beta defines the camera rotation along the latitudinal axis
  94393. * @param radius defines the camera distance from its target
  94394. * @param target defines the camera target
  94395. * @param scene defines the scene the camera belongs to
  94396. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94397. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94398. */
  94399. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94400. /**
  94401. * Gets camera class name
  94402. * @returns VRDeviceOrientationArcRotateCamera
  94403. */
  94404. getClassName(): string;
  94405. }
  94406. }
  94407. declare module BABYLON {
  94408. /**
  94409. * Camera used to simulate VR rendering (based on FreeCamera)
  94410. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94411. */
  94412. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94413. /**
  94414. * Creates a new VRDeviceOrientationFreeCamera
  94415. * @param name defines camera name
  94416. * @param position defines the start position of the camera
  94417. * @param scene defines the scene the camera belongs to
  94418. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94419. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94420. */
  94421. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94422. /**
  94423. * Gets camera class name
  94424. * @returns VRDeviceOrientationFreeCamera
  94425. */
  94426. getClassName(): string;
  94427. }
  94428. }
  94429. declare module BABYLON {
  94430. /**
  94431. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94432. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94433. */
  94434. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94435. /**
  94436. * Creates a new VRDeviceOrientationGamepadCamera
  94437. * @param name defines camera name
  94438. * @param position defines the start position of the camera
  94439. * @param scene defines the scene the camera belongs to
  94440. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94441. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94442. */
  94443. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94444. /**
  94445. * Gets camera class name
  94446. * @returns VRDeviceOrientationGamepadCamera
  94447. */
  94448. getClassName(): string;
  94449. }
  94450. }
  94451. declare module BABYLON {
  94452. /**
  94453. * Defines supported buttons for XBox360 compatible gamepads
  94454. */
  94455. export enum Xbox360Button {
  94456. /** A */
  94457. A = 0,
  94458. /** B */
  94459. B = 1,
  94460. /** X */
  94461. X = 2,
  94462. /** Y */
  94463. Y = 3,
  94464. /** Start */
  94465. Start = 4,
  94466. /** Back */
  94467. Back = 5,
  94468. /** Left button */
  94469. LB = 6,
  94470. /** Right button */
  94471. RB = 7,
  94472. /** Left stick */
  94473. LeftStick = 8,
  94474. /** Right stick */
  94475. RightStick = 9
  94476. }
  94477. /** Defines values for XBox360 DPad */
  94478. export enum Xbox360Dpad {
  94479. /** Up */
  94480. Up = 0,
  94481. /** Down */
  94482. Down = 1,
  94483. /** Left */
  94484. Left = 2,
  94485. /** Right */
  94486. Right = 3
  94487. }
  94488. /**
  94489. * Defines a XBox360 gamepad
  94490. */
  94491. export class Xbox360Pad extends Gamepad {
  94492. private _leftTrigger;
  94493. private _rightTrigger;
  94494. private _onlefttriggerchanged;
  94495. private _onrighttriggerchanged;
  94496. private _onbuttondown;
  94497. private _onbuttonup;
  94498. private _ondpaddown;
  94499. private _ondpadup;
  94500. /** Observable raised when a button is pressed */
  94501. onButtonDownObservable: Observable<Xbox360Button>;
  94502. /** Observable raised when a button is released */
  94503. onButtonUpObservable: Observable<Xbox360Button>;
  94504. /** Observable raised when a pad is pressed */
  94505. onPadDownObservable: Observable<Xbox360Dpad>;
  94506. /** Observable raised when a pad is released */
  94507. onPadUpObservable: Observable<Xbox360Dpad>;
  94508. private _buttonA;
  94509. private _buttonB;
  94510. private _buttonX;
  94511. private _buttonY;
  94512. private _buttonBack;
  94513. private _buttonStart;
  94514. private _buttonLB;
  94515. private _buttonRB;
  94516. private _buttonLeftStick;
  94517. private _buttonRightStick;
  94518. private _dPadUp;
  94519. private _dPadDown;
  94520. private _dPadLeft;
  94521. private _dPadRight;
  94522. private _isXboxOnePad;
  94523. /**
  94524. * Creates a new XBox360 gamepad object
  94525. * @param id defines the id of this gamepad
  94526. * @param index defines its index
  94527. * @param gamepad defines the internal HTML gamepad object
  94528. * @param xboxOne defines if it is a XBox One gamepad
  94529. */
  94530. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  94531. /**
  94532. * Defines the callback to call when left trigger is pressed
  94533. * @param callback defines the callback to use
  94534. */
  94535. onlefttriggerchanged(callback: (value: number) => void): void;
  94536. /**
  94537. * Defines the callback to call when right trigger is pressed
  94538. * @param callback defines the callback to use
  94539. */
  94540. onrighttriggerchanged(callback: (value: number) => void): void;
  94541. /**
  94542. * Gets the left trigger value
  94543. */
  94544. /**
  94545. * Sets the left trigger value
  94546. */
  94547. leftTrigger: number;
  94548. /**
  94549. * Gets the right trigger value
  94550. */
  94551. /**
  94552. * Sets the right trigger value
  94553. */
  94554. rightTrigger: number;
  94555. /**
  94556. * Defines the callback to call when a button is pressed
  94557. * @param callback defines the callback to use
  94558. */
  94559. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  94560. /**
  94561. * Defines the callback to call when a button is released
  94562. * @param callback defines the callback to use
  94563. */
  94564. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  94565. /**
  94566. * Defines the callback to call when a pad is pressed
  94567. * @param callback defines the callback to use
  94568. */
  94569. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  94570. /**
  94571. * Defines the callback to call when a pad is released
  94572. * @param callback defines the callback to use
  94573. */
  94574. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  94575. private _setButtonValue;
  94576. private _setDPadValue;
  94577. /**
  94578. * Gets the value of the `A` button
  94579. */
  94580. /**
  94581. * Sets the value of the `A` button
  94582. */
  94583. buttonA: number;
  94584. /**
  94585. * Gets the value of the `B` button
  94586. */
  94587. /**
  94588. * Sets the value of the `B` button
  94589. */
  94590. buttonB: number;
  94591. /**
  94592. * Gets the value of the `X` button
  94593. */
  94594. /**
  94595. * Sets the value of the `X` button
  94596. */
  94597. buttonX: number;
  94598. /**
  94599. * Gets the value of the `Y` button
  94600. */
  94601. /**
  94602. * Sets the value of the `Y` button
  94603. */
  94604. buttonY: number;
  94605. /**
  94606. * Gets the value of the `Start` button
  94607. */
  94608. /**
  94609. * Sets the value of the `Start` button
  94610. */
  94611. buttonStart: number;
  94612. /**
  94613. * Gets the value of the `Back` button
  94614. */
  94615. /**
  94616. * Sets the value of the `Back` button
  94617. */
  94618. buttonBack: number;
  94619. /**
  94620. * Gets the value of the `Left` button
  94621. */
  94622. /**
  94623. * Sets the value of the `Left` button
  94624. */
  94625. buttonLB: number;
  94626. /**
  94627. * Gets the value of the `Right` button
  94628. */
  94629. /**
  94630. * Sets the value of the `Right` button
  94631. */
  94632. buttonRB: number;
  94633. /**
  94634. * Gets the value of the Left joystick
  94635. */
  94636. /**
  94637. * Sets the value of the Left joystick
  94638. */
  94639. buttonLeftStick: number;
  94640. /**
  94641. * Gets the value of the Right joystick
  94642. */
  94643. /**
  94644. * Sets the value of the Right joystick
  94645. */
  94646. buttonRightStick: number;
  94647. /**
  94648. * Gets the value of D-pad up
  94649. */
  94650. /**
  94651. * Sets the value of D-pad up
  94652. */
  94653. dPadUp: number;
  94654. /**
  94655. * Gets the value of D-pad down
  94656. */
  94657. /**
  94658. * Sets the value of D-pad down
  94659. */
  94660. dPadDown: number;
  94661. /**
  94662. * Gets the value of D-pad left
  94663. */
  94664. /**
  94665. * Sets the value of D-pad left
  94666. */
  94667. dPadLeft: number;
  94668. /**
  94669. * Gets the value of D-pad right
  94670. */
  94671. /**
  94672. * Sets the value of D-pad right
  94673. */
  94674. dPadRight: number;
  94675. /**
  94676. * Force the gamepad to synchronize with device values
  94677. */
  94678. update(): void;
  94679. /**
  94680. * Disposes the gamepad
  94681. */
  94682. dispose(): void;
  94683. }
  94684. }
  94685. declare module BABYLON {
  94686. /**
  94687. * Base class of materials working in push mode in babylon JS
  94688. * @hidden
  94689. */
  94690. export class PushMaterial extends Material {
  94691. protected _activeEffect: Effect;
  94692. protected _normalMatrix: Matrix;
  94693. /**
  94694. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94695. * This means that the material can keep using a previous shader while a new one is being compiled.
  94696. * This is mostly used when shader parallel compilation is supported (true by default)
  94697. */
  94698. allowShaderHotSwapping: boolean;
  94699. constructor(name: string, scene: Scene);
  94700. getEffect(): Effect;
  94701. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94702. /**
  94703. * Binds the given world matrix to the active effect
  94704. *
  94705. * @param world the matrix to bind
  94706. */
  94707. bindOnlyWorldMatrix(world: Matrix): void;
  94708. /**
  94709. * Binds the given normal matrix to the active effect
  94710. *
  94711. * @param normalMatrix the matrix to bind
  94712. */
  94713. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94714. bind(world: Matrix, mesh?: Mesh): void;
  94715. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94716. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94717. }
  94718. }
  94719. declare module BABYLON {
  94720. /**
  94721. * This groups all the flags used to control the materials channel.
  94722. */
  94723. export class MaterialFlags {
  94724. private static _DiffuseTextureEnabled;
  94725. /**
  94726. * Are diffuse textures enabled in the application.
  94727. */
  94728. static DiffuseTextureEnabled: boolean;
  94729. private static _AmbientTextureEnabled;
  94730. /**
  94731. * Are ambient textures enabled in the application.
  94732. */
  94733. static AmbientTextureEnabled: boolean;
  94734. private static _OpacityTextureEnabled;
  94735. /**
  94736. * Are opacity textures enabled in the application.
  94737. */
  94738. static OpacityTextureEnabled: boolean;
  94739. private static _ReflectionTextureEnabled;
  94740. /**
  94741. * Are reflection textures enabled in the application.
  94742. */
  94743. static ReflectionTextureEnabled: boolean;
  94744. private static _EmissiveTextureEnabled;
  94745. /**
  94746. * Are emissive textures enabled in the application.
  94747. */
  94748. static EmissiveTextureEnabled: boolean;
  94749. private static _SpecularTextureEnabled;
  94750. /**
  94751. * Are specular textures enabled in the application.
  94752. */
  94753. static SpecularTextureEnabled: boolean;
  94754. private static _BumpTextureEnabled;
  94755. /**
  94756. * Are bump textures enabled in the application.
  94757. */
  94758. static BumpTextureEnabled: boolean;
  94759. private static _LightmapTextureEnabled;
  94760. /**
  94761. * Are lightmap textures enabled in the application.
  94762. */
  94763. static LightmapTextureEnabled: boolean;
  94764. private static _RefractionTextureEnabled;
  94765. /**
  94766. * Are refraction textures enabled in the application.
  94767. */
  94768. static RefractionTextureEnabled: boolean;
  94769. private static _ColorGradingTextureEnabled;
  94770. /**
  94771. * Are color grading textures enabled in the application.
  94772. */
  94773. static ColorGradingTextureEnabled: boolean;
  94774. private static _FresnelEnabled;
  94775. /**
  94776. * Are fresnels enabled in the application.
  94777. */
  94778. static FresnelEnabled: boolean;
  94779. private static _ClearCoatTextureEnabled;
  94780. /**
  94781. * Are clear coat textures enabled in the application.
  94782. */
  94783. static ClearCoatTextureEnabled: boolean;
  94784. private static _ClearCoatBumpTextureEnabled;
  94785. /**
  94786. * Are clear coat bump textures enabled in the application.
  94787. */
  94788. static ClearCoatBumpTextureEnabled: boolean;
  94789. private static _ClearCoatTintTextureEnabled;
  94790. /**
  94791. * Are clear coat tint textures enabled in the application.
  94792. */
  94793. static ClearCoatTintTextureEnabled: boolean;
  94794. }
  94795. }
  94796. declare module BABYLON {
  94797. /** @hidden */
  94798. export var defaultFragmentDeclaration: {
  94799. name: string;
  94800. shader: string;
  94801. };
  94802. }
  94803. declare module BABYLON {
  94804. /** @hidden */
  94805. export var defaultUboDeclaration: {
  94806. name: string;
  94807. shader: string;
  94808. };
  94809. }
  94810. declare module BABYLON {
  94811. /** @hidden */
  94812. export var lightFragmentDeclaration: {
  94813. name: string;
  94814. shader: string;
  94815. };
  94816. }
  94817. declare module BABYLON {
  94818. /** @hidden */
  94819. export var lightUboDeclaration: {
  94820. name: string;
  94821. shader: string;
  94822. };
  94823. }
  94824. declare module BABYLON {
  94825. /** @hidden */
  94826. export var lightsFragmentFunctions: {
  94827. name: string;
  94828. shader: string;
  94829. };
  94830. }
  94831. declare module BABYLON {
  94832. /** @hidden */
  94833. export var shadowsFragmentFunctions: {
  94834. name: string;
  94835. shader: string;
  94836. };
  94837. }
  94838. declare module BABYLON {
  94839. /** @hidden */
  94840. export var fresnelFunction: {
  94841. name: string;
  94842. shader: string;
  94843. };
  94844. }
  94845. declare module BABYLON {
  94846. /** @hidden */
  94847. export var reflectionFunction: {
  94848. name: string;
  94849. shader: string;
  94850. };
  94851. }
  94852. declare module BABYLON {
  94853. /** @hidden */
  94854. export var bumpFragmentFunctions: {
  94855. name: string;
  94856. shader: string;
  94857. };
  94858. }
  94859. declare module BABYLON {
  94860. /** @hidden */
  94861. export var logDepthDeclaration: {
  94862. name: string;
  94863. shader: string;
  94864. };
  94865. }
  94866. declare module BABYLON {
  94867. /** @hidden */
  94868. export var bumpFragment: {
  94869. name: string;
  94870. shader: string;
  94871. };
  94872. }
  94873. declare module BABYLON {
  94874. /** @hidden */
  94875. export var depthPrePass: {
  94876. name: string;
  94877. shader: string;
  94878. };
  94879. }
  94880. declare module BABYLON {
  94881. /** @hidden */
  94882. export var lightFragment: {
  94883. name: string;
  94884. shader: string;
  94885. };
  94886. }
  94887. declare module BABYLON {
  94888. /** @hidden */
  94889. export var logDepthFragment: {
  94890. name: string;
  94891. shader: string;
  94892. };
  94893. }
  94894. declare module BABYLON {
  94895. /** @hidden */
  94896. export var defaultPixelShader: {
  94897. name: string;
  94898. shader: string;
  94899. };
  94900. }
  94901. declare module BABYLON {
  94902. /** @hidden */
  94903. export var defaultVertexDeclaration: {
  94904. name: string;
  94905. shader: string;
  94906. };
  94907. }
  94908. declare module BABYLON {
  94909. /** @hidden */
  94910. export var bumpVertexDeclaration: {
  94911. name: string;
  94912. shader: string;
  94913. };
  94914. }
  94915. declare module BABYLON {
  94916. /** @hidden */
  94917. export var bumpVertex: {
  94918. name: string;
  94919. shader: string;
  94920. };
  94921. }
  94922. declare module BABYLON {
  94923. /** @hidden */
  94924. export var fogVertex: {
  94925. name: string;
  94926. shader: string;
  94927. };
  94928. }
  94929. declare module BABYLON {
  94930. /** @hidden */
  94931. export var shadowsVertex: {
  94932. name: string;
  94933. shader: string;
  94934. };
  94935. }
  94936. declare module BABYLON {
  94937. /** @hidden */
  94938. export var pointCloudVertex: {
  94939. name: string;
  94940. shader: string;
  94941. };
  94942. }
  94943. declare module BABYLON {
  94944. /** @hidden */
  94945. export var logDepthVertex: {
  94946. name: string;
  94947. shader: string;
  94948. };
  94949. }
  94950. declare module BABYLON {
  94951. /** @hidden */
  94952. export var defaultVertexShader: {
  94953. name: string;
  94954. shader: string;
  94955. };
  94956. }
  94957. declare module BABYLON {
  94958. /** @hidden */
  94959. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  94960. MAINUV1: boolean;
  94961. MAINUV2: boolean;
  94962. DIFFUSE: boolean;
  94963. DIFFUSEDIRECTUV: number;
  94964. AMBIENT: boolean;
  94965. AMBIENTDIRECTUV: number;
  94966. OPACITY: boolean;
  94967. OPACITYDIRECTUV: number;
  94968. OPACITYRGB: boolean;
  94969. REFLECTION: boolean;
  94970. EMISSIVE: boolean;
  94971. EMISSIVEDIRECTUV: number;
  94972. SPECULAR: boolean;
  94973. SPECULARDIRECTUV: number;
  94974. BUMP: boolean;
  94975. BUMPDIRECTUV: number;
  94976. PARALLAX: boolean;
  94977. PARALLAXOCCLUSION: boolean;
  94978. SPECULAROVERALPHA: boolean;
  94979. CLIPPLANE: boolean;
  94980. CLIPPLANE2: boolean;
  94981. CLIPPLANE3: boolean;
  94982. CLIPPLANE4: boolean;
  94983. ALPHATEST: boolean;
  94984. DEPTHPREPASS: boolean;
  94985. ALPHAFROMDIFFUSE: boolean;
  94986. POINTSIZE: boolean;
  94987. FOG: boolean;
  94988. SPECULARTERM: boolean;
  94989. DIFFUSEFRESNEL: boolean;
  94990. OPACITYFRESNEL: boolean;
  94991. REFLECTIONFRESNEL: boolean;
  94992. REFRACTIONFRESNEL: boolean;
  94993. EMISSIVEFRESNEL: boolean;
  94994. FRESNEL: boolean;
  94995. NORMAL: boolean;
  94996. UV1: boolean;
  94997. UV2: boolean;
  94998. VERTEXCOLOR: boolean;
  94999. VERTEXALPHA: boolean;
  95000. NUM_BONE_INFLUENCERS: number;
  95001. BonesPerMesh: number;
  95002. BONETEXTURE: boolean;
  95003. INSTANCES: boolean;
  95004. GLOSSINESS: boolean;
  95005. ROUGHNESS: boolean;
  95006. EMISSIVEASILLUMINATION: boolean;
  95007. LINKEMISSIVEWITHDIFFUSE: boolean;
  95008. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95009. LIGHTMAP: boolean;
  95010. LIGHTMAPDIRECTUV: number;
  95011. OBJECTSPACE_NORMALMAP: boolean;
  95012. USELIGHTMAPASSHADOWMAP: boolean;
  95013. REFLECTIONMAP_3D: boolean;
  95014. REFLECTIONMAP_SPHERICAL: boolean;
  95015. REFLECTIONMAP_PLANAR: boolean;
  95016. REFLECTIONMAP_CUBIC: boolean;
  95017. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95018. REFLECTIONMAP_PROJECTION: boolean;
  95019. REFLECTIONMAP_SKYBOX: boolean;
  95020. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95021. REFLECTIONMAP_EXPLICIT: boolean;
  95022. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95023. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95024. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95025. INVERTCUBICMAP: boolean;
  95026. LOGARITHMICDEPTH: boolean;
  95027. REFRACTION: boolean;
  95028. REFRACTIONMAP_3D: boolean;
  95029. REFLECTIONOVERALPHA: boolean;
  95030. TWOSIDEDLIGHTING: boolean;
  95031. SHADOWFLOAT: boolean;
  95032. MORPHTARGETS: boolean;
  95033. MORPHTARGETS_NORMAL: boolean;
  95034. MORPHTARGETS_TANGENT: boolean;
  95035. NUM_MORPH_INFLUENCERS: number;
  95036. NONUNIFORMSCALING: boolean;
  95037. PREMULTIPLYALPHA: boolean;
  95038. IMAGEPROCESSING: boolean;
  95039. VIGNETTE: boolean;
  95040. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95041. VIGNETTEBLENDMODEOPAQUE: boolean;
  95042. TONEMAPPING: boolean;
  95043. TONEMAPPING_ACES: boolean;
  95044. CONTRAST: boolean;
  95045. COLORCURVES: boolean;
  95046. COLORGRADING: boolean;
  95047. COLORGRADING3D: boolean;
  95048. SAMPLER3DGREENDEPTH: boolean;
  95049. SAMPLER3DBGRMAP: boolean;
  95050. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95051. /**
  95052. * If the reflection texture on this material is in linear color space
  95053. * @hidden
  95054. */
  95055. IS_REFLECTION_LINEAR: boolean;
  95056. /**
  95057. * If the refraction texture on this material is in linear color space
  95058. * @hidden
  95059. */
  95060. IS_REFRACTION_LINEAR: boolean;
  95061. EXPOSURE: boolean;
  95062. constructor();
  95063. setReflectionMode(modeToEnable: string): void;
  95064. }
  95065. /**
  95066. * This is the default material used in Babylon. It is the best trade off between quality
  95067. * and performances.
  95068. * @see http://doc.babylonjs.com/babylon101/materials
  95069. */
  95070. export class StandardMaterial extends PushMaterial {
  95071. private _diffuseTexture;
  95072. /**
  95073. * The basic texture of the material as viewed under a light.
  95074. */
  95075. diffuseTexture: Nullable<BaseTexture>;
  95076. private _ambientTexture;
  95077. /**
  95078. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95079. */
  95080. ambientTexture: Nullable<BaseTexture>;
  95081. private _opacityTexture;
  95082. /**
  95083. * Define the transparency of the material from a texture.
  95084. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95085. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95086. */
  95087. opacityTexture: Nullable<BaseTexture>;
  95088. private _reflectionTexture;
  95089. /**
  95090. * Define the texture used to display the reflection.
  95091. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95092. */
  95093. reflectionTexture: Nullable<BaseTexture>;
  95094. private _emissiveTexture;
  95095. /**
  95096. * Define texture of the material as if self lit.
  95097. * This will be mixed in the final result even in the absence of light.
  95098. */
  95099. emissiveTexture: Nullable<BaseTexture>;
  95100. private _specularTexture;
  95101. /**
  95102. * Define how the color and intensity of the highlight given by the light in the material.
  95103. */
  95104. specularTexture: Nullable<BaseTexture>;
  95105. private _bumpTexture;
  95106. /**
  95107. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95108. * 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.
  95109. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95110. */
  95111. bumpTexture: Nullable<BaseTexture>;
  95112. private _lightmapTexture;
  95113. /**
  95114. * Complex lighting can be computationally expensive to compute at runtime.
  95115. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95116. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95117. */
  95118. lightmapTexture: Nullable<BaseTexture>;
  95119. private _refractionTexture;
  95120. /**
  95121. * Define the texture used to display the refraction.
  95122. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95123. */
  95124. refractionTexture: Nullable<BaseTexture>;
  95125. /**
  95126. * The color of the material lit by the environmental background lighting.
  95127. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95128. */
  95129. ambientColor: Color3;
  95130. /**
  95131. * The basic color of the material as viewed under a light.
  95132. */
  95133. diffuseColor: Color3;
  95134. /**
  95135. * Define how the color and intensity of the highlight given by the light in the material.
  95136. */
  95137. specularColor: Color3;
  95138. /**
  95139. * Define the color of the material as if self lit.
  95140. * This will be mixed in the final result even in the absence of light.
  95141. */
  95142. emissiveColor: Color3;
  95143. /**
  95144. * Defines how sharp are the highlights in the material.
  95145. * The bigger the value the sharper giving a more glossy feeling to the result.
  95146. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95147. */
  95148. specularPower: number;
  95149. private _useAlphaFromDiffuseTexture;
  95150. /**
  95151. * Does the transparency come from the diffuse texture alpha channel.
  95152. */
  95153. useAlphaFromDiffuseTexture: boolean;
  95154. private _useEmissiveAsIllumination;
  95155. /**
  95156. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95157. */
  95158. useEmissiveAsIllumination: boolean;
  95159. private _linkEmissiveWithDiffuse;
  95160. /**
  95161. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95162. * the emissive level when the final color is close to one.
  95163. */
  95164. linkEmissiveWithDiffuse: boolean;
  95165. private _useSpecularOverAlpha;
  95166. /**
  95167. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95168. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95169. */
  95170. useSpecularOverAlpha: boolean;
  95171. private _useReflectionOverAlpha;
  95172. /**
  95173. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95174. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95175. */
  95176. useReflectionOverAlpha: boolean;
  95177. private _disableLighting;
  95178. /**
  95179. * Does lights from the scene impacts this material.
  95180. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95181. */
  95182. disableLighting: boolean;
  95183. private _useObjectSpaceNormalMap;
  95184. /**
  95185. * Allows using an object space normal map (instead of tangent space).
  95186. */
  95187. useObjectSpaceNormalMap: boolean;
  95188. private _useParallax;
  95189. /**
  95190. * Is parallax enabled or not.
  95191. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95192. */
  95193. useParallax: boolean;
  95194. private _useParallaxOcclusion;
  95195. /**
  95196. * Is parallax occlusion enabled or not.
  95197. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95198. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95199. */
  95200. useParallaxOcclusion: boolean;
  95201. /**
  95202. * 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.
  95203. */
  95204. parallaxScaleBias: number;
  95205. private _roughness;
  95206. /**
  95207. * Helps to define how blurry the reflections should appears in the material.
  95208. */
  95209. roughness: number;
  95210. /**
  95211. * In case of refraction, define the value of the indice of refraction.
  95212. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95213. */
  95214. indexOfRefraction: number;
  95215. /**
  95216. * Invert the refraction texture alongside the y axis.
  95217. * It can be useful with procedural textures or probe for instance.
  95218. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95219. */
  95220. invertRefractionY: boolean;
  95221. /**
  95222. * Defines the alpha limits in alpha test mode.
  95223. */
  95224. alphaCutOff: number;
  95225. private _useLightmapAsShadowmap;
  95226. /**
  95227. * In case of light mapping, define whether the map contains light or shadow informations.
  95228. */
  95229. useLightmapAsShadowmap: boolean;
  95230. private _diffuseFresnelParameters;
  95231. /**
  95232. * Define the diffuse fresnel parameters of the material.
  95233. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95234. */
  95235. diffuseFresnelParameters: FresnelParameters;
  95236. private _opacityFresnelParameters;
  95237. /**
  95238. * Define the opacity fresnel parameters of the material.
  95239. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95240. */
  95241. opacityFresnelParameters: FresnelParameters;
  95242. private _reflectionFresnelParameters;
  95243. /**
  95244. * Define the reflection fresnel parameters of the material.
  95245. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95246. */
  95247. reflectionFresnelParameters: FresnelParameters;
  95248. private _refractionFresnelParameters;
  95249. /**
  95250. * Define the refraction fresnel parameters of the material.
  95251. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95252. */
  95253. refractionFresnelParameters: FresnelParameters;
  95254. private _emissiveFresnelParameters;
  95255. /**
  95256. * Define the emissive fresnel parameters of the material.
  95257. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95258. */
  95259. emissiveFresnelParameters: FresnelParameters;
  95260. private _useReflectionFresnelFromSpecular;
  95261. /**
  95262. * If true automatically deducts the fresnels values from the material specularity.
  95263. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95264. */
  95265. useReflectionFresnelFromSpecular: boolean;
  95266. private _useGlossinessFromSpecularMapAlpha;
  95267. /**
  95268. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95269. */
  95270. useGlossinessFromSpecularMapAlpha: boolean;
  95271. private _maxSimultaneousLights;
  95272. /**
  95273. * Defines the maximum number of lights that can be used in the material
  95274. */
  95275. maxSimultaneousLights: number;
  95276. private _invertNormalMapX;
  95277. /**
  95278. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95279. */
  95280. invertNormalMapX: boolean;
  95281. private _invertNormalMapY;
  95282. /**
  95283. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95284. */
  95285. invertNormalMapY: boolean;
  95286. private _twoSidedLighting;
  95287. /**
  95288. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95289. */
  95290. twoSidedLighting: boolean;
  95291. /**
  95292. * Default configuration related to image processing available in the standard Material.
  95293. */
  95294. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95295. /**
  95296. * Gets the image processing configuration used either in this material.
  95297. */
  95298. /**
  95299. * Sets the Default image processing configuration used either in the this material.
  95300. *
  95301. * If sets to null, the scene one is in use.
  95302. */
  95303. imageProcessingConfiguration: ImageProcessingConfiguration;
  95304. /**
  95305. * Keep track of the image processing observer to allow dispose and replace.
  95306. */
  95307. private _imageProcessingObserver;
  95308. /**
  95309. * Attaches a new image processing configuration to the Standard Material.
  95310. * @param configuration
  95311. */
  95312. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95313. /**
  95314. * Gets wether the color curves effect is enabled.
  95315. */
  95316. /**
  95317. * Sets wether the color curves effect is enabled.
  95318. */
  95319. cameraColorCurvesEnabled: boolean;
  95320. /**
  95321. * Gets wether the color grading effect is enabled.
  95322. */
  95323. /**
  95324. * Gets wether the color grading effect is enabled.
  95325. */
  95326. cameraColorGradingEnabled: boolean;
  95327. /**
  95328. * Gets wether tonemapping is enabled or not.
  95329. */
  95330. /**
  95331. * Sets wether tonemapping is enabled or not
  95332. */
  95333. cameraToneMappingEnabled: boolean;
  95334. /**
  95335. * The camera exposure used on this material.
  95336. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95337. * This corresponds to a photographic exposure.
  95338. */
  95339. /**
  95340. * The camera exposure used on this material.
  95341. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95342. * This corresponds to a photographic exposure.
  95343. */
  95344. cameraExposure: number;
  95345. /**
  95346. * Gets The camera contrast used on this material.
  95347. */
  95348. /**
  95349. * Sets The camera contrast used on this material.
  95350. */
  95351. cameraContrast: number;
  95352. /**
  95353. * Gets the Color Grading 2D Lookup Texture.
  95354. */
  95355. /**
  95356. * Sets the Color Grading 2D Lookup Texture.
  95357. */
  95358. cameraColorGradingTexture: Nullable<BaseTexture>;
  95359. /**
  95360. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95361. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95362. * 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;
  95363. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95364. */
  95365. /**
  95366. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95367. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95368. * 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;
  95369. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95370. */
  95371. cameraColorCurves: Nullable<ColorCurves>;
  95372. /**
  95373. * Custom callback helping to override the default shader used in the material.
  95374. */
  95375. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95376. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95377. protected _worldViewProjectionMatrix: Matrix;
  95378. protected _globalAmbientColor: Color3;
  95379. protected _useLogarithmicDepth: boolean;
  95380. /**
  95381. * Instantiates a new standard material.
  95382. * This is the default material used in Babylon. It is the best trade off between quality
  95383. * and performances.
  95384. * @see http://doc.babylonjs.com/babylon101/materials
  95385. * @param name Define the name of the material in the scene
  95386. * @param scene Define the scene the material belong to
  95387. */
  95388. constructor(name: string, scene: Scene);
  95389. /**
  95390. * Gets a boolean indicating that current material needs to register RTT
  95391. */
  95392. readonly hasRenderTargetTextures: boolean;
  95393. /**
  95394. * Gets the current class name of the material e.g. "StandardMaterial"
  95395. * Mainly use in serialization.
  95396. * @returns the class name
  95397. */
  95398. getClassName(): string;
  95399. /**
  95400. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95401. * You can try switching to logarithmic depth.
  95402. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95403. */
  95404. useLogarithmicDepth: boolean;
  95405. /**
  95406. * Specifies if the material will require alpha blending
  95407. * @returns a boolean specifying if alpha blending is needed
  95408. */
  95409. needAlphaBlending(): boolean;
  95410. /**
  95411. * Specifies if this material should be rendered in alpha test mode
  95412. * @returns a boolean specifying if an alpha test is needed.
  95413. */
  95414. needAlphaTesting(): boolean;
  95415. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95416. /**
  95417. * Get the texture used for alpha test purpose.
  95418. * @returns the diffuse texture in case of the standard material.
  95419. */
  95420. getAlphaTestTexture(): Nullable<BaseTexture>;
  95421. /**
  95422. * Get if the submesh is ready to be used and all its information available.
  95423. * Child classes can use it to update shaders
  95424. * @param mesh defines the mesh to check
  95425. * @param subMesh defines which submesh to check
  95426. * @param useInstances specifies that instances should be used
  95427. * @returns a boolean indicating that the submesh is ready or not
  95428. */
  95429. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95430. /**
  95431. * Builds the material UBO layouts.
  95432. * Used internally during the effect preparation.
  95433. */
  95434. buildUniformLayout(): void;
  95435. /**
  95436. * Unbinds the material from the mesh
  95437. */
  95438. unbind(): void;
  95439. /**
  95440. * Binds the submesh to this material by preparing the effect and shader to draw
  95441. * @param world defines the world transformation matrix
  95442. * @param mesh defines the mesh containing the submesh
  95443. * @param subMesh defines the submesh to bind the material to
  95444. */
  95445. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95446. /**
  95447. * Get the list of animatables in the material.
  95448. * @returns the list of animatables object used in the material
  95449. */
  95450. getAnimatables(): IAnimatable[];
  95451. /**
  95452. * Gets the active textures from the material
  95453. * @returns an array of textures
  95454. */
  95455. getActiveTextures(): BaseTexture[];
  95456. /**
  95457. * Specifies if the material uses a texture
  95458. * @param texture defines the texture to check against the material
  95459. * @returns a boolean specifying if the material uses the texture
  95460. */
  95461. hasTexture(texture: BaseTexture): boolean;
  95462. /**
  95463. * Disposes the material
  95464. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95465. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95466. */
  95467. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95468. /**
  95469. * Makes a duplicate of the material, and gives it a new name
  95470. * @param name defines the new name for the duplicated material
  95471. * @returns the cloned material
  95472. */
  95473. clone(name: string): StandardMaterial;
  95474. /**
  95475. * Serializes this material in a JSON representation
  95476. * @returns the serialized material object
  95477. */
  95478. serialize(): any;
  95479. /**
  95480. * Creates a standard material from parsed material data
  95481. * @param source defines the JSON representation of the material
  95482. * @param scene defines the hosting scene
  95483. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95484. * @returns a new standard material
  95485. */
  95486. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95487. /**
  95488. * Are diffuse textures enabled in the application.
  95489. */
  95490. static DiffuseTextureEnabled: boolean;
  95491. /**
  95492. * Are ambient textures enabled in the application.
  95493. */
  95494. static AmbientTextureEnabled: boolean;
  95495. /**
  95496. * Are opacity textures enabled in the application.
  95497. */
  95498. static OpacityTextureEnabled: boolean;
  95499. /**
  95500. * Are reflection textures enabled in the application.
  95501. */
  95502. static ReflectionTextureEnabled: boolean;
  95503. /**
  95504. * Are emissive textures enabled in the application.
  95505. */
  95506. static EmissiveTextureEnabled: boolean;
  95507. /**
  95508. * Are specular textures enabled in the application.
  95509. */
  95510. static SpecularTextureEnabled: boolean;
  95511. /**
  95512. * Are bump textures enabled in the application.
  95513. */
  95514. static BumpTextureEnabled: boolean;
  95515. /**
  95516. * Are lightmap textures enabled in the application.
  95517. */
  95518. static LightmapTextureEnabled: boolean;
  95519. /**
  95520. * Are refraction textures enabled in the application.
  95521. */
  95522. static RefractionTextureEnabled: boolean;
  95523. /**
  95524. * Are color grading textures enabled in the application.
  95525. */
  95526. static ColorGradingTextureEnabled: boolean;
  95527. /**
  95528. * Are fresnels enabled in the application.
  95529. */
  95530. static FresnelEnabled: boolean;
  95531. }
  95532. }
  95533. declare module BABYLON {
  95534. /**
  95535. * A class extending Texture allowing drawing on a texture
  95536. * @see http://doc.babylonjs.com/how_to/dynamictexture
  95537. */
  95538. export class DynamicTexture extends Texture {
  95539. private _generateMipMaps;
  95540. private _canvas;
  95541. private _context;
  95542. private _engine;
  95543. /**
  95544. * Creates a DynamicTexture
  95545. * @param name defines the name of the texture
  95546. * @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
  95547. * @param scene defines the scene where you want the texture
  95548. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  95549. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95550. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  95551. */
  95552. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  95553. /**
  95554. * Get the current class name of the texture useful for serialization or dynamic coding.
  95555. * @returns "DynamicTexture"
  95556. */
  95557. getClassName(): string;
  95558. /**
  95559. * Gets the current state of canRescale
  95560. */
  95561. readonly canRescale: boolean;
  95562. private _recreate;
  95563. /**
  95564. * Scales the texture
  95565. * @param ratio the scale factor to apply to both width and height
  95566. */
  95567. scale(ratio: number): void;
  95568. /**
  95569. * Resizes the texture
  95570. * @param width the new width
  95571. * @param height the new height
  95572. */
  95573. scaleTo(width: number, height: number): void;
  95574. /**
  95575. * Gets the context of the canvas used by the texture
  95576. * @returns the canvas context of the dynamic texture
  95577. */
  95578. getContext(): CanvasRenderingContext2D;
  95579. /**
  95580. * Clears the texture
  95581. */
  95582. clear(): void;
  95583. /**
  95584. * Updates the texture
  95585. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95586. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  95587. */
  95588. update(invertY?: boolean, premulAlpha?: boolean): void;
  95589. /**
  95590. * Draws text onto the texture
  95591. * @param text defines the text to be drawn
  95592. * @param x defines the placement of the text from the left
  95593. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  95594. * @param font defines the font to be used with font-style, font-size, font-name
  95595. * @param color defines the color used for the text
  95596. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  95597. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95598. * @param update defines whether texture is immediately update (default is true)
  95599. */
  95600. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  95601. /**
  95602. * Clones the texture
  95603. * @returns the clone of the texture.
  95604. */
  95605. clone(): DynamicTexture;
  95606. /**
  95607. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  95608. * @returns a serialized dynamic texture object
  95609. */
  95610. serialize(): any;
  95611. /** @hidden */
  95612. _rebuild(): void;
  95613. }
  95614. }
  95615. declare module BABYLON {
  95616. /** @hidden */
  95617. export var imageProcessingPixelShader: {
  95618. name: string;
  95619. shader: string;
  95620. };
  95621. }
  95622. declare module BABYLON {
  95623. /**
  95624. * ImageProcessingPostProcess
  95625. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  95626. */
  95627. export class ImageProcessingPostProcess extends PostProcess {
  95628. /**
  95629. * Default configuration related to image processing available in the PBR Material.
  95630. */
  95631. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95632. /**
  95633. * Gets the image processing configuration used either in this material.
  95634. */
  95635. /**
  95636. * Sets the Default image processing configuration used either in the this material.
  95637. *
  95638. * If sets to null, the scene one is in use.
  95639. */
  95640. imageProcessingConfiguration: ImageProcessingConfiguration;
  95641. /**
  95642. * Keep track of the image processing observer to allow dispose and replace.
  95643. */
  95644. private _imageProcessingObserver;
  95645. /**
  95646. * Attaches a new image processing configuration to the PBR Material.
  95647. * @param configuration
  95648. */
  95649. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  95650. /**
  95651. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95652. */
  95653. /**
  95654. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95655. */
  95656. colorCurves: Nullable<ColorCurves>;
  95657. /**
  95658. * Gets wether the color curves effect is enabled.
  95659. */
  95660. /**
  95661. * Sets wether the color curves effect is enabled.
  95662. */
  95663. colorCurvesEnabled: boolean;
  95664. /**
  95665. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95666. */
  95667. /**
  95668. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95669. */
  95670. colorGradingTexture: Nullable<BaseTexture>;
  95671. /**
  95672. * Gets wether the color grading effect is enabled.
  95673. */
  95674. /**
  95675. * Gets wether the color grading effect is enabled.
  95676. */
  95677. colorGradingEnabled: boolean;
  95678. /**
  95679. * Gets exposure used in the effect.
  95680. */
  95681. /**
  95682. * Sets exposure used in the effect.
  95683. */
  95684. exposure: number;
  95685. /**
  95686. * Gets wether tonemapping is enabled or not.
  95687. */
  95688. /**
  95689. * Sets wether tonemapping is enabled or not
  95690. */
  95691. toneMappingEnabled: boolean;
  95692. /**
  95693. * Gets the type of tone mapping effect.
  95694. */
  95695. /**
  95696. * Sets the type of tone mapping effect.
  95697. */
  95698. toneMappingType: number;
  95699. /**
  95700. * Gets contrast used in the effect.
  95701. */
  95702. /**
  95703. * Sets contrast used in the effect.
  95704. */
  95705. contrast: number;
  95706. /**
  95707. * Gets Vignette stretch size.
  95708. */
  95709. /**
  95710. * Sets Vignette stretch size.
  95711. */
  95712. vignetteStretch: number;
  95713. /**
  95714. * Gets Vignette centre X Offset.
  95715. */
  95716. /**
  95717. * Sets Vignette centre X Offset.
  95718. */
  95719. vignetteCentreX: number;
  95720. /**
  95721. * Gets Vignette centre Y Offset.
  95722. */
  95723. /**
  95724. * Sets Vignette centre Y Offset.
  95725. */
  95726. vignetteCentreY: number;
  95727. /**
  95728. * Gets Vignette weight or intensity of the vignette effect.
  95729. */
  95730. /**
  95731. * Sets Vignette weight or intensity of the vignette effect.
  95732. */
  95733. vignetteWeight: number;
  95734. /**
  95735. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95736. * if vignetteEnabled is set to true.
  95737. */
  95738. /**
  95739. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95740. * if vignetteEnabled is set to true.
  95741. */
  95742. vignetteColor: Color4;
  95743. /**
  95744. * Gets Camera field of view used by the Vignette effect.
  95745. */
  95746. /**
  95747. * Sets Camera field of view used by the Vignette effect.
  95748. */
  95749. vignetteCameraFov: number;
  95750. /**
  95751. * Gets the vignette blend mode allowing different kind of effect.
  95752. */
  95753. /**
  95754. * Sets the vignette blend mode allowing different kind of effect.
  95755. */
  95756. vignetteBlendMode: number;
  95757. /**
  95758. * Gets wether the vignette effect is enabled.
  95759. */
  95760. /**
  95761. * Sets wether the vignette effect is enabled.
  95762. */
  95763. vignetteEnabled: boolean;
  95764. private _fromLinearSpace;
  95765. /**
  95766. * Gets wether the input of the processing is in Gamma or Linear Space.
  95767. */
  95768. /**
  95769. * Sets wether the input of the processing is in Gamma or Linear Space.
  95770. */
  95771. fromLinearSpace: boolean;
  95772. /**
  95773. * Defines cache preventing GC.
  95774. */
  95775. private _defines;
  95776. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  95777. /**
  95778. * "ImageProcessingPostProcess"
  95779. * @returns "ImageProcessingPostProcess"
  95780. */
  95781. getClassName(): string;
  95782. protected _updateParameters(): void;
  95783. dispose(camera?: Camera): void;
  95784. }
  95785. }
  95786. declare module BABYLON {
  95787. /**
  95788. * Class containing static functions to help procedurally build meshes
  95789. */
  95790. export class GroundBuilder {
  95791. /**
  95792. * Creates a ground mesh
  95793. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  95794. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  95795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95796. * @param name defines the name of the mesh
  95797. * @param options defines the options used to create the mesh
  95798. * @param scene defines the hosting scene
  95799. * @returns the ground mesh
  95800. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  95801. */
  95802. static CreateGround(name: string, options: {
  95803. width?: number;
  95804. height?: number;
  95805. subdivisions?: number;
  95806. subdivisionsX?: number;
  95807. subdivisionsY?: number;
  95808. updatable?: boolean;
  95809. }, scene: any): Mesh;
  95810. /**
  95811. * Creates a tiled ground mesh
  95812. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  95813. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  95814. * * 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
  95815. * * 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
  95816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95817. * @param name defines the name of the mesh
  95818. * @param options defines the options used to create the mesh
  95819. * @param scene defines the hosting scene
  95820. * @returns the tiled ground mesh
  95821. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  95822. */
  95823. static CreateTiledGround(name: string, options: {
  95824. xmin: number;
  95825. zmin: number;
  95826. xmax: number;
  95827. zmax: number;
  95828. subdivisions?: {
  95829. w: number;
  95830. h: number;
  95831. };
  95832. precision?: {
  95833. w: number;
  95834. h: number;
  95835. };
  95836. updatable?: boolean;
  95837. }, scene: Scene): Mesh;
  95838. /**
  95839. * Creates a ground mesh from a height map
  95840. * * The parameter `url` sets the URL of the height map image resource.
  95841. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  95842. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  95843. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  95844. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  95845. * * 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.
  95846. * * 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).
  95847. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95849. * @param name defines the name of the mesh
  95850. * @param url defines the url to the height map
  95851. * @param options defines the options used to create the mesh
  95852. * @param scene defines the hosting scene
  95853. * @returns the ground mesh
  95854. * @see https://doc.babylonjs.com/babylon101/height_map
  95855. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  95856. */
  95857. static CreateGroundFromHeightMap(name: string, url: string, options: {
  95858. width?: number;
  95859. height?: number;
  95860. subdivisions?: number;
  95861. minHeight?: number;
  95862. maxHeight?: number;
  95863. colorFilter?: Color3;
  95864. alphaFilter?: number;
  95865. updatable?: boolean;
  95866. onReady?: (mesh: GroundMesh) => void;
  95867. }, scene: Scene): GroundMesh;
  95868. }
  95869. }
  95870. declare module BABYLON {
  95871. /**
  95872. * Class containing static functions to help procedurally build meshes
  95873. */
  95874. export class TorusBuilder {
  95875. /**
  95876. * Creates a torus mesh
  95877. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  95878. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  95879. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  95880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95881. * * If you create a double-sided mesh, you can choose what parts of 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
  95882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95883. * @param name defines the name of the mesh
  95884. * @param options defines the options used to create the mesh
  95885. * @param scene defines the hosting scene
  95886. * @returns the torus mesh
  95887. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  95888. */
  95889. static CreateTorus(name: string, options: {
  95890. diameter?: number;
  95891. thickness?: number;
  95892. tessellation?: number;
  95893. updatable?: boolean;
  95894. sideOrientation?: number;
  95895. frontUVs?: Vector4;
  95896. backUVs?: Vector4;
  95897. }, scene: any): Mesh;
  95898. }
  95899. }
  95900. declare module BABYLON {
  95901. /**
  95902. * Class containing static functions to help procedurally build meshes
  95903. */
  95904. export class CylinderBuilder {
  95905. /**
  95906. * Creates a cylinder or a cone mesh
  95907. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  95908. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  95909. * * 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.
  95910. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  95911. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  95912. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  95913. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  95914. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  95915. * * 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).
  95916. * * 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
  95917. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  95918. * * 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
  95919. * * 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.
  95920. * * If `enclose` is false, a ring surface is one element.
  95921. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  95922. * * 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
  95923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95924. * * If you create a double-sided mesh, you can choose what parts of 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
  95925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95926. * @param name defines the name of the mesh
  95927. * @param options defines the options used to create the mesh
  95928. * @param scene defines the hosting scene
  95929. * @returns the cylinder mesh
  95930. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  95931. */
  95932. static CreateCylinder(name: string, options: {
  95933. height?: number;
  95934. diameterTop?: number;
  95935. diameterBottom?: number;
  95936. diameter?: number;
  95937. tessellation?: number;
  95938. subdivisions?: number;
  95939. arc?: number;
  95940. faceColors?: Color4[];
  95941. faceUV?: Vector4[];
  95942. updatable?: boolean;
  95943. hasRings?: boolean;
  95944. enclose?: boolean;
  95945. sideOrientation?: number;
  95946. frontUVs?: Vector4;
  95947. backUVs?: Vector4;
  95948. }, scene: any): Mesh;
  95949. }
  95950. }
  95951. declare module BABYLON {
  95952. /**
  95953. * Manager for handling gamepads
  95954. */
  95955. export class GamepadManager {
  95956. private _scene?;
  95957. private _babylonGamepads;
  95958. private _oneGamepadConnected;
  95959. /** @hidden */
  95960. _isMonitoring: boolean;
  95961. private _gamepadEventSupported;
  95962. private _gamepadSupport;
  95963. /**
  95964. * observable to be triggered when the gamepad controller has been connected
  95965. */
  95966. onGamepadConnectedObservable: Observable<Gamepad>;
  95967. /**
  95968. * observable to be triggered when the gamepad controller has been disconnected
  95969. */
  95970. onGamepadDisconnectedObservable: Observable<Gamepad>;
  95971. private _onGamepadConnectedEvent;
  95972. private _onGamepadDisconnectedEvent;
  95973. /**
  95974. * Initializes the gamepad manager
  95975. * @param _scene BabylonJS scene
  95976. */
  95977. constructor(_scene?: Scene | undefined);
  95978. /**
  95979. * The gamepads in the game pad manager
  95980. */
  95981. readonly gamepads: Gamepad[];
  95982. /**
  95983. * Get the gamepad controllers based on type
  95984. * @param type The type of gamepad controller
  95985. * @returns Nullable gamepad
  95986. */
  95987. getGamepadByType(type?: number): Nullable<Gamepad>;
  95988. /**
  95989. * Disposes the gamepad manager
  95990. */
  95991. dispose(): void;
  95992. private _addNewGamepad;
  95993. private _startMonitoringGamepads;
  95994. private _stopMonitoringGamepads;
  95995. /** @hidden */
  95996. _checkGamepadsStatus(): void;
  95997. private _updateGamepadObjects;
  95998. }
  95999. }
  96000. declare module BABYLON {
  96001. interface Scene {
  96002. /** @hidden */
  96003. _gamepadManager: Nullable<GamepadManager>;
  96004. /**
  96005. * Gets the gamepad manager associated with the scene
  96006. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96007. */
  96008. gamepadManager: GamepadManager;
  96009. }
  96010. /**
  96011. * Interface representing a free camera inputs manager
  96012. */
  96013. interface FreeCameraInputsManager {
  96014. /**
  96015. * Adds gamepad input support to the FreeCameraInputsManager.
  96016. * @returns the FreeCameraInputsManager
  96017. */
  96018. addGamepad(): FreeCameraInputsManager;
  96019. }
  96020. /**
  96021. * Interface representing an arc rotate camera inputs manager
  96022. */
  96023. interface ArcRotateCameraInputsManager {
  96024. /**
  96025. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96026. * @returns the camera inputs manager
  96027. */
  96028. addGamepad(): ArcRotateCameraInputsManager;
  96029. }
  96030. /**
  96031. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96032. */
  96033. export class GamepadSystemSceneComponent implements ISceneComponent {
  96034. /**
  96035. * The component name helpfull to identify the component in the list of scene components.
  96036. */
  96037. readonly name: string;
  96038. /**
  96039. * The scene the component belongs to.
  96040. */
  96041. scene: Scene;
  96042. /**
  96043. * Creates a new instance of the component for the given scene
  96044. * @param scene Defines the scene to register the component in
  96045. */
  96046. constructor(scene: Scene);
  96047. /**
  96048. * Registers the component in a given scene
  96049. */
  96050. register(): void;
  96051. /**
  96052. * Rebuilds the elements related to this component in case of
  96053. * context lost for instance.
  96054. */
  96055. rebuild(): void;
  96056. /**
  96057. * Disposes the component and the associated ressources
  96058. */
  96059. dispose(): void;
  96060. private _beforeCameraUpdate;
  96061. }
  96062. }
  96063. declare module BABYLON {
  96064. /**
  96065. * Options to modify the vr teleportation behavior.
  96066. */
  96067. export interface VRTeleportationOptions {
  96068. /**
  96069. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96070. */
  96071. floorMeshName?: string;
  96072. /**
  96073. * A list of meshes to be used as the teleportation floor. (default: empty)
  96074. */
  96075. floorMeshes?: Mesh[];
  96076. }
  96077. /**
  96078. * Options to modify the vr experience helper's behavior.
  96079. */
  96080. export interface VRExperienceHelperOptions extends WebVROptions {
  96081. /**
  96082. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96083. */
  96084. createDeviceOrientationCamera?: boolean;
  96085. /**
  96086. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96087. */
  96088. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96089. /**
  96090. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96091. */
  96092. laserToggle?: boolean;
  96093. /**
  96094. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96095. */
  96096. floorMeshes?: Mesh[];
  96097. /**
  96098. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96099. */
  96100. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96101. }
  96102. /**
  96103. * Event containing information after VR has been entered
  96104. */
  96105. export class OnAfterEnteringVRObservableEvent {
  96106. /**
  96107. * If entering vr was successful
  96108. */
  96109. success: boolean;
  96110. }
  96111. /**
  96112. * Helps to quickly add VR support to an existing scene.
  96113. * See http://doc.babylonjs.com/how_to/webvr_helper
  96114. */
  96115. export class VRExperienceHelper {
  96116. /** Options to modify the vr experience helper's behavior. */
  96117. webVROptions: VRExperienceHelperOptions;
  96118. private _scene;
  96119. private _position;
  96120. private _btnVR;
  96121. private _btnVRDisplayed;
  96122. private _webVRsupported;
  96123. private _webVRready;
  96124. private _webVRrequesting;
  96125. private _webVRpresenting;
  96126. private _hasEnteredVR;
  96127. private _fullscreenVRpresenting;
  96128. private _canvas;
  96129. private _webVRCamera;
  96130. private _vrDeviceOrientationCamera;
  96131. private _deviceOrientationCamera;
  96132. private _existingCamera;
  96133. private _onKeyDown;
  96134. private _onVrDisplayPresentChange;
  96135. private _onVRDisplayChanged;
  96136. private _onVRRequestPresentStart;
  96137. private _onVRRequestPresentComplete;
  96138. /**
  96139. * Observable raised right before entering VR.
  96140. */
  96141. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96142. /**
  96143. * Observable raised when entering VR has completed.
  96144. */
  96145. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96146. /**
  96147. * Observable raised when exiting VR.
  96148. */
  96149. onExitingVRObservable: Observable<VRExperienceHelper>;
  96150. /**
  96151. * Observable raised when controller mesh is loaded.
  96152. */
  96153. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96154. /** Return this.onEnteringVRObservable
  96155. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96156. */
  96157. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96158. /** Return this.onExitingVRObservable
  96159. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96160. */
  96161. readonly onExitingVR: Observable<VRExperienceHelper>;
  96162. /** Return this.onControllerMeshLoadedObservable
  96163. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96164. */
  96165. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96166. private _rayLength;
  96167. private _useCustomVRButton;
  96168. private _teleportationRequested;
  96169. private _teleportActive;
  96170. private _floorMeshName;
  96171. private _floorMeshesCollection;
  96172. private _rotationAllowed;
  96173. private _teleportBackwardsVector;
  96174. private _teleportationTarget;
  96175. private _isDefaultTeleportationTarget;
  96176. private _postProcessMove;
  96177. private _teleportationFillColor;
  96178. private _teleportationBorderColor;
  96179. private _rotationAngle;
  96180. private _haloCenter;
  96181. private _cameraGazer;
  96182. private _padSensibilityUp;
  96183. private _padSensibilityDown;
  96184. private _leftController;
  96185. private _rightController;
  96186. /**
  96187. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96188. */
  96189. onNewMeshSelected: Observable<AbstractMesh>;
  96190. /**
  96191. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96192. */
  96193. onNewMeshPicked: Observable<PickingInfo>;
  96194. private _circleEase;
  96195. /**
  96196. * Observable raised before camera teleportation
  96197. */
  96198. onBeforeCameraTeleport: Observable<Vector3>;
  96199. /**
  96200. * Observable raised after camera teleportation
  96201. */
  96202. onAfterCameraTeleport: Observable<Vector3>;
  96203. /**
  96204. * Observable raised when current selected mesh gets unselected
  96205. */
  96206. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96207. private _raySelectionPredicate;
  96208. /**
  96209. * To be optionaly changed by user to define custom ray selection
  96210. */
  96211. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96212. /**
  96213. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96214. */
  96215. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96216. /**
  96217. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96218. */
  96219. teleportationEnabled: boolean;
  96220. private _defaultHeight;
  96221. private _teleportationInitialized;
  96222. private _interactionsEnabled;
  96223. private _interactionsRequested;
  96224. private _displayGaze;
  96225. private _displayLaserPointer;
  96226. /**
  96227. * The mesh used to display where the user is going to teleport.
  96228. */
  96229. /**
  96230. * Sets the mesh to be used to display where the user is going to teleport.
  96231. */
  96232. teleportationTarget: Mesh;
  96233. /**
  96234. * 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
  96235. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96236. * See http://doc.babylonjs.com/resources/baking_transformations
  96237. */
  96238. gazeTrackerMesh: Mesh;
  96239. /**
  96240. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96241. */
  96242. updateGazeTrackerScale: boolean;
  96243. /**
  96244. * If the gaze trackers color should be updated when selecting meshes
  96245. */
  96246. updateGazeTrackerColor: boolean;
  96247. /**
  96248. * The gaze tracking mesh corresponding to the left controller
  96249. */
  96250. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96251. /**
  96252. * The gaze tracking mesh corresponding to the right controller
  96253. */
  96254. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96255. /**
  96256. * If the ray of the gaze should be displayed.
  96257. */
  96258. /**
  96259. * Sets if the ray of the gaze should be displayed.
  96260. */
  96261. displayGaze: boolean;
  96262. /**
  96263. * If the ray of the LaserPointer should be displayed.
  96264. */
  96265. /**
  96266. * Sets if the ray of the LaserPointer should be displayed.
  96267. */
  96268. displayLaserPointer: boolean;
  96269. /**
  96270. * The deviceOrientationCamera used as the camera when not in VR.
  96271. */
  96272. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96273. /**
  96274. * Based on the current WebVR support, returns the current VR camera used.
  96275. */
  96276. readonly currentVRCamera: Nullable<Camera>;
  96277. /**
  96278. * The webVRCamera which is used when in VR.
  96279. */
  96280. readonly webVRCamera: WebVRFreeCamera;
  96281. /**
  96282. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96283. */
  96284. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96285. private readonly _teleportationRequestInitiated;
  96286. /**
  96287. * Defines wether or not Pointer lock should be requested when switching to
  96288. * full screen.
  96289. */
  96290. requestPointerLockOnFullScreen: boolean;
  96291. /**
  96292. * Instantiates a VRExperienceHelper.
  96293. * Helps to quickly add VR support to an existing scene.
  96294. * @param scene The scene the VRExperienceHelper belongs to.
  96295. * @param webVROptions Options to modify the vr experience helper's behavior.
  96296. */
  96297. constructor(scene: Scene,
  96298. /** Options to modify the vr experience helper's behavior. */
  96299. webVROptions?: VRExperienceHelperOptions);
  96300. private _onDefaultMeshLoaded;
  96301. private _onResize;
  96302. private _onFullscreenChange;
  96303. /**
  96304. * Gets a value indicating if we are currently in VR mode.
  96305. */
  96306. readonly isInVRMode: boolean;
  96307. private onVrDisplayPresentChange;
  96308. private onVRDisplayChanged;
  96309. private moveButtonToBottomRight;
  96310. private displayVRButton;
  96311. private updateButtonVisibility;
  96312. private _cachedAngularSensibility;
  96313. /**
  96314. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96315. * Otherwise, will use the fullscreen API.
  96316. */
  96317. enterVR(): void;
  96318. /**
  96319. * Attempt to exit VR, or fullscreen.
  96320. */
  96321. exitVR(): void;
  96322. /**
  96323. * The position of the vr experience helper.
  96324. */
  96325. /**
  96326. * Sets the position of the vr experience helper.
  96327. */
  96328. position: Vector3;
  96329. /**
  96330. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96331. */
  96332. enableInteractions(): void;
  96333. private readonly _noControllerIsActive;
  96334. private beforeRender;
  96335. private _isTeleportationFloor;
  96336. /**
  96337. * Adds a floor mesh to be used for teleportation.
  96338. * @param floorMesh the mesh to be used for teleportation.
  96339. */
  96340. addFloorMesh(floorMesh: Mesh): void;
  96341. /**
  96342. * Removes a floor mesh from being used for teleportation.
  96343. * @param floorMesh the mesh to be removed.
  96344. */
  96345. removeFloorMesh(floorMesh: Mesh): void;
  96346. /**
  96347. * Enables interactions and teleportation using the VR controllers and gaze.
  96348. * @param vrTeleportationOptions options to modify teleportation behavior.
  96349. */
  96350. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96351. private _onNewGamepadConnected;
  96352. private _tryEnableInteractionOnController;
  96353. private _onNewGamepadDisconnected;
  96354. private _enableInteractionOnController;
  96355. private _checkTeleportWithRay;
  96356. private _checkRotate;
  96357. private _checkTeleportBackwards;
  96358. private _enableTeleportationOnController;
  96359. private _createTeleportationCircles;
  96360. private _displayTeleportationTarget;
  96361. private _hideTeleportationTarget;
  96362. private _rotateCamera;
  96363. private _moveTeleportationSelectorTo;
  96364. private _workingVector;
  96365. private _workingQuaternion;
  96366. private _workingMatrix;
  96367. /**
  96368. * Teleports the users feet to the desired location
  96369. * @param location The location where the user's feet should be placed
  96370. */
  96371. teleportCamera(location: Vector3): void;
  96372. private _convertNormalToDirectionOfRay;
  96373. private _castRayAndSelectObject;
  96374. private _notifySelectedMeshUnselected;
  96375. /**
  96376. * Sets the color of the laser ray from the vr controllers.
  96377. * @param color new color for the ray.
  96378. */
  96379. changeLaserColor(color: Color3): void;
  96380. /**
  96381. * Sets the color of the ray from the vr headsets gaze.
  96382. * @param color new color for the ray.
  96383. */
  96384. changeGazeColor(color: Color3): void;
  96385. /**
  96386. * Exits VR and disposes of the vr experience helper
  96387. */
  96388. dispose(): void;
  96389. /**
  96390. * Gets the name of the VRExperienceHelper class
  96391. * @returns "VRExperienceHelper"
  96392. */
  96393. getClassName(): string;
  96394. }
  96395. }
  96396. declare module BABYLON {
  96397. /**
  96398. * Manages an XRSession
  96399. * @see https://doc.babylonjs.com/how_to/webxr
  96400. */
  96401. export class WebXRSessionManager implements IDisposable {
  96402. private scene;
  96403. /**
  96404. * Fires every time a new xrFrame arrives which can be used to update the camera
  96405. */
  96406. onXRFrameObservable: Observable<any>;
  96407. /**
  96408. * Fires when the xr session is ended either by the device or manually done
  96409. */
  96410. onXRSessionEnded: Observable<any>;
  96411. /** @hidden */
  96412. _xrSession: XRSession;
  96413. /** @hidden */
  96414. _frameOfReference: XRFrameOfReference;
  96415. /** @hidden */
  96416. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96417. /** @hidden */
  96418. _currentXRFrame: Nullable<XRFrame>;
  96419. private _xrNavigator;
  96420. private _xrDevice;
  96421. private _tmpMatrix;
  96422. /**
  96423. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96424. * @param scene The scene which the session should be created for
  96425. */
  96426. constructor(scene: Scene);
  96427. /**
  96428. * Initializes the manager
  96429. * After initialization enterXR can be called to start an XR session
  96430. * @returns Promise which resolves after it is initialized
  96431. */
  96432. initializeAsync(): Promise<void>;
  96433. /**
  96434. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96435. * @param sessionCreationOptions xr options to create the session with
  96436. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96437. * @returns Promise which resolves after it enters XR
  96438. */
  96439. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96440. /**
  96441. * Stops the xrSession and restores the renderloop
  96442. * @returns Promise which resolves after it exits XR
  96443. */
  96444. exitXRAsync(): Promise<void>;
  96445. /**
  96446. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96447. * @param ray ray to cast into the environment
  96448. * @returns Promise which resolves with a collision point in the environment if it exists
  96449. */
  96450. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96451. /**
  96452. * Checks if a session would be supported for the creation options specified
  96453. * @param options creation options to check if they are supported
  96454. * @returns true if supported
  96455. */
  96456. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96457. /**
  96458. * @hidden
  96459. * Converts the render layer of xrSession to a render target
  96460. * @param session session to create render target for
  96461. * @param scene scene the new render target should be created for
  96462. */
  96463. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96464. /**
  96465. * Disposes of the session manager
  96466. */
  96467. dispose(): void;
  96468. }
  96469. }
  96470. declare module BABYLON {
  96471. /**
  96472. * WebXR Camera which holds the views for the xrSession
  96473. * @see https://doc.babylonjs.com/how_to/webxr
  96474. */
  96475. export class WebXRCamera extends FreeCamera {
  96476. private static _TmpMatrix;
  96477. /**
  96478. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  96479. * @param name the name of the camera
  96480. * @param scene the scene to add the camera to
  96481. */
  96482. constructor(name: string, scene: Scene);
  96483. private _updateNumberOfRigCameras;
  96484. /** @hidden */
  96485. _updateForDualEyeDebugging(pupilDistance?: number): void;
  96486. /**
  96487. * Updates the cameras position from the current pose information of the XR session
  96488. * @param xrSessionManager the session containing pose information
  96489. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  96490. */
  96491. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  96492. }
  96493. }
  96494. declare module BABYLON {
  96495. /**
  96496. * States of the webXR experience
  96497. */
  96498. export enum WebXRState {
  96499. /**
  96500. * Transitioning to being in XR mode
  96501. */
  96502. ENTERING_XR = 0,
  96503. /**
  96504. * Transitioning to non XR mode
  96505. */
  96506. EXITING_XR = 1,
  96507. /**
  96508. * In XR mode and presenting
  96509. */
  96510. IN_XR = 2,
  96511. /**
  96512. * Not entered XR mode
  96513. */
  96514. NOT_IN_XR = 3
  96515. }
  96516. /**
  96517. * Helper class used to enable XR
  96518. * @see https://doc.babylonjs.com/how_to/webxr
  96519. */
  96520. export class WebXRExperienceHelper implements IDisposable {
  96521. private scene;
  96522. /**
  96523. * 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
  96524. */
  96525. container: AbstractMesh;
  96526. /**
  96527. * Camera used to render xr content
  96528. */
  96529. camera: WebXRCamera;
  96530. /**
  96531. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  96532. */
  96533. state: WebXRState;
  96534. private _setState;
  96535. private static _TmpVector;
  96536. /**
  96537. * Fires when the state of the experience helper has changed
  96538. */
  96539. onStateChangedObservable: Observable<WebXRState>;
  96540. /** @hidden */
  96541. _sessionManager: WebXRSessionManager;
  96542. private _nonVRCamera;
  96543. private _originalSceneAutoClear;
  96544. private _supported;
  96545. /**
  96546. * Creates the experience helper
  96547. * @param scene the scene to attach the experience helper to
  96548. * @returns a promise for the experience helper
  96549. */
  96550. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  96551. /**
  96552. * Creates a WebXRExperienceHelper
  96553. * @param scene The scene the helper should be created in
  96554. */
  96555. private constructor();
  96556. /**
  96557. * Exits XR mode and returns the scene to its original state
  96558. * @returns promise that resolves after xr mode has exited
  96559. */
  96560. exitXRAsync(): Promise<void>;
  96561. /**
  96562. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  96563. * @param sessionCreationOptions options for the XR session
  96564. * @param frameOfReference frame of reference of the XR session
  96565. * @returns promise that resolves after xr mode has entered
  96566. */
  96567. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  96568. /**
  96569. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96570. * @param ray ray to cast into the environment
  96571. * @returns Promise which resolves with a collision point in the environment if it exists
  96572. */
  96573. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96574. /**
  96575. * Updates the global position of the camera by moving the camera's container
  96576. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  96577. * @param position The desired global position of the camera
  96578. */
  96579. setPositionOfCameraUsingContainer(position: Vector3): void;
  96580. /**
  96581. * Rotates the xr camera by rotating the camera's container around the camera's position
  96582. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  96583. * @param rotation the desired quaternion rotation to apply to the camera
  96584. */
  96585. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  96586. /**
  96587. * Checks if the creation options are supported by the xr session
  96588. * @param options creation options
  96589. * @returns true if supported
  96590. */
  96591. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96592. /**
  96593. * Disposes of the experience helper
  96594. */
  96595. dispose(): void;
  96596. }
  96597. }
  96598. declare module BABYLON {
  96599. /**
  96600. * Button which can be used to enter a different mode of XR
  96601. */
  96602. export class WebXREnterExitUIButton {
  96603. /** button element */
  96604. element: HTMLElement;
  96605. /** XR initialization options for the button */
  96606. initializationOptions: XRSessionCreationOptions;
  96607. /**
  96608. * Creates a WebXREnterExitUIButton
  96609. * @param element button element
  96610. * @param initializationOptions XR initialization options for the button
  96611. */
  96612. constructor(
  96613. /** button element */
  96614. element: HTMLElement,
  96615. /** XR initialization options for the button */
  96616. initializationOptions: XRSessionCreationOptions);
  96617. /**
  96618. * Overwritable function which can be used to update the button's visuals when the state changes
  96619. * @param activeButton the current active button in the UI
  96620. */
  96621. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  96622. }
  96623. /**
  96624. * Options to create the webXR UI
  96625. */
  96626. export class WebXREnterExitUIOptions {
  96627. /**
  96628. * Context to enter xr with
  96629. */
  96630. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  96631. /**
  96632. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  96633. */
  96634. customButtons?: Array<WebXREnterExitUIButton>;
  96635. }
  96636. /**
  96637. * UI to allow the user to enter/exit XR mode
  96638. */
  96639. export class WebXREnterExitUI implements IDisposable {
  96640. private scene;
  96641. private _overlay;
  96642. private _buttons;
  96643. private _activeButton;
  96644. /**
  96645. * Fired every time the active button is changed.
  96646. *
  96647. * When xr is entered via a button that launches xr that button will be the callback parameter
  96648. *
  96649. * When exiting xr the callback parameter will be null)
  96650. */
  96651. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  96652. /**
  96653. * Creates UI to allow the user to enter/exit XR mode
  96654. * @param scene the scene to add the ui to
  96655. * @param helper the xr experience helper to enter/exit xr with
  96656. * @param options options to configure the UI
  96657. * @returns the created ui
  96658. */
  96659. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  96660. private constructor();
  96661. private _updateButtons;
  96662. /**
  96663. * Disposes of the object
  96664. */
  96665. dispose(): void;
  96666. }
  96667. }
  96668. declare module BABYLON {
  96669. /**
  96670. * Represents an XR input
  96671. */
  96672. export class WebXRController {
  96673. /**
  96674. * 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
  96675. */
  96676. grip?: AbstractMesh;
  96677. /**
  96678. * Pointer which can be used to select objects or attach a visible laser to
  96679. */
  96680. pointer: AbstractMesh;
  96681. /**
  96682. * Creates the controller
  96683. * @see https://doc.babylonjs.com/how_to/webxr
  96684. * @param scene the scene which the controller should be associated to
  96685. */
  96686. constructor(scene: Scene);
  96687. /**
  96688. * Disposes of the object
  96689. */
  96690. dispose(): void;
  96691. }
  96692. /**
  96693. * XR input used to track XR inputs such as controllers/rays
  96694. */
  96695. export class WebXRInput implements IDisposable {
  96696. private helper;
  96697. /**
  96698. * XR controllers being tracked
  96699. */
  96700. controllers: Array<WebXRController>;
  96701. private _tmpMatrix;
  96702. private _frameObserver;
  96703. /**
  96704. * Initializes the WebXRInput
  96705. * @param helper experience helper which the input should be created for
  96706. */
  96707. constructor(helper: WebXRExperienceHelper);
  96708. /**
  96709. * Disposes of the object
  96710. */
  96711. dispose(): void;
  96712. }
  96713. }
  96714. declare module BABYLON {
  96715. /**
  96716. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  96717. */
  96718. export class WebXRManagedOutputCanvas implements IDisposable {
  96719. private _canvas;
  96720. /**
  96721. * xrpresent context of the canvas which can be used to display/mirror xr content
  96722. */
  96723. canvasContext: Nullable<WebGLRenderingContext>;
  96724. /**
  96725. * Initializes the canvas to be added/removed upon entering/exiting xr
  96726. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  96727. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  96728. */
  96729. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  96730. /**
  96731. * Disposes of the object
  96732. */
  96733. dispose(): void;
  96734. private _setManagedOutputCanvas;
  96735. private _addCanvas;
  96736. private _removeCanvas;
  96737. }
  96738. }
  96739. declare module BABYLON {
  96740. /**
  96741. * Contains an array of blocks representing the octree
  96742. */
  96743. export interface IOctreeContainer<T> {
  96744. /**
  96745. * Blocks within the octree
  96746. */
  96747. blocks: Array<OctreeBlock<T>>;
  96748. }
  96749. /**
  96750. * Class used to store a cell in an octree
  96751. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96752. */
  96753. export class OctreeBlock<T> {
  96754. /**
  96755. * Gets the content of the current block
  96756. */
  96757. entries: T[];
  96758. /**
  96759. * Gets the list of block children
  96760. */
  96761. blocks: Array<OctreeBlock<T>>;
  96762. private _depth;
  96763. private _maxDepth;
  96764. private _capacity;
  96765. private _minPoint;
  96766. private _maxPoint;
  96767. private _boundingVectors;
  96768. private _creationFunc;
  96769. /**
  96770. * Creates a new block
  96771. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  96772. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  96773. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96774. * @param depth defines the current depth of this block in the octree
  96775. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  96776. * @param creationFunc defines a callback to call when an element is added to the block
  96777. */
  96778. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  96779. /**
  96780. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96781. */
  96782. readonly capacity: number;
  96783. /**
  96784. * Gets the minimum vector (in world space) of the block's bounding box
  96785. */
  96786. readonly minPoint: Vector3;
  96787. /**
  96788. * Gets the maximum vector (in world space) of the block's bounding box
  96789. */
  96790. readonly maxPoint: Vector3;
  96791. /**
  96792. * Add a new element to this block
  96793. * @param entry defines the element to add
  96794. */
  96795. addEntry(entry: T): void;
  96796. /**
  96797. * Remove an element from this block
  96798. * @param entry defines the element to remove
  96799. */
  96800. removeEntry(entry: T): void;
  96801. /**
  96802. * Add an array of elements to this block
  96803. * @param entries defines the array of elements to add
  96804. */
  96805. addEntries(entries: T[]): void;
  96806. /**
  96807. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  96808. * @param frustumPlanes defines the frustum planes to test
  96809. * @param selection defines the array to store current content if selection is positive
  96810. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96811. */
  96812. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96813. /**
  96814. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  96815. * @param sphereCenter defines the bounding sphere center
  96816. * @param sphereRadius defines the bounding sphere radius
  96817. * @param selection defines the array to store current content if selection is positive
  96818. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96819. */
  96820. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96821. /**
  96822. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  96823. * @param ray defines the ray to test with
  96824. * @param selection defines the array to store current content if selection is positive
  96825. */
  96826. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  96827. /**
  96828. * Subdivide the content into child blocks (this block will then be empty)
  96829. */
  96830. createInnerBlocks(): void;
  96831. /**
  96832. * @hidden
  96833. */
  96834. 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;
  96835. }
  96836. }
  96837. declare module BABYLON {
  96838. /**
  96839. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  96840. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96841. */
  96842. export class Octree<T> {
  96843. /** 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.) */
  96844. maxDepth: number;
  96845. /**
  96846. * Blocks within the octree containing objects
  96847. */
  96848. blocks: Array<OctreeBlock<T>>;
  96849. /**
  96850. * Content stored in the octree
  96851. */
  96852. dynamicContent: T[];
  96853. private _maxBlockCapacity;
  96854. private _selectionContent;
  96855. private _creationFunc;
  96856. /**
  96857. * Creates a octree
  96858. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96859. * @param creationFunc function to be used to instatiate the octree
  96860. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  96861. * @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.)
  96862. */
  96863. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  96864. /** 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.) */
  96865. maxDepth?: number);
  96866. /**
  96867. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  96868. * @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);
  96869. * @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);
  96870. * @param entries meshes to be added to the octree blocks
  96871. */
  96872. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  96873. /**
  96874. * Adds a mesh to the octree
  96875. * @param entry Mesh to add to the octree
  96876. */
  96877. addMesh(entry: T): void;
  96878. /**
  96879. * Remove an element from the octree
  96880. * @param entry defines the element to remove
  96881. */
  96882. removeMesh(entry: T): void;
  96883. /**
  96884. * Selects an array of meshes within the frustum
  96885. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  96886. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  96887. * @returns array of meshes within the frustum
  96888. */
  96889. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  96890. /**
  96891. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  96892. * @param sphereCenter defines the bounding sphere center
  96893. * @param sphereRadius defines the bounding sphere radius
  96894. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96895. * @returns an array of objects that intersect the sphere
  96896. */
  96897. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  96898. /**
  96899. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  96900. * @param ray defines the ray to test with
  96901. * @returns array of intersected objects
  96902. */
  96903. intersectsRay(ray: Ray): SmartArray<T>;
  96904. /**
  96905. * Adds a mesh into the octree block if it intersects the block
  96906. */
  96907. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  96908. /**
  96909. * Adds a submesh into the octree block if it intersects the block
  96910. */
  96911. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  96912. }
  96913. }
  96914. declare module BABYLON {
  96915. interface Scene {
  96916. /**
  96917. * @hidden
  96918. * Backing Filed
  96919. */
  96920. _selectionOctree: Octree<AbstractMesh>;
  96921. /**
  96922. * Gets the octree used to boost mesh selection (picking)
  96923. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96924. */
  96925. selectionOctree: Octree<AbstractMesh>;
  96926. /**
  96927. * Creates or updates the octree used to boost selection (picking)
  96928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96929. * @param maxCapacity defines the maximum capacity per leaf
  96930. * @param maxDepth defines the maximum depth of the octree
  96931. * @returns an octree of AbstractMesh
  96932. */
  96933. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  96934. }
  96935. interface AbstractMesh {
  96936. /**
  96937. * @hidden
  96938. * Backing Field
  96939. */
  96940. _submeshesOctree: Octree<SubMesh>;
  96941. /**
  96942. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  96943. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96944. * @param maxCapacity defines the maximum size of each block (64 by default)
  96945. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  96946. * @returns the new octree
  96947. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  96948. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96949. */
  96950. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  96951. }
  96952. /**
  96953. * Defines the octree scene component responsible to manage any octrees
  96954. * in a given scene.
  96955. */
  96956. export class OctreeSceneComponent {
  96957. /**
  96958. * The component name helpfull to identify the component in the list of scene components.
  96959. */
  96960. readonly name: string;
  96961. /**
  96962. * The scene the component belongs to.
  96963. */
  96964. scene: Scene;
  96965. /**
  96966. * Indicates if the meshes have been checked to make sure they are isEnabled()
  96967. */
  96968. readonly checksIsEnabled: boolean;
  96969. /**
  96970. * Creates a new instance of the component for the given scene
  96971. * @param scene Defines the scene to register the component in
  96972. */
  96973. constructor(scene: Scene);
  96974. /**
  96975. * Registers the component in a given scene
  96976. */
  96977. register(): void;
  96978. /**
  96979. * Return the list of active meshes
  96980. * @returns the list of active meshes
  96981. */
  96982. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96983. /**
  96984. * Return the list of active sub meshes
  96985. * @param mesh The mesh to get the candidates sub meshes from
  96986. * @returns the list of active sub meshes
  96987. */
  96988. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  96989. private _tempRay;
  96990. /**
  96991. * Return the list of sub meshes intersecting with a given local ray
  96992. * @param mesh defines the mesh to find the submesh for
  96993. * @param localRay defines the ray in local space
  96994. * @returns the list of intersecting sub meshes
  96995. */
  96996. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  96997. /**
  96998. * Return the list of sub meshes colliding with a collider
  96999. * @param mesh defines the mesh to find the submesh for
  97000. * @param collider defines the collider to evaluate the collision against
  97001. * @returns the list of colliding sub meshes
  97002. */
  97003. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97004. /**
  97005. * Rebuilds the elements related to this component in case of
  97006. * context lost for instance.
  97007. */
  97008. rebuild(): void;
  97009. /**
  97010. * Disposes the component and the associated ressources.
  97011. */
  97012. dispose(): void;
  97013. }
  97014. }
  97015. declare module BABYLON {
  97016. /**
  97017. * Class containing static functions to help procedurally build meshes
  97018. */
  97019. export class LinesBuilder {
  97020. /**
  97021. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97022. * * 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
  97023. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97024. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97025. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97026. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97027. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97028. * * 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
  97029. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97032. * @param name defines the name of the new line system
  97033. * @param options defines the options used to create the line system
  97034. * @param scene defines the hosting scene
  97035. * @returns a new line system mesh
  97036. */
  97037. static CreateLineSystem(name: string, options: {
  97038. lines: Vector3[][];
  97039. updatable?: boolean;
  97040. instance?: Nullable<LinesMesh>;
  97041. colors?: Nullable<Color4[][]>;
  97042. useVertexAlpha?: boolean;
  97043. }, scene: Nullable<Scene>): LinesMesh;
  97044. /**
  97045. * Creates a line mesh
  97046. * 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
  97047. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97048. * * The parameter `points` is an array successive Vector3
  97049. * * 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
  97050. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97051. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97052. * * When updating an instance, remember that only point positions can change, not the number of points
  97053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97055. * @param name defines the name of the new line system
  97056. * @param options defines the options used to create the line system
  97057. * @param scene defines the hosting scene
  97058. * @returns a new line mesh
  97059. */
  97060. static CreateLines(name: string, options: {
  97061. points: Vector3[];
  97062. updatable?: boolean;
  97063. instance?: Nullable<LinesMesh>;
  97064. colors?: Color4[];
  97065. useVertexAlpha?: boolean;
  97066. }, scene?: Nullable<Scene>): LinesMesh;
  97067. /**
  97068. * Creates a dashed line mesh
  97069. * * 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
  97070. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97071. * * The parameter `points` is an array successive Vector3
  97072. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97073. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97074. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97075. * * 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
  97076. * * When updating an instance, remember that only point positions can change, not the number of points
  97077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97078. * @param name defines the name of the mesh
  97079. * @param options defines the options used to create the mesh
  97080. * @param scene defines the hosting scene
  97081. * @returns the dashed line mesh
  97082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97083. */
  97084. static CreateDashedLines(name: string, options: {
  97085. points: Vector3[];
  97086. dashSize?: number;
  97087. gapSize?: number;
  97088. dashNb?: number;
  97089. updatable?: boolean;
  97090. instance?: LinesMesh;
  97091. }, scene?: Nullable<Scene>): LinesMesh;
  97092. }
  97093. }
  97094. declare module BABYLON {
  97095. /**
  97096. * Renders a layer on top of an existing scene
  97097. */
  97098. export class UtilityLayerRenderer implements IDisposable {
  97099. /** the original scene that will be rendered on top of */
  97100. originalScene: Scene;
  97101. private _pointerCaptures;
  97102. private _lastPointerEvents;
  97103. private static _DefaultUtilityLayer;
  97104. private static _DefaultKeepDepthUtilityLayer;
  97105. /**
  97106. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97107. */
  97108. pickUtilitySceneFirst: boolean;
  97109. /**
  97110. * 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)
  97111. */
  97112. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97113. /**
  97114. * 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)
  97115. */
  97116. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97117. /**
  97118. * The scene that is rendered on top of the original scene
  97119. */
  97120. utilityLayerScene: Scene;
  97121. /**
  97122. * If the utility layer should automatically be rendered on top of existing scene
  97123. */
  97124. shouldRender: boolean;
  97125. /**
  97126. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97127. */
  97128. onlyCheckPointerDownEvents: boolean;
  97129. /**
  97130. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97131. */
  97132. processAllEvents: boolean;
  97133. /**
  97134. * Observable raised when the pointer move from the utility layer scene to the main scene
  97135. */
  97136. onPointerOutObservable: Observable<number>;
  97137. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97138. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97139. private _afterRenderObserver;
  97140. private _sceneDisposeObserver;
  97141. private _originalPointerObserver;
  97142. /**
  97143. * Instantiates a UtilityLayerRenderer
  97144. * @param originalScene the original scene that will be rendered on top of
  97145. * @param handleEvents boolean indicating if the utility layer should handle events
  97146. */
  97147. constructor(
  97148. /** the original scene that will be rendered on top of */
  97149. originalScene: Scene, handleEvents?: boolean);
  97150. private _notifyObservers;
  97151. /**
  97152. * Renders the utility layers scene on top of the original scene
  97153. */
  97154. render(): void;
  97155. /**
  97156. * Disposes of the renderer
  97157. */
  97158. dispose(): void;
  97159. private _updateCamera;
  97160. }
  97161. }
  97162. declare module BABYLON {
  97163. /**
  97164. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97165. */
  97166. export class Gizmo implements IDisposable {
  97167. /** The utility layer the gizmo will be added to */
  97168. gizmoLayer: UtilityLayerRenderer;
  97169. /**
  97170. * The root mesh of the gizmo
  97171. */
  97172. _rootMesh: Mesh;
  97173. private _attachedMesh;
  97174. /**
  97175. * Ratio for the scale of the gizmo (Default: 1)
  97176. */
  97177. scaleRatio: number;
  97178. private _tmpMatrix;
  97179. /**
  97180. * If a custom mesh has been set (Default: false)
  97181. */
  97182. protected _customMeshSet: boolean;
  97183. /**
  97184. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97185. * * When set, interactions will be enabled
  97186. */
  97187. attachedMesh: Nullable<AbstractMesh>;
  97188. /**
  97189. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97190. * @param mesh The mesh to replace the default mesh of the gizmo
  97191. */
  97192. setCustomMesh(mesh: Mesh): void;
  97193. /**
  97194. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97195. */
  97196. updateGizmoRotationToMatchAttachedMesh: boolean;
  97197. /**
  97198. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97199. */
  97200. updateGizmoPositionToMatchAttachedMesh: boolean;
  97201. /**
  97202. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97203. */
  97204. protected _updateScale: boolean;
  97205. protected _interactionsEnabled: boolean;
  97206. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97207. private _beforeRenderObserver;
  97208. /**
  97209. * Creates a gizmo
  97210. * @param gizmoLayer The utility layer the gizmo will be added to
  97211. */
  97212. constructor(
  97213. /** The utility layer the gizmo will be added to */
  97214. gizmoLayer?: UtilityLayerRenderer);
  97215. private _tempVector;
  97216. /**
  97217. * @hidden
  97218. * Updates the gizmo to match the attached mesh's position/rotation
  97219. */
  97220. protected _update(): void;
  97221. /**
  97222. * Disposes of the gizmo
  97223. */
  97224. dispose(): void;
  97225. }
  97226. }
  97227. declare module BABYLON {
  97228. /**
  97229. * Single axis drag gizmo
  97230. */
  97231. export class AxisDragGizmo extends Gizmo {
  97232. /**
  97233. * Drag behavior responsible for the gizmos dragging interactions
  97234. */
  97235. dragBehavior: PointerDragBehavior;
  97236. private _pointerObserver;
  97237. /**
  97238. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97239. */
  97240. snapDistance: number;
  97241. /**
  97242. * Event that fires each time the gizmo snaps to a new location.
  97243. * * snapDistance is the the change in distance
  97244. */
  97245. onSnapObservable: Observable<{
  97246. snapDistance: number;
  97247. }>;
  97248. /** @hidden */
  97249. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97250. /** @hidden */
  97251. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97252. /**
  97253. * Creates an AxisDragGizmo
  97254. * @param gizmoLayer The utility layer the gizmo will be added to
  97255. * @param dragAxis The axis which the gizmo will be able to drag on
  97256. * @param color The color of the gizmo
  97257. */
  97258. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97259. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97260. /**
  97261. * Disposes of the gizmo
  97262. */
  97263. dispose(): void;
  97264. }
  97265. }
  97266. declare module BABYLON.Debug {
  97267. /**
  97268. * The Axes viewer will show 3 axes in a specific point in space
  97269. */
  97270. export class AxesViewer {
  97271. private _xAxis;
  97272. private _yAxis;
  97273. private _zAxis;
  97274. private _scaleLinesFactor;
  97275. private _instanced;
  97276. /**
  97277. * Gets the hosting scene
  97278. */
  97279. scene: Scene;
  97280. /**
  97281. * Gets or sets a number used to scale line length
  97282. */
  97283. scaleLines: number;
  97284. /** Gets the node hierarchy used to render x-axis */
  97285. readonly xAxis: TransformNode;
  97286. /** Gets the node hierarchy used to render y-axis */
  97287. readonly yAxis: TransformNode;
  97288. /** Gets the node hierarchy used to render z-axis */
  97289. readonly zAxis: TransformNode;
  97290. /**
  97291. * Creates a new AxesViewer
  97292. * @param scene defines the hosting scene
  97293. * @param scaleLines defines a number used to scale line length (1 by default)
  97294. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97295. * @param xAxis defines the node hierarchy used to render the x-axis
  97296. * @param yAxis defines the node hierarchy used to render the y-axis
  97297. * @param zAxis defines the node hierarchy used to render the z-axis
  97298. */
  97299. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97300. /**
  97301. * Force the viewer to update
  97302. * @param position defines the position of the viewer
  97303. * @param xaxis defines the x axis of the viewer
  97304. * @param yaxis defines the y axis of the viewer
  97305. * @param zaxis defines the z axis of the viewer
  97306. */
  97307. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97308. /**
  97309. * Creates an instance of this axes viewer.
  97310. * @returns a new axes viewer with instanced meshes
  97311. */
  97312. createInstance(): AxesViewer;
  97313. /** Releases resources */
  97314. dispose(): void;
  97315. private static _SetRenderingGroupId;
  97316. }
  97317. }
  97318. declare module BABYLON.Debug {
  97319. /**
  97320. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97321. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97322. */
  97323. export class BoneAxesViewer extends AxesViewer {
  97324. /**
  97325. * Gets or sets the target mesh where to display the axes viewer
  97326. */
  97327. mesh: Nullable<Mesh>;
  97328. /**
  97329. * Gets or sets the target bone where to display the axes viewer
  97330. */
  97331. bone: Nullable<Bone>;
  97332. /** Gets current position */
  97333. pos: Vector3;
  97334. /** Gets direction of X axis */
  97335. xaxis: Vector3;
  97336. /** Gets direction of Y axis */
  97337. yaxis: Vector3;
  97338. /** Gets direction of Z axis */
  97339. zaxis: Vector3;
  97340. /**
  97341. * Creates a new BoneAxesViewer
  97342. * @param scene defines the hosting scene
  97343. * @param bone defines the target bone
  97344. * @param mesh defines the target mesh
  97345. * @param scaleLines defines a scaling factor for line length (1 by default)
  97346. */
  97347. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97348. /**
  97349. * Force the viewer to update
  97350. */
  97351. update(): void;
  97352. /** Releases resources */
  97353. dispose(): void;
  97354. }
  97355. }
  97356. declare module BABYLON {
  97357. /**
  97358. * Interface used to define scene explorer extensibility option
  97359. */
  97360. export interface IExplorerExtensibilityOption {
  97361. /**
  97362. * Define the option label
  97363. */
  97364. label: string;
  97365. /**
  97366. * Defines the action to execute on click
  97367. */
  97368. action: (entity: any) => void;
  97369. }
  97370. /**
  97371. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97372. */
  97373. export interface IExplorerExtensibilityGroup {
  97374. /**
  97375. * Defines a predicate to test if a given type mut be extended
  97376. */
  97377. predicate: (entity: any) => boolean;
  97378. /**
  97379. * Gets the list of options added to a type
  97380. */
  97381. entries: IExplorerExtensibilityOption[];
  97382. }
  97383. /**
  97384. * Interface used to define the options to use to create the Inspector
  97385. */
  97386. export interface IInspectorOptions {
  97387. /**
  97388. * Display in overlay mode (default: false)
  97389. */
  97390. overlay?: boolean;
  97391. /**
  97392. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97393. */
  97394. globalRoot?: HTMLElement;
  97395. /**
  97396. * Display the Scene explorer
  97397. */
  97398. showExplorer?: boolean;
  97399. /**
  97400. * Display the property inspector
  97401. */
  97402. showInspector?: boolean;
  97403. /**
  97404. * Display in embed mode (both panes on the right)
  97405. */
  97406. embedMode?: boolean;
  97407. /**
  97408. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97409. */
  97410. handleResize?: boolean;
  97411. /**
  97412. * Allow the panes to popup (default: true)
  97413. */
  97414. enablePopup?: boolean;
  97415. /**
  97416. * Allow the panes to be closed by users (default: true)
  97417. */
  97418. enableClose?: boolean;
  97419. /**
  97420. * Optional list of extensibility entries
  97421. */
  97422. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97423. /**
  97424. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97425. */
  97426. inspectorURL?: string;
  97427. }
  97428. interface Scene {
  97429. /**
  97430. * @hidden
  97431. * Backing field
  97432. */
  97433. _debugLayer: DebugLayer;
  97434. /**
  97435. * Gets the debug layer (aka Inspector) associated with the scene
  97436. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97437. */
  97438. debugLayer: DebugLayer;
  97439. }
  97440. /**
  97441. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97442. * what is happening in your scene
  97443. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97444. */
  97445. export class DebugLayer {
  97446. /**
  97447. * Define the url to get the inspector script from.
  97448. * By default it uses the babylonjs CDN.
  97449. * @ignoreNaming
  97450. */
  97451. static InspectorURL: string;
  97452. private _scene;
  97453. private BJSINSPECTOR;
  97454. /**
  97455. * Observable triggered when a property is changed through the inspector.
  97456. */
  97457. onPropertyChangedObservable: Observable<{
  97458. object: any;
  97459. property: string;
  97460. value: any;
  97461. initialValue: any;
  97462. }>;
  97463. /**
  97464. * Instantiates a new debug layer.
  97465. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97466. * what is happening in your scene
  97467. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97468. * @param scene Defines the scene to inspect
  97469. */
  97470. constructor(scene: Scene);
  97471. /** Creates the inspector window. */
  97472. private _createInspector;
  97473. /**
  97474. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  97475. * @param entity defines the entity to select
  97476. * @param lineContainerTitle defines the specific block to highlight
  97477. */
  97478. select(entity: any, lineContainerTitle?: string): void;
  97479. /** Get the inspector from bundle or global */
  97480. private _getGlobalInspector;
  97481. /**
  97482. * Get if the inspector is visible or not.
  97483. * @returns true if visible otherwise, false
  97484. */
  97485. isVisible(): boolean;
  97486. /**
  97487. * Hide the inspector and close its window.
  97488. */
  97489. hide(): void;
  97490. /**
  97491. * Launch the debugLayer.
  97492. * @param config Define the configuration of the inspector
  97493. * @return a promise fulfilled when the debug layer is visible
  97494. */
  97495. show(config?: IInspectorOptions): Promise<DebugLayer>;
  97496. }
  97497. }
  97498. declare module BABYLON {
  97499. /**
  97500. * Class containing static functions to help procedurally build meshes
  97501. */
  97502. export class BoxBuilder {
  97503. /**
  97504. * Creates a box mesh
  97505. * * The parameter `size` sets the size (float) of each box side (default 1)
  97506. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  97507. * * 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)
  97508. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  97509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97510. * * If you create a double-sided mesh, you can choose what parts of 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
  97511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97512. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  97513. * @param name defines the name of the mesh
  97514. * @param options defines the options used to create the mesh
  97515. * @param scene defines the hosting scene
  97516. * @returns the box mesh
  97517. */
  97518. static CreateBox(name: string, options: {
  97519. size?: number;
  97520. width?: number;
  97521. height?: number;
  97522. depth?: number;
  97523. faceUV?: Vector4[];
  97524. faceColors?: Color4[];
  97525. sideOrientation?: number;
  97526. frontUVs?: Vector4;
  97527. backUVs?: Vector4;
  97528. updatable?: boolean;
  97529. }, scene?: Nullable<Scene>): Mesh;
  97530. }
  97531. }
  97532. declare module BABYLON {
  97533. /**
  97534. * Class containing static functions to help procedurally build meshes
  97535. */
  97536. export class SphereBuilder {
  97537. /**
  97538. * Creates a sphere mesh
  97539. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  97540. * * 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`)
  97541. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  97542. * * 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
  97543. * * 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)
  97544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97545. * * If you create a double-sided mesh, you can choose what parts of 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
  97546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97547. * @param name defines the name of the mesh
  97548. * @param options defines the options used to create the mesh
  97549. * @param scene defines the hosting scene
  97550. * @returns the sphere mesh
  97551. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  97552. */
  97553. static CreateSphere(name: string, options: {
  97554. segments?: number;
  97555. diameter?: number;
  97556. diameterX?: number;
  97557. diameterY?: number;
  97558. diameterZ?: number;
  97559. arc?: number;
  97560. slice?: number;
  97561. sideOrientation?: number;
  97562. frontUVs?: Vector4;
  97563. backUVs?: Vector4;
  97564. updatable?: boolean;
  97565. }, scene: any): Mesh;
  97566. }
  97567. }
  97568. declare module BABYLON.Debug {
  97569. /**
  97570. * Used to show the physics impostor around the specific mesh
  97571. */
  97572. export class PhysicsViewer {
  97573. /** @hidden */
  97574. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  97575. /** @hidden */
  97576. protected _meshes: Array<Nullable<AbstractMesh>>;
  97577. /** @hidden */
  97578. protected _scene: Nullable<Scene>;
  97579. /** @hidden */
  97580. protected _numMeshes: number;
  97581. /** @hidden */
  97582. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  97583. private _renderFunction;
  97584. private _utilityLayer;
  97585. private _debugBoxMesh;
  97586. private _debugSphereMesh;
  97587. private _debugMaterial;
  97588. /**
  97589. * Creates a new PhysicsViewer
  97590. * @param scene defines the hosting scene
  97591. */
  97592. constructor(scene: Scene);
  97593. /** @hidden */
  97594. protected _updateDebugMeshes(): void;
  97595. /**
  97596. * Renders a specified physic impostor
  97597. * @param impostor defines the impostor to render
  97598. * @returns the new debug mesh used to render the impostor
  97599. */
  97600. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  97601. /**
  97602. * Hides a specified physic impostor
  97603. * @param impostor defines the impostor to hide
  97604. */
  97605. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  97606. private _getDebugMaterial;
  97607. private _getDebugBoxMesh;
  97608. private _getDebugSphereMesh;
  97609. private _getDebugMesh;
  97610. /** Releases all resources */
  97611. dispose(): void;
  97612. }
  97613. }
  97614. declare module BABYLON {
  97615. /**
  97616. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97617. * in order to better appreciate the issue one might have.
  97618. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97619. */
  97620. export class RayHelper {
  97621. /**
  97622. * Defines the ray we are currently tryin to visualize.
  97623. */
  97624. ray: Nullable<Ray>;
  97625. private _renderPoints;
  97626. private _renderLine;
  97627. private _renderFunction;
  97628. private _scene;
  97629. private _updateToMeshFunction;
  97630. private _attachedToMesh;
  97631. private _meshSpaceDirection;
  97632. private _meshSpaceOrigin;
  97633. /**
  97634. * Helper function to create a colored helper in a scene in one line.
  97635. * @param ray Defines the ray we are currently tryin to visualize
  97636. * @param scene Defines the scene the ray is used in
  97637. * @param color Defines the color we want to see the ray in
  97638. * @returns The newly created ray helper.
  97639. */
  97640. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  97641. /**
  97642. * Instantiate a new ray helper.
  97643. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97644. * in order to better appreciate the issue one might have.
  97645. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97646. * @param ray Defines the ray we are currently tryin to visualize
  97647. */
  97648. constructor(ray: Ray);
  97649. /**
  97650. * Shows the ray we are willing to debug.
  97651. * @param scene Defines the scene the ray needs to be rendered in
  97652. * @param color Defines the color the ray needs to be rendered in
  97653. */
  97654. show(scene: Scene, color?: Color3): void;
  97655. /**
  97656. * Hides the ray we are debugging.
  97657. */
  97658. hide(): void;
  97659. private _render;
  97660. /**
  97661. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  97662. * @param mesh Defines the mesh we want the helper attached to
  97663. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  97664. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  97665. * @param length Defines the length of the ray
  97666. */
  97667. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  97668. /**
  97669. * Detach the ray helper from the mesh it has previously been attached to.
  97670. */
  97671. detachFromMesh(): void;
  97672. private _updateToMesh;
  97673. /**
  97674. * Dispose the helper and release its associated resources.
  97675. */
  97676. dispose(): void;
  97677. }
  97678. }
  97679. declare module BABYLON.Debug {
  97680. /**
  97681. * Class used to render a debug view of a given skeleton
  97682. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  97683. */
  97684. export class SkeletonViewer {
  97685. /** defines the skeleton to render */
  97686. skeleton: Skeleton;
  97687. /** defines the mesh attached to the skeleton */
  97688. mesh: AbstractMesh;
  97689. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97690. autoUpdateBonesMatrices: boolean;
  97691. /** defines the rendering group id to use with the viewer */
  97692. renderingGroupId: number;
  97693. /** Gets or sets the color used to render the skeleton */
  97694. color: Color3;
  97695. private _scene;
  97696. private _debugLines;
  97697. private _debugMesh;
  97698. private _isEnabled;
  97699. private _renderFunction;
  97700. private _utilityLayer;
  97701. /**
  97702. * Returns the mesh used to render the bones
  97703. */
  97704. readonly debugMesh: Nullable<LinesMesh>;
  97705. /**
  97706. * Creates a new SkeletonViewer
  97707. * @param skeleton defines the skeleton to render
  97708. * @param mesh defines the mesh attached to the skeleton
  97709. * @param scene defines the hosting scene
  97710. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  97711. * @param renderingGroupId defines the rendering group id to use with the viewer
  97712. */
  97713. constructor(
  97714. /** defines the skeleton to render */
  97715. skeleton: Skeleton,
  97716. /** defines the mesh attached to the skeleton */
  97717. mesh: AbstractMesh, scene: Scene,
  97718. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97719. autoUpdateBonesMatrices?: boolean,
  97720. /** defines the rendering group id to use with the viewer */
  97721. renderingGroupId?: number);
  97722. /** Gets or sets a boolean indicating if the viewer is enabled */
  97723. isEnabled: boolean;
  97724. private _getBonePosition;
  97725. private _getLinesForBonesWithLength;
  97726. private _getLinesForBonesNoLength;
  97727. /** Update the viewer to sync with current skeleton state */
  97728. update(): void;
  97729. /** Release associated resources */
  97730. dispose(): void;
  97731. }
  97732. }
  97733. declare module BABYLON {
  97734. /**
  97735. * Options to create the null engine
  97736. */
  97737. export class NullEngineOptions {
  97738. /**
  97739. * Render width (Default: 512)
  97740. */
  97741. renderWidth: number;
  97742. /**
  97743. * Render height (Default: 256)
  97744. */
  97745. renderHeight: number;
  97746. /**
  97747. * Texture size (Default: 512)
  97748. */
  97749. textureSize: number;
  97750. /**
  97751. * If delta time between frames should be constant
  97752. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97753. */
  97754. deterministicLockstep: boolean;
  97755. /**
  97756. * Maximum about of steps between frames (Default: 4)
  97757. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97758. */
  97759. lockstepMaxSteps: number;
  97760. }
  97761. /**
  97762. * The null engine class provides support for headless version of babylon.js.
  97763. * This can be used in server side scenario or for testing purposes
  97764. */
  97765. export class NullEngine extends Engine {
  97766. private _options;
  97767. /**
  97768. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97769. */
  97770. isDeterministicLockStep(): boolean;
  97771. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  97772. getLockstepMaxSteps(): number;
  97773. /**
  97774. * Sets hardware scaling, used to save performance if needed
  97775. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97776. */
  97777. getHardwareScalingLevel(): number;
  97778. constructor(options?: NullEngineOptions);
  97779. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97780. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  97781. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97782. getRenderWidth(useScreen?: boolean): number;
  97783. getRenderHeight(useScreen?: boolean): number;
  97784. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  97785. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  97786. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  97787. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  97788. bindSamplers(effect: Effect): void;
  97789. enableEffect(effect: Effect): void;
  97790. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97791. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  97792. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  97793. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  97794. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  97795. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  97796. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  97797. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  97798. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  97799. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  97800. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  97801. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  97802. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  97803. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  97804. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  97805. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97806. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97807. setFloat(uniform: WebGLUniformLocation, value: number): void;
  97808. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  97809. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  97810. setBool(uniform: WebGLUniformLocation, bool: number): void;
  97811. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  97812. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  97813. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  97814. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97815. bindBuffers(vertexBuffers: {
  97816. [key: string]: VertexBuffer;
  97817. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  97818. wipeCaches(bruteForce?: boolean): void;
  97819. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97820. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97821. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97822. /** @hidden */
  97823. _createTexture(): WebGLTexture;
  97824. /** @hidden */
  97825. _releaseTexture(texture: InternalTexture): void;
  97826. 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;
  97827. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97828. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97829. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  97830. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97831. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97832. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  97833. areAllEffectsReady(): boolean;
  97834. /**
  97835. * @hidden
  97836. * Get the current error code of the webGL context
  97837. * @returns the error code
  97838. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97839. */
  97840. getError(): number;
  97841. /** @hidden */
  97842. _getUnpackAlignement(): number;
  97843. /** @hidden */
  97844. _unpackFlipY(value: boolean): void;
  97845. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  97846. /**
  97847. * Updates a dynamic vertex buffer.
  97848. * @param vertexBuffer the vertex buffer to update
  97849. * @param data the data used to update the vertex buffer
  97850. * @param byteOffset the byte offset of the data (optional)
  97851. * @param byteLength the byte length of the data (optional)
  97852. */
  97853. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  97854. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  97855. /** @hidden */
  97856. _bindTexture(channel: number, texture: InternalTexture): void;
  97857. /** @hidden */
  97858. _releaseBuffer(buffer: WebGLBuffer): boolean;
  97859. releaseEffects(): void;
  97860. displayLoadingUI(): void;
  97861. hideLoadingUI(): void;
  97862. /** @hidden */
  97863. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97864. /** @hidden */
  97865. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97866. /** @hidden */
  97867. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97868. /** @hidden */
  97869. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97870. }
  97871. }
  97872. declare module BABYLON {
  97873. /** @hidden */
  97874. export class _OcclusionDataStorage {
  97875. /** @hidden */
  97876. occlusionInternalRetryCounter: number;
  97877. /** @hidden */
  97878. isOcclusionQueryInProgress: boolean;
  97879. /** @hidden */
  97880. isOccluded: boolean;
  97881. /** @hidden */
  97882. occlusionRetryCount: number;
  97883. /** @hidden */
  97884. occlusionType: number;
  97885. /** @hidden */
  97886. occlusionQueryAlgorithmType: number;
  97887. }
  97888. interface Engine {
  97889. /**
  97890. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  97891. * @return the new query
  97892. */
  97893. createQuery(): WebGLQuery;
  97894. /**
  97895. * Delete and release a webGL query
  97896. * @param query defines the query to delete
  97897. * @return the current engine
  97898. */
  97899. deleteQuery(query: WebGLQuery): Engine;
  97900. /**
  97901. * Check if a given query has resolved and got its value
  97902. * @param query defines the query to check
  97903. * @returns true if the query got its value
  97904. */
  97905. isQueryResultAvailable(query: WebGLQuery): boolean;
  97906. /**
  97907. * Gets the value of a given query
  97908. * @param query defines the query to check
  97909. * @returns the value of the query
  97910. */
  97911. getQueryResult(query: WebGLQuery): number;
  97912. /**
  97913. * Initiates an occlusion query
  97914. * @param algorithmType defines the algorithm to use
  97915. * @param query defines the query to use
  97916. * @returns the current engine
  97917. * @see http://doc.babylonjs.com/features/occlusionquery
  97918. */
  97919. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  97920. /**
  97921. * Ends an occlusion query
  97922. * @see http://doc.babylonjs.com/features/occlusionquery
  97923. * @param algorithmType defines the algorithm to use
  97924. * @returns the current engine
  97925. */
  97926. endOcclusionQuery(algorithmType: number): Engine;
  97927. /**
  97928. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  97929. * Please note that only one query can be issued at a time
  97930. * @returns a time token used to track the time span
  97931. */
  97932. startTimeQuery(): Nullable<_TimeToken>;
  97933. /**
  97934. * Ends a time query
  97935. * @param token defines the token used to measure the time span
  97936. * @returns the time spent (in ns)
  97937. */
  97938. endTimeQuery(token: _TimeToken): int;
  97939. /** @hidden */
  97940. _currentNonTimestampToken: Nullable<_TimeToken>;
  97941. /** @hidden */
  97942. _createTimeQuery(): WebGLQuery;
  97943. /** @hidden */
  97944. _deleteTimeQuery(query: WebGLQuery): void;
  97945. /** @hidden */
  97946. _getGlAlgorithmType(algorithmType: number): number;
  97947. /** @hidden */
  97948. _getTimeQueryResult(query: WebGLQuery): any;
  97949. /** @hidden */
  97950. _getTimeQueryAvailability(query: WebGLQuery): any;
  97951. }
  97952. interface AbstractMesh {
  97953. /**
  97954. * Backing filed
  97955. * @hidden
  97956. */
  97957. __occlusionDataStorage: _OcclusionDataStorage;
  97958. /**
  97959. * Access property
  97960. * @hidden
  97961. */
  97962. _occlusionDataStorage: _OcclusionDataStorage;
  97963. /**
  97964. * 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.
  97965. * The default value is -1 which means don't break the query and wait till the result
  97966. * @see http://doc.babylonjs.com/features/occlusionquery
  97967. */
  97968. occlusionRetryCount: number;
  97969. /**
  97970. * 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:
  97971. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  97972. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  97973. * * 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.
  97974. * @see http://doc.babylonjs.com/features/occlusionquery
  97975. */
  97976. occlusionType: number;
  97977. /**
  97978. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  97979. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  97980. * * 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.
  97981. * @see http://doc.babylonjs.com/features/occlusionquery
  97982. */
  97983. occlusionQueryAlgorithmType: number;
  97984. /**
  97985. * 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
  97986. * @see http://doc.babylonjs.com/features/occlusionquery
  97987. */
  97988. isOccluded: boolean;
  97989. /**
  97990. * Flag to check the progress status of the query
  97991. * @see http://doc.babylonjs.com/features/occlusionquery
  97992. */
  97993. isOcclusionQueryInProgress: boolean;
  97994. }
  97995. }
  97996. declare module BABYLON {
  97997. /** @hidden */
  97998. export var _forceTransformFeedbackToBundle: boolean;
  97999. interface Engine {
  98000. /**
  98001. * Creates a webGL transform feedback object
  98002. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98003. * @returns the webGL transform feedback object
  98004. */
  98005. createTransformFeedback(): WebGLTransformFeedback;
  98006. /**
  98007. * Delete a webGL transform feedback object
  98008. * @param value defines the webGL transform feedback object to delete
  98009. */
  98010. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98011. /**
  98012. * Bind a webGL transform feedback object to the webgl context
  98013. * @param value defines the webGL transform feedback object to bind
  98014. */
  98015. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98016. /**
  98017. * Begins a transform feedback operation
  98018. * @param usePoints defines if points or triangles must be used
  98019. */
  98020. beginTransformFeedback(usePoints: boolean): void;
  98021. /**
  98022. * Ends a transform feedback operation
  98023. */
  98024. endTransformFeedback(): void;
  98025. /**
  98026. * Specify the varyings to use with transform feedback
  98027. * @param program defines the associated webGL program
  98028. * @param value defines the list of strings representing the varying names
  98029. */
  98030. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98031. /**
  98032. * Bind a webGL buffer for a transform feedback operation
  98033. * @param value defines the webGL buffer to bind
  98034. */
  98035. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98036. }
  98037. }
  98038. declare module BABYLON {
  98039. /**
  98040. * Gather the list of clipboard event types as constants.
  98041. */
  98042. export class ClipboardEventTypes {
  98043. /**
  98044. * The clipboard event is fired when a copy command is active (pressed).
  98045. */
  98046. static readonly COPY: number;
  98047. /**
  98048. * The clipboard event is fired when a cut command is active (pressed).
  98049. */
  98050. static readonly CUT: number;
  98051. /**
  98052. * The clipboard event is fired when a paste command is active (pressed).
  98053. */
  98054. static readonly PASTE: number;
  98055. }
  98056. /**
  98057. * This class is used to store clipboard related info for the onClipboardObservable event.
  98058. */
  98059. export class ClipboardInfo {
  98060. /**
  98061. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98062. */
  98063. type: number;
  98064. /**
  98065. * Defines the related dom event
  98066. */
  98067. event: ClipboardEvent;
  98068. /**
  98069. *Creates an instance of ClipboardInfo.
  98070. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98071. * @param event Defines the related dom event
  98072. */
  98073. constructor(
  98074. /**
  98075. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98076. */
  98077. type: number,
  98078. /**
  98079. * Defines the related dom event
  98080. */
  98081. event: ClipboardEvent);
  98082. /**
  98083. * Get the clipboard event's type from the keycode.
  98084. * @param keyCode Defines the keyCode for the current keyboard event.
  98085. * @return {number}
  98086. */
  98087. static GetTypeFromCharacter(keyCode: number): number;
  98088. }
  98089. }
  98090. declare module BABYLON {
  98091. /**
  98092. * Class used to represent data loading progression
  98093. */
  98094. export class SceneLoaderProgressEvent {
  98095. /** defines if data length to load can be evaluated */
  98096. readonly lengthComputable: boolean;
  98097. /** defines the loaded data length */
  98098. readonly loaded: number;
  98099. /** defines the data length to load */
  98100. readonly total: number;
  98101. /**
  98102. * Create a new progress event
  98103. * @param lengthComputable defines if data length to load can be evaluated
  98104. * @param loaded defines the loaded data length
  98105. * @param total defines the data length to load
  98106. */
  98107. constructor(
  98108. /** defines if data length to load can be evaluated */
  98109. lengthComputable: boolean,
  98110. /** defines the loaded data length */
  98111. loaded: number,
  98112. /** defines the data length to load */
  98113. total: number);
  98114. /**
  98115. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98116. * @param event defines the source event
  98117. * @returns a new SceneLoaderProgressEvent
  98118. */
  98119. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98120. }
  98121. /**
  98122. * Interface used by SceneLoader plugins to define supported file extensions
  98123. */
  98124. export interface ISceneLoaderPluginExtensions {
  98125. /**
  98126. * Defines the list of supported extensions
  98127. */
  98128. [extension: string]: {
  98129. isBinary: boolean;
  98130. };
  98131. }
  98132. /**
  98133. * Interface used by SceneLoader plugin factory
  98134. */
  98135. export interface ISceneLoaderPluginFactory {
  98136. /**
  98137. * Defines the name of the factory
  98138. */
  98139. name: string;
  98140. /**
  98141. * Function called to create a new plugin
  98142. * @return the new plugin
  98143. */
  98144. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98145. /**
  98146. * Boolean indicating if the plugin can direct load specific data
  98147. */
  98148. canDirectLoad?: (data: string) => boolean;
  98149. }
  98150. /**
  98151. * Interface used to define a SceneLoader plugin
  98152. */
  98153. export interface ISceneLoaderPlugin {
  98154. /**
  98155. * The friendly name of this plugin.
  98156. */
  98157. name: string;
  98158. /**
  98159. * The file extensions supported by this plugin.
  98160. */
  98161. extensions: string | ISceneLoaderPluginExtensions;
  98162. /**
  98163. * Import meshes into a scene.
  98164. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98165. * @param scene The scene to import into
  98166. * @param data The data to import
  98167. * @param rootUrl The root url for scene and resources
  98168. * @param meshes The meshes array to import into
  98169. * @param particleSystems The particle systems array to import into
  98170. * @param skeletons The skeletons array to import into
  98171. * @param onError The callback when import fails
  98172. * @returns True if successful or false otherwise
  98173. */
  98174. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98175. /**
  98176. * Load into a scene.
  98177. * @param scene The scene to load into
  98178. * @param data The data to import
  98179. * @param rootUrl The root url for scene and resources
  98180. * @param onError The callback when import fails
  98181. * @returns true if successful or false otherwise
  98182. */
  98183. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98184. /**
  98185. * The callback that returns true if the data can be directly loaded.
  98186. */
  98187. canDirectLoad?: (data: string) => boolean;
  98188. /**
  98189. * The callback that allows custom handling of the root url based on the response url.
  98190. */
  98191. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98192. /**
  98193. * Load into an asset container.
  98194. * @param scene The scene to load into
  98195. * @param data The data to import
  98196. * @param rootUrl The root url for scene and resources
  98197. * @param onError The callback when import fails
  98198. * @returns The loaded asset container
  98199. */
  98200. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98201. }
  98202. /**
  98203. * Interface used to define an async SceneLoader plugin
  98204. */
  98205. export interface ISceneLoaderPluginAsync {
  98206. /**
  98207. * The friendly name of this plugin.
  98208. */
  98209. name: string;
  98210. /**
  98211. * The file extensions supported by this plugin.
  98212. */
  98213. extensions: string | ISceneLoaderPluginExtensions;
  98214. /**
  98215. * Import meshes into a scene.
  98216. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98217. * @param scene The scene to import into
  98218. * @param data The data to import
  98219. * @param rootUrl The root url for scene and resources
  98220. * @param onProgress The callback when the load progresses
  98221. * @param fileName Defines the name of the file to load
  98222. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98223. */
  98224. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98225. meshes: AbstractMesh[];
  98226. particleSystems: IParticleSystem[];
  98227. skeletons: Skeleton[];
  98228. animationGroups: AnimationGroup[];
  98229. }>;
  98230. /**
  98231. * Load into a scene.
  98232. * @param scene The scene to load into
  98233. * @param data The data to import
  98234. * @param rootUrl The root url for scene and resources
  98235. * @param onProgress The callback when the load progresses
  98236. * @param fileName Defines the name of the file to load
  98237. * @returns Nothing
  98238. */
  98239. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98240. /**
  98241. * The callback that returns true if the data can be directly loaded.
  98242. */
  98243. canDirectLoad?: (data: string) => boolean;
  98244. /**
  98245. * The callback that allows custom handling of the root url based on the response url.
  98246. */
  98247. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98248. /**
  98249. * Load into an asset container.
  98250. * @param scene The scene to load into
  98251. * @param data The data to import
  98252. * @param rootUrl The root url for scene and resources
  98253. * @param onProgress The callback when the load progresses
  98254. * @param fileName Defines the name of the file to load
  98255. * @returns The loaded asset container
  98256. */
  98257. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98258. }
  98259. /**
  98260. * Class used to load scene from various file formats using registered plugins
  98261. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98262. */
  98263. export class SceneLoader {
  98264. /**
  98265. * No logging while loading
  98266. */
  98267. static readonly NO_LOGGING: number;
  98268. /**
  98269. * Minimal logging while loading
  98270. */
  98271. static readonly MINIMAL_LOGGING: number;
  98272. /**
  98273. * Summary logging while loading
  98274. */
  98275. static readonly SUMMARY_LOGGING: number;
  98276. /**
  98277. * Detailled logging while loading
  98278. */
  98279. static readonly DETAILED_LOGGING: number;
  98280. /**
  98281. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98282. */
  98283. static ForceFullSceneLoadingForIncremental: boolean;
  98284. /**
  98285. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98286. */
  98287. static ShowLoadingScreen: boolean;
  98288. /**
  98289. * Defines the current logging level (while loading the scene)
  98290. * @ignorenaming
  98291. */
  98292. static loggingLevel: number;
  98293. /**
  98294. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98295. */
  98296. static CleanBoneMatrixWeights: boolean;
  98297. /**
  98298. * Event raised when a plugin is used to load a scene
  98299. */
  98300. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98301. private static _registeredPlugins;
  98302. private static _getDefaultPlugin;
  98303. private static _getPluginForExtension;
  98304. private static _getPluginForDirectLoad;
  98305. private static _getPluginForFilename;
  98306. private static _getDirectLoad;
  98307. private static _loadData;
  98308. private static _getFileInfo;
  98309. /**
  98310. * Gets a plugin that can load the given extension
  98311. * @param extension defines the extension to load
  98312. * @returns a plugin or null if none works
  98313. */
  98314. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98315. /**
  98316. * Gets a boolean indicating that the given extension can be loaded
  98317. * @param extension defines the extension to load
  98318. * @returns true if the extension is supported
  98319. */
  98320. static IsPluginForExtensionAvailable(extension: string): boolean;
  98321. /**
  98322. * Adds a new plugin to the list of registered plugins
  98323. * @param plugin defines the plugin to add
  98324. */
  98325. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98326. /**
  98327. * Import meshes into a scene
  98328. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98329. * @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)
  98330. * @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)
  98331. * @param scene the instance of BABYLON.Scene to append to
  98332. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98333. * @param onProgress a callback with a progress event for each file being loaded
  98334. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98335. * @param pluginExtension the extension used to determine the plugin
  98336. * @returns The loaded plugin
  98337. */
  98338. 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>;
  98339. /**
  98340. * Import meshes into a scene
  98341. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98342. * @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)
  98343. * @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)
  98344. * @param scene the instance of BABYLON.Scene to append to
  98345. * @param onProgress a callback with a progress event for each file being loaded
  98346. * @param pluginExtension the extension used to determine the plugin
  98347. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98348. */
  98349. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98350. meshes: AbstractMesh[];
  98351. particleSystems: IParticleSystem[];
  98352. skeletons: Skeleton[];
  98353. animationGroups: AnimationGroup[];
  98354. }>;
  98355. /**
  98356. * Load a scene
  98357. * @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)
  98358. * @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)
  98359. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98360. * @param onSuccess a callback with the scene when import succeeds
  98361. * @param onProgress a callback with a progress event for each file being loaded
  98362. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98363. * @param pluginExtension the extension used to determine the plugin
  98364. * @returns The loaded plugin
  98365. */
  98366. 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>;
  98367. /**
  98368. * Load a scene
  98369. * @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)
  98370. * @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)
  98371. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98372. * @param onProgress a callback with a progress event for each file being loaded
  98373. * @param pluginExtension the extension used to determine the plugin
  98374. * @returns The loaded scene
  98375. */
  98376. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98377. /**
  98378. * Append a scene
  98379. * @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)
  98380. * @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)
  98381. * @param scene is the instance of BABYLON.Scene to append to
  98382. * @param onSuccess a callback with the scene when import succeeds
  98383. * @param onProgress a callback with a progress event for each file being loaded
  98384. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98385. * @param pluginExtension the extension used to determine the plugin
  98386. * @returns The loaded plugin
  98387. */
  98388. 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>;
  98389. /**
  98390. * Append a scene
  98391. * @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)
  98392. * @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)
  98393. * @param scene is the instance of BABYLON.Scene to append to
  98394. * @param onProgress a callback with a progress event for each file being loaded
  98395. * @param pluginExtension the extension used to determine the plugin
  98396. * @returns The given scene
  98397. */
  98398. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98399. /**
  98400. * Load a scene into an asset container
  98401. * @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)
  98402. * @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)
  98403. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98404. * @param onSuccess a callback with the scene when import succeeds
  98405. * @param onProgress a callback with a progress event for each file being loaded
  98406. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98407. * @param pluginExtension the extension used to determine the plugin
  98408. * @returns The loaded plugin
  98409. */
  98410. 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>;
  98411. /**
  98412. * Load a scene into an asset container
  98413. * @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)
  98414. * @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)
  98415. * @param scene is the instance of Scene to append to
  98416. * @param onProgress a callback with a progress event for each file being loaded
  98417. * @param pluginExtension the extension used to determine the plugin
  98418. * @returns The loaded asset container
  98419. */
  98420. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98421. }
  98422. }
  98423. declare module BABYLON {
  98424. /**
  98425. * Google Daydream controller
  98426. */
  98427. export class DaydreamController extends WebVRController {
  98428. /**
  98429. * Base Url for the controller model.
  98430. */
  98431. static MODEL_BASE_URL: string;
  98432. /**
  98433. * File name for the controller model.
  98434. */
  98435. static MODEL_FILENAME: string;
  98436. /**
  98437. * Gamepad Id prefix used to identify Daydream Controller.
  98438. */
  98439. static readonly GAMEPAD_ID_PREFIX: string;
  98440. /**
  98441. * Creates a new DaydreamController from a gamepad
  98442. * @param vrGamepad the gamepad that the controller should be created from
  98443. */
  98444. constructor(vrGamepad: any);
  98445. /**
  98446. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98447. * @param scene scene in which to add meshes
  98448. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98449. */
  98450. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98451. /**
  98452. * Called once for each button that changed state since the last frame
  98453. * @param buttonIdx Which button index changed
  98454. * @param state New state of the button
  98455. * @param changes Which properties on the state changed since last frame
  98456. */
  98457. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98458. }
  98459. }
  98460. declare module BABYLON {
  98461. /**
  98462. * Gear VR Controller
  98463. */
  98464. export class GearVRController extends WebVRController {
  98465. /**
  98466. * Base Url for the controller model.
  98467. */
  98468. static MODEL_BASE_URL: string;
  98469. /**
  98470. * File name for the controller model.
  98471. */
  98472. static MODEL_FILENAME: string;
  98473. /**
  98474. * Gamepad Id prefix used to identify this controller.
  98475. */
  98476. static readonly GAMEPAD_ID_PREFIX: string;
  98477. private readonly _buttonIndexToObservableNameMap;
  98478. /**
  98479. * Creates a new GearVRController from a gamepad
  98480. * @param vrGamepad the gamepad that the controller should be created from
  98481. */
  98482. constructor(vrGamepad: any);
  98483. /**
  98484. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98485. * @param scene scene in which to add meshes
  98486. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98487. */
  98488. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98489. /**
  98490. * Called once for each button that changed state since the last frame
  98491. * @param buttonIdx Which button index changed
  98492. * @param state New state of the button
  98493. * @param changes Which properties on the state changed since last frame
  98494. */
  98495. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98496. }
  98497. }
  98498. declare module BABYLON {
  98499. /**
  98500. * Generic Controller
  98501. */
  98502. export class GenericController extends WebVRController {
  98503. /**
  98504. * Base Url for the controller model.
  98505. */
  98506. static readonly MODEL_BASE_URL: string;
  98507. /**
  98508. * File name for the controller model.
  98509. */
  98510. static readonly MODEL_FILENAME: string;
  98511. /**
  98512. * Creates a new GenericController from a gamepad
  98513. * @param vrGamepad the gamepad that the controller should be created from
  98514. */
  98515. constructor(vrGamepad: any);
  98516. /**
  98517. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98518. * @param scene scene in which to add meshes
  98519. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98520. */
  98521. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98522. /**
  98523. * Called once for each button that changed state since the last frame
  98524. * @param buttonIdx Which button index changed
  98525. * @param state New state of the button
  98526. * @param changes Which properties on the state changed since last frame
  98527. */
  98528. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98529. }
  98530. }
  98531. declare module BABYLON {
  98532. /**
  98533. * Oculus Touch Controller
  98534. */
  98535. export class OculusTouchController extends WebVRController {
  98536. /**
  98537. * Base Url for the controller model.
  98538. */
  98539. static MODEL_BASE_URL: string;
  98540. /**
  98541. * File name for the left controller model.
  98542. */
  98543. static MODEL_LEFT_FILENAME: string;
  98544. /**
  98545. * File name for the right controller model.
  98546. */
  98547. static MODEL_RIGHT_FILENAME: string;
  98548. /**
  98549. * Fired when the secondary trigger on this controller is modified
  98550. */
  98551. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98552. /**
  98553. * Fired when the thumb rest on this controller is modified
  98554. */
  98555. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  98556. /**
  98557. * Creates a new OculusTouchController from a gamepad
  98558. * @param vrGamepad the gamepad that the controller should be created from
  98559. */
  98560. constructor(vrGamepad: any);
  98561. /**
  98562. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98563. * @param scene scene in which to add meshes
  98564. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98565. */
  98566. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98567. /**
  98568. * Fired when the A button on this controller is modified
  98569. */
  98570. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98571. /**
  98572. * Fired when the B button on this controller is modified
  98573. */
  98574. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98575. /**
  98576. * Fired when the X button on this controller is modified
  98577. */
  98578. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98579. /**
  98580. * Fired when the Y button on this controller is modified
  98581. */
  98582. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98583. /**
  98584. * Called once for each button that changed state since the last frame
  98585. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  98586. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  98587. * 2) secondary trigger (same)
  98588. * 3) A (right) X (left), touch, pressed = value
  98589. * 4) B / Y
  98590. * 5) thumb rest
  98591. * @param buttonIdx Which button index changed
  98592. * @param state New state of the button
  98593. * @param changes Which properties on the state changed since last frame
  98594. */
  98595. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98596. }
  98597. }
  98598. declare module BABYLON {
  98599. /**
  98600. * Vive Controller
  98601. */
  98602. export class ViveController extends WebVRController {
  98603. /**
  98604. * Base Url for the controller model.
  98605. */
  98606. static MODEL_BASE_URL: string;
  98607. /**
  98608. * File name for the controller model.
  98609. */
  98610. static MODEL_FILENAME: string;
  98611. /**
  98612. * Creates a new ViveController from a gamepad
  98613. * @param vrGamepad the gamepad that the controller should be created from
  98614. */
  98615. constructor(vrGamepad: any);
  98616. /**
  98617. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98618. * @param scene scene in which to add meshes
  98619. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98620. */
  98621. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98622. /**
  98623. * Fired when the left button on this controller is modified
  98624. */
  98625. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98626. /**
  98627. * Fired when the right button on this controller is modified
  98628. */
  98629. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98630. /**
  98631. * Fired when the menu button on this controller is modified
  98632. */
  98633. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98634. /**
  98635. * Called once for each button that changed state since the last frame
  98636. * Vive mapping:
  98637. * 0: touchpad
  98638. * 1: trigger
  98639. * 2: left AND right buttons
  98640. * 3: menu button
  98641. * @param buttonIdx Which button index changed
  98642. * @param state New state of the button
  98643. * @param changes Which properties on the state changed since last frame
  98644. */
  98645. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98646. }
  98647. }
  98648. declare module BABYLON {
  98649. /**
  98650. * Defines the WindowsMotionController object that the state of the windows motion controller
  98651. */
  98652. export class WindowsMotionController extends WebVRController {
  98653. /**
  98654. * The base url used to load the left and right controller models
  98655. */
  98656. static MODEL_BASE_URL: string;
  98657. /**
  98658. * The name of the left controller model file
  98659. */
  98660. static MODEL_LEFT_FILENAME: string;
  98661. /**
  98662. * The name of the right controller model file
  98663. */
  98664. static MODEL_RIGHT_FILENAME: string;
  98665. /**
  98666. * The controller name prefix for this controller type
  98667. */
  98668. static readonly GAMEPAD_ID_PREFIX: string;
  98669. /**
  98670. * The controller id pattern for this controller type
  98671. */
  98672. private static readonly GAMEPAD_ID_PATTERN;
  98673. private _loadedMeshInfo;
  98674. private readonly _mapping;
  98675. /**
  98676. * Fired when the trackpad on this controller is clicked
  98677. */
  98678. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  98679. /**
  98680. * Fired when the trackpad on this controller is modified
  98681. */
  98682. onTrackpadValuesChangedObservable: Observable<StickValues>;
  98683. /**
  98684. * The current x and y values of this controller's trackpad
  98685. */
  98686. trackpad: StickValues;
  98687. /**
  98688. * Creates a new WindowsMotionController from a gamepad
  98689. * @param vrGamepad the gamepad that the controller should be created from
  98690. */
  98691. constructor(vrGamepad: any);
  98692. /**
  98693. * Fired when the trigger on this controller is modified
  98694. */
  98695. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98696. /**
  98697. * Fired when the menu button on this controller is modified
  98698. */
  98699. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98700. /**
  98701. * Fired when the grip button on this controller is modified
  98702. */
  98703. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98704. /**
  98705. * Fired when the thumbstick button on this controller is modified
  98706. */
  98707. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98708. /**
  98709. * Fired when the touchpad button on this controller is modified
  98710. */
  98711. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98712. /**
  98713. * Fired when the touchpad values on this controller are modified
  98714. */
  98715. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  98716. private _updateTrackpad;
  98717. /**
  98718. * Called once per frame by the engine.
  98719. */
  98720. update(): void;
  98721. /**
  98722. * Called once for each button that changed state since the last frame
  98723. * @param buttonIdx Which button index changed
  98724. * @param state New state of the button
  98725. * @param changes Which properties on the state changed since last frame
  98726. */
  98727. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98728. /**
  98729. * Moves the buttons on the controller mesh based on their current state
  98730. * @param buttonName the name of the button to move
  98731. * @param buttonValue the value of the button which determines the buttons new position
  98732. */
  98733. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  98734. /**
  98735. * Moves the axis on the controller mesh based on its current state
  98736. * @param axis the index of the axis
  98737. * @param axisValue the value of the axis which determines the meshes new position
  98738. * @hidden
  98739. */
  98740. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  98741. /**
  98742. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98743. * @param scene scene in which to add meshes
  98744. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98745. */
  98746. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  98747. /**
  98748. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  98749. * can be transformed by button presses and axes values, based on this._mapping.
  98750. *
  98751. * @param scene scene in which the meshes exist
  98752. * @param meshes list of meshes that make up the controller model to process
  98753. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  98754. */
  98755. private processModel;
  98756. private createMeshInfo;
  98757. /**
  98758. * Gets the ray of the controller in the direction the controller is pointing
  98759. * @param length the length the resulting ray should be
  98760. * @returns a ray in the direction the controller is pointing
  98761. */
  98762. getForwardRay(length?: number): Ray;
  98763. /**
  98764. * Disposes of the controller
  98765. */
  98766. dispose(): void;
  98767. }
  98768. }
  98769. declare module BABYLON {
  98770. /**
  98771. * Single axis scale gizmo
  98772. */
  98773. export class AxisScaleGizmo extends Gizmo {
  98774. private _coloredMaterial;
  98775. /**
  98776. * Drag behavior responsible for the gizmos dragging interactions
  98777. */
  98778. dragBehavior: PointerDragBehavior;
  98779. private _pointerObserver;
  98780. /**
  98781. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98782. */
  98783. snapDistance: number;
  98784. /**
  98785. * Event that fires each time the gizmo snaps to a new location.
  98786. * * snapDistance is the the change in distance
  98787. */
  98788. onSnapObservable: Observable<{
  98789. snapDistance: number;
  98790. }>;
  98791. /**
  98792. * If the scaling operation should be done on all axis (default: false)
  98793. */
  98794. uniformScaling: boolean;
  98795. /**
  98796. * Creates an AxisScaleGizmo
  98797. * @param gizmoLayer The utility layer the gizmo will be added to
  98798. * @param dragAxis The axis which the gizmo will be able to scale on
  98799. * @param color The color of the gizmo
  98800. */
  98801. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98802. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98803. /**
  98804. * Disposes of the gizmo
  98805. */
  98806. dispose(): void;
  98807. /**
  98808. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98809. * @param mesh The mesh to replace the default mesh of the gizmo
  98810. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  98811. */
  98812. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  98813. }
  98814. }
  98815. declare module BABYLON {
  98816. /**
  98817. * Bounding box gizmo
  98818. */
  98819. export class BoundingBoxGizmo extends Gizmo {
  98820. private _lineBoundingBox;
  98821. private _rotateSpheresParent;
  98822. private _scaleBoxesParent;
  98823. private _boundingDimensions;
  98824. private _renderObserver;
  98825. private _pointerObserver;
  98826. private _scaleDragSpeed;
  98827. private _tmpQuaternion;
  98828. private _tmpVector;
  98829. private _tmpRotationMatrix;
  98830. /**
  98831. * 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)
  98832. */
  98833. ignoreChildren: boolean;
  98834. /**
  98835. * 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)
  98836. */
  98837. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  98838. /**
  98839. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  98840. */
  98841. rotationSphereSize: number;
  98842. /**
  98843. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  98844. */
  98845. scaleBoxSize: number;
  98846. /**
  98847. * 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)
  98848. */
  98849. fixedDragMeshScreenSize: boolean;
  98850. /**
  98851. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  98852. */
  98853. fixedDragMeshScreenSizeDistanceFactor: number;
  98854. /**
  98855. * Fired when a rotation sphere or scale box is dragged
  98856. */
  98857. onDragStartObservable: Observable<{}>;
  98858. /**
  98859. * Fired when a scale box is dragged
  98860. */
  98861. onScaleBoxDragObservable: Observable<{}>;
  98862. /**
  98863. * Fired when a scale box drag is ended
  98864. */
  98865. onScaleBoxDragEndObservable: Observable<{}>;
  98866. /**
  98867. * Fired when a rotation sphere is dragged
  98868. */
  98869. onRotationSphereDragObservable: Observable<{}>;
  98870. /**
  98871. * Fired when a rotation sphere drag is ended
  98872. */
  98873. onRotationSphereDragEndObservable: Observable<{}>;
  98874. /**
  98875. * 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)
  98876. */
  98877. scalePivot: Nullable<Vector3>;
  98878. private _anchorMesh;
  98879. private _existingMeshScale;
  98880. private _dragMesh;
  98881. private pointerDragBehavior;
  98882. private coloredMaterial;
  98883. private hoverColoredMaterial;
  98884. /**
  98885. * Sets the color of the bounding box gizmo
  98886. * @param color the color to set
  98887. */
  98888. setColor(color: Color3): void;
  98889. /**
  98890. * Creates an BoundingBoxGizmo
  98891. * @param gizmoLayer The utility layer the gizmo will be added to
  98892. * @param color The color of the gizmo
  98893. */
  98894. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98895. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98896. private _selectNode;
  98897. /**
  98898. * Updates the bounding box information for the Gizmo
  98899. */
  98900. updateBoundingBox(): void;
  98901. private _updateRotationSpheres;
  98902. private _updateScaleBoxes;
  98903. /**
  98904. * Enables rotation on the specified axis and disables rotation on the others
  98905. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  98906. */
  98907. setEnabledRotationAxis(axis: string): void;
  98908. /**
  98909. * Enables/disables scaling
  98910. * @param enable if scaling should be enabled
  98911. */
  98912. setEnabledScaling(enable: boolean): void;
  98913. private _updateDummy;
  98914. /**
  98915. * Enables a pointer drag behavior on the bounding box of the gizmo
  98916. */
  98917. enableDragBehavior(): void;
  98918. /**
  98919. * Disposes of the gizmo
  98920. */
  98921. dispose(): void;
  98922. /**
  98923. * 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)
  98924. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  98925. * @returns the bounding box mesh with the passed in mesh as a child
  98926. */
  98927. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  98928. /**
  98929. * CustomMeshes are not supported by this gizmo
  98930. * @param mesh The mesh to replace the default mesh of the gizmo
  98931. */
  98932. setCustomMesh(mesh: Mesh): void;
  98933. }
  98934. }
  98935. declare module BABYLON {
  98936. /**
  98937. * Single plane rotation gizmo
  98938. */
  98939. export class PlaneRotationGizmo extends Gizmo {
  98940. /**
  98941. * Drag behavior responsible for the gizmos dragging interactions
  98942. */
  98943. dragBehavior: PointerDragBehavior;
  98944. private _pointerObserver;
  98945. /**
  98946. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  98947. */
  98948. snapDistance: number;
  98949. /**
  98950. * Event that fires each time the gizmo snaps to a new location.
  98951. * * snapDistance is the the change in distance
  98952. */
  98953. onSnapObservable: Observable<{
  98954. snapDistance: number;
  98955. }>;
  98956. /**
  98957. * Creates a PlaneRotationGizmo
  98958. * @param gizmoLayer The utility layer the gizmo will be added to
  98959. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  98960. * @param color The color of the gizmo
  98961. * @param tessellation Amount of tessellation to be used when creating rotation circles
  98962. */
  98963. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  98964. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98965. /**
  98966. * Disposes of the gizmo
  98967. */
  98968. dispose(): void;
  98969. }
  98970. }
  98971. declare module BABYLON {
  98972. /**
  98973. * Gizmo that enables rotating a mesh along 3 axis
  98974. */
  98975. export class RotationGizmo extends Gizmo {
  98976. /**
  98977. * Internal gizmo used for interactions on the x axis
  98978. */
  98979. xGizmo: PlaneRotationGizmo;
  98980. /**
  98981. * Internal gizmo used for interactions on the y axis
  98982. */
  98983. yGizmo: PlaneRotationGizmo;
  98984. /**
  98985. * Internal gizmo used for interactions on the z axis
  98986. */
  98987. zGizmo: PlaneRotationGizmo;
  98988. /** Fires an event when any of it's sub gizmos are dragged */
  98989. onDragStartObservable: Observable<{}>;
  98990. /** Fires an event when any of it's sub gizmos are released from dragging */
  98991. onDragEndObservable: Observable<{}>;
  98992. attachedMesh: Nullable<AbstractMesh>;
  98993. /**
  98994. * Creates a RotationGizmo
  98995. * @param gizmoLayer The utility layer the gizmo will be added to
  98996. * @param tessellation Amount of tessellation to be used when creating rotation circles
  98997. */
  98998. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  98999. updateGizmoRotationToMatchAttachedMesh: boolean;
  99000. /**
  99001. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99002. */
  99003. snapDistance: number;
  99004. /**
  99005. * Ratio for the scale of the gizmo (Default: 1)
  99006. */
  99007. scaleRatio: number;
  99008. /**
  99009. * Disposes of the gizmo
  99010. */
  99011. dispose(): void;
  99012. /**
  99013. * CustomMeshes are not supported by this gizmo
  99014. * @param mesh The mesh to replace the default mesh of the gizmo
  99015. */
  99016. setCustomMesh(mesh: Mesh): void;
  99017. }
  99018. }
  99019. declare module BABYLON {
  99020. /**
  99021. * Gizmo that enables dragging a mesh along 3 axis
  99022. */
  99023. export class PositionGizmo extends Gizmo {
  99024. /**
  99025. * Internal gizmo used for interactions on the x axis
  99026. */
  99027. xGizmo: AxisDragGizmo;
  99028. /**
  99029. * Internal gizmo used for interactions on the y axis
  99030. */
  99031. yGizmo: AxisDragGizmo;
  99032. /**
  99033. * Internal gizmo used for interactions on the z axis
  99034. */
  99035. zGizmo: AxisDragGizmo;
  99036. /** Fires an event when any of it's sub gizmos are dragged */
  99037. onDragStartObservable: Observable<{}>;
  99038. /** Fires an event when any of it's sub gizmos are released from dragging */
  99039. onDragEndObservable: Observable<{}>;
  99040. attachedMesh: Nullable<AbstractMesh>;
  99041. /**
  99042. * Creates a PositionGizmo
  99043. * @param gizmoLayer The utility layer the gizmo will be added to
  99044. */
  99045. constructor(gizmoLayer?: UtilityLayerRenderer);
  99046. updateGizmoRotationToMatchAttachedMesh: boolean;
  99047. /**
  99048. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99049. */
  99050. snapDistance: number;
  99051. /**
  99052. * Ratio for the scale of the gizmo (Default: 1)
  99053. */
  99054. scaleRatio: number;
  99055. /**
  99056. * Disposes of the gizmo
  99057. */
  99058. dispose(): void;
  99059. /**
  99060. * CustomMeshes are not supported by this gizmo
  99061. * @param mesh The mesh to replace the default mesh of the gizmo
  99062. */
  99063. setCustomMesh(mesh: Mesh): void;
  99064. }
  99065. }
  99066. declare module BABYLON {
  99067. /**
  99068. * Class containing static functions to help procedurally build meshes
  99069. */
  99070. export class PolyhedronBuilder {
  99071. /**
  99072. * Creates a polyhedron mesh
  99073. * * 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
  99074. * * The parameter `size` (positive float, default 1) sets the polygon size
  99075. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99076. * * 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`
  99077. * * 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
  99078. * * 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)`)
  99079. * * 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
  99080. * * 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
  99081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99082. * * If you create a double-sided mesh, you can choose what parts of 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
  99083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99084. * @param name defines the name of the mesh
  99085. * @param options defines the options used to create the mesh
  99086. * @param scene defines the hosting scene
  99087. * @returns the polyhedron mesh
  99088. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99089. */
  99090. static CreatePolyhedron(name: string, options: {
  99091. type?: number;
  99092. size?: number;
  99093. sizeX?: number;
  99094. sizeY?: number;
  99095. sizeZ?: number;
  99096. custom?: any;
  99097. faceUV?: Vector4[];
  99098. faceColors?: Color4[];
  99099. flat?: boolean;
  99100. updatable?: boolean;
  99101. sideOrientation?: number;
  99102. frontUVs?: Vector4;
  99103. backUVs?: Vector4;
  99104. }, scene: Scene): Mesh;
  99105. }
  99106. }
  99107. declare module BABYLON {
  99108. /**
  99109. * Gizmo that enables scaling a mesh along 3 axis
  99110. */
  99111. export class ScaleGizmo extends Gizmo {
  99112. /**
  99113. * Internal gizmo used for interactions on the x axis
  99114. */
  99115. xGizmo: AxisScaleGizmo;
  99116. /**
  99117. * Internal gizmo used for interactions on the y axis
  99118. */
  99119. yGizmo: AxisScaleGizmo;
  99120. /**
  99121. * Internal gizmo used for interactions on the z axis
  99122. */
  99123. zGizmo: AxisScaleGizmo;
  99124. /**
  99125. * Internal gizmo used to scale all axis equally
  99126. */
  99127. uniformScaleGizmo: AxisScaleGizmo;
  99128. /** Fires an event when any of it's sub gizmos are dragged */
  99129. onDragStartObservable: Observable<{}>;
  99130. /** Fires an event when any of it's sub gizmos are released from dragging */
  99131. onDragEndObservable: Observable<{}>;
  99132. attachedMesh: Nullable<AbstractMesh>;
  99133. /**
  99134. * Creates a ScaleGizmo
  99135. * @param gizmoLayer The utility layer the gizmo will be added to
  99136. */
  99137. constructor(gizmoLayer?: UtilityLayerRenderer);
  99138. updateGizmoRotationToMatchAttachedMesh: boolean;
  99139. /**
  99140. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99141. */
  99142. snapDistance: number;
  99143. /**
  99144. * Ratio for the scale of the gizmo (Default: 1)
  99145. */
  99146. scaleRatio: number;
  99147. /**
  99148. * Disposes of the gizmo
  99149. */
  99150. dispose(): void;
  99151. }
  99152. }
  99153. declare module BABYLON {
  99154. /**
  99155. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99156. */
  99157. export class GizmoManager implements IDisposable {
  99158. private scene;
  99159. /**
  99160. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99161. */
  99162. gizmos: {
  99163. positionGizmo: Nullable<PositionGizmo>;
  99164. rotationGizmo: Nullable<RotationGizmo>;
  99165. scaleGizmo: Nullable<ScaleGizmo>;
  99166. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99167. };
  99168. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99169. clearGizmoOnEmptyPointerEvent: boolean;
  99170. /** Fires an event when the manager is attached to a mesh */
  99171. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99172. private _gizmosEnabled;
  99173. private _pointerObserver;
  99174. private _attachedMesh;
  99175. private _boundingBoxColor;
  99176. private _defaultUtilityLayer;
  99177. private _defaultKeepDepthUtilityLayer;
  99178. /**
  99179. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99180. */
  99181. boundingBoxDragBehavior: SixDofDragBehavior;
  99182. /**
  99183. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99184. */
  99185. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99186. /**
  99187. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99188. */
  99189. usePointerToAttachGizmos: boolean;
  99190. /**
  99191. * Instatiates a gizmo manager
  99192. * @param scene the scene to overlay the gizmos on top of
  99193. */
  99194. constructor(scene: Scene);
  99195. /**
  99196. * Attaches a set of gizmos to the specified mesh
  99197. * @param mesh The mesh the gizmo's should be attached to
  99198. */
  99199. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99200. /**
  99201. * If the position gizmo is enabled
  99202. */
  99203. positionGizmoEnabled: boolean;
  99204. /**
  99205. * If the rotation gizmo is enabled
  99206. */
  99207. rotationGizmoEnabled: boolean;
  99208. /**
  99209. * If the scale gizmo is enabled
  99210. */
  99211. scaleGizmoEnabled: boolean;
  99212. /**
  99213. * If the boundingBox gizmo is enabled
  99214. */
  99215. boundingBoxGizmoEnabled: boolean;
  99216. /**
  99217. * Disposes of the gizmo manager
  99218. */
  99219. dispose(): void;
  99220. }
  99221. }
  99222. declare module BABYLON {
  99223. /**
  99224. * Gizmo that enables viewing a light
  99225. */
  99226. export class LightGizmo extends Gizmo {
  99227. private _box;
  99228. /**
  99229. * Creates a LightGizmo
  99230. * @param gizmoLayer The utility layer the gizmo will be added to
  99231. */
  99232. constructor(gizmoLayer?: UtilityLayerRenderer);
  99233. private _light;
  99234. /**
  99235. * The light that the gizmo is attached to
  99236. */
  99237. light: Nullable<Light>;
  99238. /**
  99239. * @hidden
  99240. * Updates the gizmo to match the attached mesh's position/rotation
  99241. */
  99242. protected _update(): void;
  99243. }
  99244. }
  99245. declare module BABYLON {
  99246. /** @hidden */
  99247. export var backgroundFragmentDeclaration: {
  99248. name: string;
  99249. shader: string;
  99250. };
  99251. }
  99252. declare module BABYLON {
  99253. /** @hidden */
  99254. export var backgroundUboDeclaration: {
  99255. name: string;
  99256. shader: string;
  99257. };
  99258. }
  99259. declare module BABYLON {
  99260. /** @hidden */
  99261. export var backgroundPixelShader: {
  99262. name: string;
  99263. shader: string;
  99264. };
  99265. }
  99266. declare module BABYLON {
  99267. /** @hidden */
  99268. export var backgroundVertexDeclaration: {
  99269. name: string;
  99270. shader: string;
  99271. };
  99272. }
  99273. declare module BABYLON {
  99274. /** @hidden */
  99275. export var backgroundVertexShader: {
  99276. name: string;
  99277. shader: string;
  99278. };
  99279. }
  99280. declare module BABYLON {
  99281. /**
  99282. * Background material used to create an efficient environement around your scene.
  99283. */
  99284. export class BackgroundMaterial extends PushMaterial {
  99285. /**
  99286. * Standard reflectance value at parallel view angle.
  99287. */
  99288. static StandardReflectance0: number;
  99289. /**
  99290. * Standard reflectance value at grazing angle.
  99291. */
  99292. static StandardReflectance90: number;
  99293. protected _primaryColor: Color3;
  99294. /**
  99295. * Key light Color (multiply against the environement texture)
  99296. */
  99297. primaryColor: Color3;
  99298. protected __perceptualColor: Nullable<Color3>;
  99299. /**
  99300. * Experimental Internal Use Only.
  99301. *
  99302. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99303. * This acts as a helper to set the primary color to a more "human friendly" value.
  99304. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99305. * output color as close as possible from the chosen value.
  99306. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99307. * part of lighting setup.)
  99308. */
  99309. _perceptualColor: Nullable<Color3>;
  99310. protected _primaryColorShadowLevel: float;
  99311. /**
  99312. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99313. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99314. */
  99315. primaryColorShadowLevel: float;
  99316. protected _primaryColorHighlightLevel: float;
  99317. /**
  99318. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99319. * The primary color is used at the level chosen to define what the white area would look.
  99320. */
  99321. primaryColorHighlightLevel: float;
  99322. protected _reflectionTexture: Nullable<BaseTexture>;
  99323. /**
  99324. * Reflection Texture used in the material.
  99325. * Should be author in a specific way for the best result (refer to the documentation).
  99326. */
  99327. reflectionTexture: Nullable<BaseTexture>;
  99328. protected _reflectionBlur: float;
  99329. /**
  99330. * Reflection Texture level of blur.
  99331. *
  99332. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99333. * texture twice.
  99334. */
  99335. reflectionBlur: float;
  99336. protected _diffuseTexture: Nullable<BaseTexture>;
  99337. /**
  99338. * Diffuse Texture used in the material.
  99339. * Should be author in a specific way for the best result (refer to the documentation).
  99340. */
  99341. diffuseTexture: Nullable<BaseTexture>;
  99342. protected _shadowLights: Nullable<IShadowLight[]>;
  99343. /**
  99344. * Specify the list of lights casting shadow on the material.
  99345. * All scene shadow lights will be included if null.
  99346. */
  99347. shadowLights: Nullable<IShadowLight[]>;
  99348. protected _shadowLevel: float;
  99349. /**
  99350. * Helps adjusting the shadow to a softer level if required.
  99351. * 0 means black shadows and 1 means no shadows.
  99352. */
  99353. shadowLevel: float;
  99354. protected _sceneCenter: Vector3;
  99355. /**
  99356. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99357. * It is usually zero but might be interesting to modify according to your setup.
  99358. */
  99359. sceneCenter: Vector3;
  99360. protected _opacityFresnel: boolean;
  99361. /**
  99362. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99363. * This helps ensuring a nice transition when the camera goes under the ground.
  99364. */
  99365. opacityFresnel: boolean;
  99366. protected _reflectionFresnel: boolean;
  99367. /**
  99368. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99369. * This helps adding a mirror texture on the ground.
  99370. */
  99371. reflectionFresnel: boolean;
  99372. protected _reflectionFalloffDistance: number;
  99373. /**
  99374. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99375. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99376. */
  99377. reflectionFalloffDistance: number;
  99378. protected _reflectionAmount: number;
  99379. /**
  99380. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99381. */
  99382. reflectionAmount: number;
  99383. protected _reflectionReflectance0: number;
  99384. /**
  99385. * This specifies the weight of the reflection at grazing angle.
  99386. */
  99387. reflectionReflectance0: number;
  99388. protected _reflectionReflectance90: number;
  99389. /**
  99390. * This specifies the weight of the reflection at a perpendicular point of view.
  99391. */
  99392. reflectionReflectance90: number;
  99393. /**
  99394. * Sets the reflection reflectance fresnel values according to the default standard
  99395. * empirically know to work well :-)
  99396. */
  99397. reflectionStandardFresnelWeight: number;
  99398. protected _useRGBColor: boolean;
  99399. /**
  99400. * Helps to directly use the maps channels instead of their level.
  99401. */
  99402. useRGBColor: boolean;
  99403. protected _enableNoise: boolean;
  99404. /**
  99405. * This helps reducing the banding effect that could occur on the background.
  99406. */
  99407. enableNoise: boolean;
  99408. /**
  99409. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99410. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99411. * Recommended to be keep at 1.0 except for special cases.
  99412. */
  99413. fovMultiplier: number;
  99414. private _fovMultiplier;
  99415. /**
  99416. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99417. */
  99418. useEquirectangularFOV: boolean;
  99419. private _maxSimultaneousLights;
  99420. /**
  99421. * Number of Simultaneous lights allowed on the material.
  99422. */
  99423. maxSimultaneousLights: int;
  99424. /**
  99425. * Default configuration related to image processing available in the Background Material.
  99426. */
  99427. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99428. /**
  99429. * Keep track of the image processing observer to allow dispose and replace.
  99430. */
  99431. private _imageProcessingObserver;
  99432. /**
  99433. * Attaches a new image processing configuration to the PBR Material.
  99434. * @param configuration (if null the scene configuration will be use)
  99435. */
  99436. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99437. /**
  99438. * Gets the image processing configuration used either in this material.
  99439. */
  99440. /**
  99441. * Sets the Default image processing configuration used either in the this material.
  99442. *
  99443. * If sets to null, the scene one is in use.
  99444. */
  99445. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99446. /**
  99447. * Gets wether the color curves effect is enabled.
  99448. */
  99449. /**
  99450. * Sets wether the color curves effect is enabled.
  99451. */
  99452. cameraColorCurvesEnabled: boolean;
  99453. /**
  99454. * Gets wether the color grading effect is enabled.
  99455. */
  99456. /**
  99457. * Gets wether the color grading effect is enabled.
  99458. */
  99459. cameraColorGradingEnabled: boolean;
  99460. /**
  99461. * Gets wether tonemapping is enabled or not.
  99462. */
  99463. /**
  99464. * Sets wether tonemapping is enabled or not
  99465. */
  99466. cameraToneMappingEnabled: boolean;
  99467. /**
  99468. * The camera exposure used on this material.
  99469. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99470. * This corresponds to a photographic exposure.
  99471. */
  99472. /**
  99473. * The camera exposure used on this material.
  99474. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99475. * This corresponds to a photographic exposure.
  99476. */
  99477. cameraExposure: float;
  99478. /**
  99479. * Gets The camera contrast used on this material.
  99480. */
  99481. /**
  99482. * Sets The camera contrast used on this material.
  99483. */
  99484. cameraContrast: float;
  99485. /**
  99486. * Gets the Color Grading 2D Lookup Texture.
  99487. */
  99488. /**
  99489. * Sets the Color Grading 2D Lookup Texture.
  99490. */
  99491. cameraColorGradingTexture: Nullable<BaseTexture>;
  99492. /**
  99493. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99494. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99495. * 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;
  99496. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99497. */
  99498. /**
  99499. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99500. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99501. * 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;
  99502. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99503. */
  99504. cameraColorCurves: Nullable<ColorCurves>;
  99505. /**
  99506. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  99507. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  99508. */
  99509. switchToBGR: boolean;
  99510. private _renderTargets;
  99511. private _reflectionControls;
  99512. private _white;
  99513. private _primaryShadowColor;
  99514. private _primaryHighlightColor;
  99515. /**
  99516. * Instantiates a Background Material in the given scene
  99517. * @param name The friendly name of the material
  99518. * @param scene The scene to add the material to
  99519. */
  99520. constructor(name: string, scene: Scene);
  99521. /**
  99522. * Gets a boolean indicating that current material needs to register RTT
  99523. */
  99524. readonly hasRenderTargetTextures: boolean;
  99525. /**
  99526. * The entire material has been created in order to prevent overdraw.
  99527. * @returns false
  99528. */
  99529. needAlphaTesting(): boolean;
  99530. /**
  99531. * The entire material has been created in order to prevent overdraw.
  99532. * @returns true if blending is enable
  99533. */
  99534. needAlphaBlending(): boolean;
  99535. /**
  99536. * Checks wether the material is ready to be rendered for a given mesh.
  99537. * @param mesh The mesh to render
  99538. * @param subMesh The submesh to check against
  99539. * @param useInstances Specify wether or not the material is used with instances
  99540. * @returns true if all the dependencies are ready (Textures, Effects...)
  99541. */
  99542. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99543. /**
  99544. * Compute the primary color according to the chosen perceptual color.
  99545. */
  99546. private _computePrimaryColorFromPerceptualColor;
  99547. /**
  99548. * Compute the highlights and shadow colors according to their chosen levels.
  99549. */
  99550. private _computePrimaryColors;
  99551. /**
  99552. * Build the uniform buffer used in the material.
  99553. */
  99554. buildUniformLayout(): void;
  99555. /**
  99556. * Unbind the material.
  99557. */
  99558. unbind(): void;
  99559. /**
  99560. * Bind only the world matrix to the material.
  99561. * @param world The world matrix to bind.
  99562. */
  99563. bindOnlyWorldMatrix(world: Matrix): void;
  99564. /**
  99565. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  99566. * @param world The world matrix to bind.
  99567. * @param subMesh The submesh to bind for.
  99568. */
  99569. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99570. /**
  99571. * Dispose the material.
  99572. * @param forceDisposeEffect Force disposal of the associated effect.
  99573. * @param forceDisposeTextures Force disposal of the associated textures.
  99574. */
  99575. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99576. /**
  99577. * Clones the material.
  99578. * @param name The cloned name.
  99579. * @returns The cloned material.
  99580. */
  99581. clone(name: string): BackgroundMaterial;
  99582. /**
  99583. * Serializes the current material to its JSON representation.
  99584. * @returns The JSON representation.
  99585. */
  99586. serialize(): any;
  99587. /**
  99588. * Gets the class name of the material
  99589. * @returns "BackgroundMaterial"
  99590. */
  99591. getClassName(): string;
  99592. /**
  99593. * Parse a JSON input to create back a background material.
  99594. * @param source The JSON data to parse
  99595. * @param scene The scene to create the parsed material in
  99596. * @param rootUrl The root url of the assets the material depends upon
  99597. * @returns the instantiated BackgroundMaterial.
  99598. */
  99599. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  99600. }
  99601. }
  99602. declare module BABYLON {
  99603. /**
  99604. * Represents the different options available during the creation of
  99605. * a Environment helper.
  99606. *
  99607. * This can control the default ground, skybox and image processing setup of your scene.
  99608. */
  99609. export interface IEnvironmentHelperOptions {
  99610. /**
  99611. * Specifies wether or not to create a ground.
  99612. * True by default.
  99613. */
  99614. createGround: boolean;
  99615. /**
  99616. * Specifies the ground size.
  99617. * 15 by default.
  99618. */
  99619. groundSize: number;
  99620. /**
  99621. * The texture used on the ground for the main color.
  99622. * Comes from the BabylonJS CDN by default.
  99623. *
  99624. * Remarks: Can be either a texture or a url.
  99625. */
  99626. groundTexture: string | BaseTexture;
  99627. /**
  99628. * The color mixed in the ground texture by default.
  99629. * BabylonJS clearColor by default.
  99630. */
  99631. groundColor: Color3;
  99632. /**
  99633. * Specifies the ground opacity.
  99634. * 1 by default.
  99635. */
  99636. groundOpacity: number;
  99637. /**
  99638. * Enables the ground to receive shadows.
  99639. * True by default.
  99640. */
  99641. enableGroundShadow: boolean;
  99642. /**
  99643. * Helps preventing the shadow to be fully black on the ground.
  99644. * 0.5 by default.
  99645. */
  99646. groundShadowLevel: number;
  99647. /**
  99648. * Creates a mirror texture attach to the ground.
  99649. * false by default.
  99650. */
  99651. enableGroundMirror: boolean;
  99652. /**
  99653. * Specifies the ground mirror size ratio.
  99654. * 0.3 by default as the default kernel is 64.
  99655. */
  99656. groundMirrorSizeRatio: number;
  99657. /**
  99658. * Specifies the ground mirror blur kernel size.
  99659. * 64 by default.
  99660. */
  99661. groundMirrorBlurKernel: number;
  99662. /**
  99663. * Specifies the ground mirror visibility amount.
  99664. * 1 by default
  99665. */
  99666. groundMirrorAmount: number;
  99667. /**
  99668. * Specifies the ground mirror reflectance weight.
  99669. * This uses the standard weight of the background material to setup the fresnel effect
  99670. * of the mirror.
  99671. * 1 by default.
  99672. */
  99673. groundMirrorFresnelWeight: number;
  99674. /**
  99675. * Specifies the ground mirror Falloff distance.
  99676. * This can helps reducing the size of the reflection.
  99677. * 0 by Default.
  99678. */
  99679. groundMirrorFallOffDistance: number;
  99680. /**
  99681. * Specifies the ground mirror texture type.
  99682. * Unsigned Int by Default.
  99683. */
  99684. groundMirrorTextureType: number;
  99685. /**
  99686. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  99687. * the shown objects.
  99688. */
  99689. groundYBias: number;
  99690. /**
  99691. * Specifies wether or not to create a skybox.
  99692. * True by default.
  99693. */
  99694. createSkybox: boolean;
  99695. /**
  99696. * Specifies the skybox size.
  99697. * 20 by default.
  99698. */
  99699. skyboxSize: number;
  99700. /**
  99701. * The texture used on the skybox for the main color.
  99702. * Comes from the BabylonJS CDN by default.
  99703. *
  99704. * Remarks: Can be either a texture or a url.
  99705. */
  99706. skyboxTexture: string | BaseTexture;
  99707. /**
  99708. * The color mixed in the skybox texture by default.
  99709. * BabylonJS clearColor by default.
  99710. */
  99711. skyboxColor: Color3;
  99712. /**
  99713. * The background rotation around the Y axis of the scene.
  99714. * This helps aligning the key lights of your scene with the background.
  99715. * 0 by default.
  99716. */
  99717. backgroundYRotation: number;
  99718. /**
  99719. * Compute automatically the size of the elements to best fit with the scene.
  99720. */
  99721. sizeAuto: boolean;
  99722. /**
  99723. * Default position of the rootMesh if autoSize is not true.
  99724. */
  99725. rootPosition: Vector3;
  99726. /**
  99727. * Sets up the image processing in the scene.
  99728. * true by default.
  99729. */
  99730. setupImageProcessing: boolean;
  99731. /**
  99732. * The texture used as your environment texture in the scene.
  99733. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  99734. *
  99735. * Remarks: Can be either a texture or a url.
  99736. */
  99737. environmentTexture: string | BaseTexture;
  99738. /**
  99739. * The value of the exposure to apply to the scene.
  99740. * 0.6 by default if setupImageProcessing is true.
  99741. */
  99742. cameraExposure: number;
  99743. /**
  99744. * The value of the contrast to apply to the scene.
  99745. * 1.6 by default if setupImageProcessing is true.
  99746. */
  99747. cameraContrast: number;
  99748. /**
  99749. * Specifies wether or not tonemapping should be enabled in the scene.
  99750. * true by default if setupImageProcessing is true.
  99751. */
  99752. toneMappingEnabled: boolean;
  99753. }
  99754. /**
  99755. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  99756. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  99757. * It also helps with the default setup of your imageProcessing configuration.
  99758. */
  99759. export class EnvironmentHelper {
  99760. /**
  99761. * Default ground texture URL.
  99762. */
  99763. private static _groundTextureCDNUrl;
  99764. /**
  99765. * Default skybox texture URL.
  99766. */
  99767. private static _skyboxTextureCDNUrl;
  99768. /**
  99769. * Default environment texture URL.
  99770. */
  99771. private static _environmentTextureCDNUrl;
  99772. /**
  99773. * Creates the default options for the helper.
  99774. */
  99775. private static _getDefaultOptions;
  99776. private _rootMesh;
  99777. /**
  99778. * Gets the root mesh created by the helper.
  99779. */
  99780. readonly rootMesh: Mesh;
  99781. private _skybox;
  99782. /**
  99783. * Gets the skybox created by the helper.
  99784. */
  99785. readonly skybox: Nullable<Mesh>;
  99786. private _skyboxTexture;
  99787. /**
  99788. * Gets the skybox texture created by the helper.
  99789. */
  99790. readonly skyboxTexture: Nullable<BaseTexture>;
  99791. private _skyboxMaterial;
  99792. /**
  99793. * Gets the skybox material created by the helper.
  99794. */
  99795. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  99796. private _ground;
  99797. /**
  99798. * Gets the ground mesh created by the helper.
  99799. */
  99800. readonly ground: Nullable<Mesh>;
  99801. private _groundTexture;
  99802. /**
  99803. * Gets the ground texture created by the helper.
  99804. */
  99805. readonly groundTexture: Nullable<BaseTexture>;
  99806. private _groundMirror;
  99807. /**
  99808. * Gets the ground mirror created by the helper.
  99809. */
  99810. readonly groundMirror: Nullable<MirrorTexture>;
  99811. /**
  99812. * Gets the ground mirror render list to helps pushing the meshes
  99813. * you wish in the ground reflection.
  99814. */
  99815. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  99816. private _groundMaterial;
  99817. /**
  99818. * Gets the ground material created by the helper.
  99819. */
  99820. readonly groundMaterial: Nullable<BackgroundMaterial>;
  99821. /**
  99822. * Stores the creation options.
  99823. */
  99824. private readonly _scene;
  99825. private _options;
  99826. /**
  99827. * This observable will be notified with any error during the creation of the environment,
  99828. * mainly texture creation errors.
  99829. */
  99830. onErrorObservable: Observable<{
  99831. message?: string;
  99832. exception?: any;
  99833. }>;
  99834. /**
  99835. * constructor
  99836. * @param options Defines the options we want to customize the helper
  99837. * @param scene The scene to add the material to
  99838. */
  99839. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  99840. /**
  99841. * Updates the background according to the new options
  99842. * @param options
  99843. */
  99844. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  99845. /**
  99846. * Sets the primary color of all the available elements.
  99847. * @param color the main color to affect to the ground and the background
  99848. */
  99849. setMainColor(color: Color3): void;
  99850. /**
  99851. * Setup the image processing according to the specified options.
  99852. */
  99853. private _setupImageProcessing;
  99854. /**
  99855. * Setup the environment texture according to the specified options.
  99856. */
  99857. private _setupEnvironmentTexture;
  99858. /**
  99859. * Setup the background according to the specified options.
  99860. */
  99861. private _setupBackground;
  99862. /**
  99863. * Get the scene sizes according to the setup.
  99864. */
  99865. private _getSceneSize;
  99866. /**
  99867. * Setup the ground according to the specified options.
  99868. */
  99869. private _setupGround;
  99870. /**
  99871. * Setup the ground material according to the specified options.
  99872. */
  99873. private _setupGroundMaterial;
  99874. /**
  99875. * Setup the ground diffuse texture according to the specified options.
  99876. */
  99877. private _setupGroundDiffuseTexture;
  99878. /**
  99879. * Setup the ground mirror texture according to the specified options.
  99880. */
  99881. private _setupGroundMirrorTexture;
  99882. /**
  99883. * Setup the ground to receive the mirror texture.
  99884. */
  99885. private _setupMirrorInGroundMaterial;
  99886. /**
  99887. * Setup the skybox according to the specified options.
  99888. */
  99889. private _setupSkybox;
  99890. /**
  99891. * Setup the skybox material according to the specified options.
  99892. */
  99893. private _setupSkyboxMaterial;
  99894. /**
  99895. * Setup the skybox reflection texture according to the specified options.
  99896. */
  99897. private _setupSkyboxReflectionTexture;
  99898. private _errorHandler;
  99899. /**
  99900. * Dispose all the elements created by the Helper.
  99901. */
  99902. dispose(): void;
  99903. }
  99904. }
  99905. declare module BABYLON {
  99906. /**
  99907. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  99908. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  99909. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  99910. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99911. */
  99912. export class PhotoDome extends TransformNode {
  99913. private _useDirectMapping;
  99914. /**
  99915. * The texture being displayed on the sphere
  99916. */
  99917. protected _photoTexture: Texture;
  99918. /**
  99919. * Gets or sets the texture being displayed on the sphere
  99920. */
  99921. photoTexture: Texture;
  99922. /**
  99923. * Observable raised when an error occured while loading the 360 image
  99924. */
  99925. onLoadErrorObservable: Observable<string>;
  99926. /**
  99927. * The skybox material
  99928. */
  99929. protected _material: BackgroundMaterial;
  99930. /**
  99931. * The surface used for the skybox
  99932. */
  99933. protected _mesh: Mesh;
  99934. /**
  99935. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99936. * Also see the options.resolution property.
  99937. */
  99938. fovMultiplier: number;
  99939. /**
  99940. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  99941. * @param name Element's name, child elements will append suffixes for their own names.
  99942. * @param urlsOfPhoto defines the url of the photo to display
  99943. * @param options defines an object containing optional or exposed sub element properties
  99944. * @param onError defines a callback called when an error occured while loading the texture
  99945. */
  99946. constructor(name: string, urlOfPhoto: string, options: {
  99947. resolution?: number;
  99948. size?: number;
  99949. useDirectMapping?: boolean;
  99950. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  99951. /**
  99952. * Releases resources associated with this node.
  99953. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99954. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99955. */
  99956. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99957. }
  99958. }
  99959. declare module BABYLON {
  99960. /**
  99961. * Class used to host texture specific utilities
  99962. */
  99963. export class TextureTools {
  99964. /**
  99965. * Uses the GPU to create a copy texture rescaled at a given size
  99966. * @param texture Texture to copy from
  99967. * @param width defines the desired width
  99968. * @param height defines the desired height
  99969. * @param useBilinearMode defines if bilinear mode has to be used
  99970. * @return the generated texture
  99971. */
  99972. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  99973. /**
  99974. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  99975. * @param scene defines the hosting scene
  99976. * @returns the environment BRDF texture
  99977. */
  99978. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  99979. private static _environmentBRDFBase64Texture;
  99980. }
  99981. }
  99982. declare module BABYLON {
  99983. /**
  99984. * @hidden
  99985. */
  99986. export interface IMaterialClearCoatDefines {
  99987. CLEARCOAT: boolean;
  99988. CLEARCOAT_DEFAULTIOR: boolean;
  99989. CLEARCOAT_TEXTURE: boolean;
  99990. CLEARCOAT_TEXTUREDIRECTUV: number;
  99991. CLEARCOAT_BUMP: boolean;
  99992. CLEARCOAT_BUMPDIRECTUV: number;
  99993. CLEARCOAT_TINT: boolean;
  99994. CLEARCOAT_TINT_TEXTURE: boolean;
  99995. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  99996. /** @hidden */
  99997. _areTexturesDirty: boolean;
  99998. }
  99999. /**
  100000. * Define the code related to the clear coat parameters of the pbr material.
  100001. */
  100002. export class PBRClearCoatConfiguration {
  100003. /**
  100004. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100005. * The default fits with a polyurethane material.
  100006. */
  100007. private static readonly _DefaultIndiceOfRefraction;
  100008. private _isEnabled;
  100009. /**
  100010. * Defines if the clear coat is enabled in the material.
  100011. */
  100012. isEnabled: boolean;
  100013. /**
  100014. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100015. */
  100016. intensity: number;
  100017. /**
  100018. * Defines the clear coat layer roughness.
  100019. */
  100020. roughness: number;
  100021. private _indiceOfRefraction;
  100022. /**
  100023. * Defines the indice of refraction of the clear coat.
  100024. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100025. * The default fits with a polyurethane material.
  100026. * Changing the default value is more performance intensive.
  100027. */
  100028. indiceOfRefraction: number;
  100029. private _texture;
  100030. /**
  100031. * Stores the clear coat values in a texture.
  100032. */
  100033. texture: Nullable<BaseTexture>;
  100034. private _bumpTexture;
  100035. /**
  100036. * Define the clear coat specific bump texture.
  100037. */
  100038. bumpTexture: Nullable<BaseTexture>;
  100039. private _isTintEnabled;
  100040. /**
  100041. * Defines if the clear coat tint is enabled in the material.
  100042. */
  100043. isTintEnabled: boolean;
  100044. /**
  100045. * Defines if the clear coat tint is enabled in the material.
  100046. * This is only use if tint is enabled
  100047. */
  100048. tintColor: Color3;
  100049. /**
  100050. * Defines if the distance at which the tint color should be found in the
  100051. * clear coat media.
  100052. * This is only use if tint is enabled
  100053. */
  100054. tintColorAtDistance: number;
  100055. /**
  100056. * Defines the clear coat layer thickness.
  100057. * This is only use if tint is enabled
  100058. */
  100059. tintThickness: number;
  100060. private _tintTexture;
  100061. /**
  100062. * Stores the clear tint values in a texture.
  100063. * rgb is tint
  100064. * a is a thickness factor
  100065. */
  100066. tintTexture: Nullable<BaseTexture>;
  100067. /** @hidden */
  100068. private _internalMarkAllSubMeshesAsTexturesDirty;
  100069. /** @hidden */
  100070. _markAllSubMeshesAsTexturesDirty(): void;
  100071. /**
  100072. * Instantiate a new istance of clear coat configuration.
  100073. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100074. */
  100075. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100076. /**
  100077. * Specifies that the submesh is ready to be used.
  100078. * @param defines the list of "defines" to update.
  100079. * @param scene defines the scene the material belongs to.
  100080. * @param engine defines the engine the material belongs to.
  100081. * @param disableBumpMap defines wether the material disables bump or not.
  100082. * @returns - boolean indicating that the submesh is ready or not.
  100083. */
  100084. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100085. /**
  100086. * Checks to see if a texture is used in the material.
  100087. * @param defines the list of "defines" to update.
  100088. * @param scene defines the scene to the material belongs to.
  100089. */
  100090. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100091. /**
  100092. * Binds the material data.
  100093. * @param uniformBuffer defines the Uniform buffer to fill in.
  100094. * @param scene defines the scene the material belongs to.
  100095. * @param engine defines the engine the material belongs to.
  100096. * @param disableBumpMap defines wether the material disables bump or not.
  100097. * @param isFrozen defines wether the material is frozen or not.
  100098. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100099. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100100. */
  100101. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100102. /**
  100103. * Checks to see if a texture is used in the material.
  100104. * @param texture - Base texture to use.
  100105. * @returns - Boolean specifying if a texture is used in the material.
  100106. */
  100107. hasTexture(texture: BaseTexture): boolean;
  100108. /**
  100109. * Returns an array of the actively used textures.
  100110. * @param activeTextures Array of BaseTextures
  100111. */
  100112. getActiveTextures(activeTextures: BaseTexture[]): void;
  100113. /**
  100114. * Returns the animatable textures.
  100115. * @param animatables Array of animatable textures.
  100116. */
  100117. getAnimatables(animatables: IAnimatable[]): void;
  100118. /**
  100119. * Disposes the resources of the material.
  100120. * @param forceDisposeTextures - Forces the disposal of all textures.
  100121. */
  100122. dispose(forceDisposeTextures?: boolean): void;
  100123. /**
  100124. * Get the current class name of the texture useful for serialization or dynamic coding.
  100125. * @returns "PBRClearCoatConfiguration"
  100126. */
  100127. getClassName(): string;
  100128. /**
  100129. * Makes a duplicate of the current configuration into another one.
  100130. * @param clearCoatConfiguration define the config where to copy the info
  100131. */
  100132. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100133. /**
  100134. * Serializes this clear coat configuration.
  100135. * @returns - An object with the serialized config.
  100136. */
  100137. serialize(): any;
  100138. /**
  100139. * Parses a Clear Coat Configuration from a serialized object.
  100140. * @param source - Serialized object.
  100141. */
  100142. parse(source: any): void;
  100143. /**
  100144. * Add fallbacks to the effect fallbacks list.
  100145. * @param defines defines the Base texture to use.
  100146. * @param fallbacks defines the current fallback list.
  100147. * @param currentRank defines the current fallback rank.
  100148. * @returns the new fallback rank.
  100149. */
  100150. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100151. /**
  100152. * Add the required uniforms to the current list.
  100153. * @param uniforms defines the current uniform list.
  100154. */
  100155. static AddUniforms(uniforms: string[]): void;
  100156. /**
  100157. * Add the required samplers to the current list.
  100158. * @param samplers defines the current sampler list.
  100159. */
  100160. static AddSamplers(samplers: string[]): void;
  100161. /**
  100162. * Add the required uniforms to the current buffer.
  100163. * @param uniformBuffer defines the current uniform buffer.
  100164. */
  100165. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100166. }
  100167. }
  100168. declare module BABYLON {
  100169. /**
  100170. * @hidden
  100171. */
  100172. export interface IMaterialAnisotropicDefines {
  100173. ANISOTROPIC: boolean;
  100174. MAINUV1: boolean;
  100175. _areMiscDirty: boolean;
  100176. _needUVs: boolean;
  100177. }
  100178. /**
  100179. * Define the code related to the anisotropic parameters of the pbr material.
  100180. */
  100181. export class PBRAnisotropicConfiguration {
  100182. private _isEnabled;
  100183. /**
  100184. * Defines if the anisotropy is enabled in the material.
  100185. */
  100186. isEnabled: boolean;
  100187. /**
  100188. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100189. */
  100190. intensity: number;
  100191. /**
  100192. * Defines if the effect is along the tangents or bitangents.
  100193. * By default, the effect is "strectching" the highlights along the tangents.
  100194. */
  100195. followTangents: boolean;
  100196. /** @hidden */
  100197. private _internalMarkAllSubMeshesAsMiscDirty;
  100198. /** @hidden */
  100199. _markAllSubMeshesAsMiscDirty(): void;
  100200. /**
  100201. * Instantiate a new istance of clear coat configuration.
  100202. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100203. */
  100204. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100205. /**
  100206. * Checks to see if a texture is used in the material.
  100207. * @param defines the list of "defines" to update.
  100208. * @param mesh the mesh we are preparing the defines for.
  100209. */
  100210. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  100211. /**
  100212. * Binds the material data.
  100213. * @param uniformBuffer defines the Uniform buffer to fill in.
  100214. * @param isFrozen defines wether the material is frozen or not.
  100215. */
  100216. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  100217. /**
  100218. * Get the current class name of the texture useful for serialization or dynamic coding.
  100219. * @returns "PBRAnisotropicConfiguration"
  100220. */
  100221. getClassName(): string;
  100222. /**
  100223. * Makes a duplicate of the current configuration into another one.
  100224. * @param anisotropicConfiguration define the config where to copy the info
  100225. */
  100226. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100227. /**
  100228. * Serializes this clear coat configuration.
  100229. * @returns - An object with the serialized config.
  100230. */
  100231. serialize(): any;
  100232. /**
  100233. * Parses a Clear Coat Configuration from a serialized object.
  100234. * @param source - Serialized object.
  100235. */
  100236. parse(source: any): void;
  100237. /**
  100238. * Add fallbacks to the effect fallbacks list.
  100239. * @param defines defines the Base texture to use.
  100240. * @param fallbacks defines the current fallback list.
  100241. * @param currentRank defines the current fallback rank.
  100242. * @returns the new fallback rank.
  100243. */
  100244. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100245. /**
  100246. * Add the required uniforms to the current list.
  100247. * @param uniforms defines the current uniform list.
  100248. */
  100249. static AddUniforms(uniforms: string[]): void;
  100250. /**
  100251. * Add the required uniforms to the current buffer.
  100252. * @param uniformBuffer defines the current uniform buffer.
  100253. */
  100254. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100255. }
  100256. }
  100257. declare module BABYLON {
  100258. /**
  100259. * @hidden
  100260. */
  100261. export interface IMaterialBRDFDefines {
  100262. BRDF_V_HEIGHT_CORRELATED: boolean;
  100263. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100264. /** @hidden */
  100265. _areMiscDirty: boolean;
  100266. }
  100267. /**
  100268. * Define the code related to the BRDF parameters of the pbr material.
  100269. */
  100270. export class PBRBRDFConfiguration {
  100271. private _useEnergyConservation;
  100272. /**
  100273. * Defines if the material uses energy conservation.
  100274. */
  100275. useEnergyConservation: boolean;
  100276. private _useSmithVisibilityHeightCorrelated;
  100277. /**
  100278. * LEGACY Mode set to false
  100279. * Defines if the material uses height smith correlated visibility term.
  100280. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100281. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100282. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100283. * Not relying on height correlated will also disable energy conservation.
  100284. */
  100285. useSmithVisibilityHeightCorrelated: boolean;
  100286. /** @hidden */
  100287. private _internalMarkAllSubMeshesAsMiscDirty;
  100288. /** @hidden */
  100289. _markAllSubMeshesAsMiscDirty(): void;
  100290. /**
  100291. * Instantiate a new istance of clear coat configuration.
  100292. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100293. */
  100294. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100295. /**
  100296. * Checks to see if a texture is used in the material.
  100297. * @param defines the list of "defines" to update.
  100298. */
  100299. prepareDefines(defines: IMaterialBRDFDefines): void;
  100300. /**
  100301. * Get the current class name of the texture useful for serialization or dynamic coding.
  100302. * @returns "PBRClearCoatConfiguration"
  100303. */
  100304. getClassName(): string;
  100305. /**
  100306. * Makes a duplicate of the current configuration into another one.
  100307. * @param brdfConfiguration define the config where to copy the info
  100308. */
  100309. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100310. /**
  100311. * Serializes this BRDF configuration.
  100312. * @returns - An object with the serialized config.
  100313. */
  100314. serialize(): any;
  100315. /**
  100316. * Parses a BRDF Configuration from a serialized object.
  100317. * @param source - Serialized object.
  100318. */
  100319. parse(source: any): void;
  100320. }
  100321. }
  100322. declare module BABYLON {
  100323. /** @hidden */
  100324. export var pbrFragmentDeclaration: {
  100325. name: string;
  100326. shader: string;
  100327. };
  100328. }
  100329. declare module BABYLON {
  100330. /** @hidden */
  100331. export var pbrUboDeclaration: {
  100332. name: string;
  100333. shader: string;
  100334. };
  100335. }
  100336. declare module BABYLON {
  100337. /** @hidden */
  100338. export var pbrFunctions: {
  100339. name: string;
  100340. shader: string;
  100341. };
  100342. }
  100343. declare module BABYLON {
  100344. /** @hidden */
  100345. export var harmonicsFunctions: {
  100346. name: string;
  100347. shader: string;
  100348. };
  100349. }
  100350. declare module BABYLON {
  100351. /** @hidden */
  100352. export var pbrPreLightingFunctions: {
  100353. name: string;
  100354. shader: string;
  100355. };
  100356. }
  100357. declare module BABYLON {
  100358. /** @hidden */
  100359. export var pbrFalloffLightingFunctions: {
  100360. name: string;
  100361. shader: string;
  100362. };
  100363. }
  100364. declare module BABYLON {
  100365. /** @hidden */
  100366. export var pbrLightingFunctions: {
  100367. name: string;
  100368. shader: string;
  100369. };
  100370. }
  100371. declare module BABYLON {
  100372. /** @hidden */
  100373. export var pbrDebug: {
  100374. name: string;
  100375. shader: string;
  100376. };
  100377. }
  100378. declare module BABYLON {
  100379. /** @hidden */
  100380. export var pbrPixelShader: {
  100381. name: string;
  100382. shader: string;
  100383. };
  100384. }
  100385. declare module BABYLON {
  100386. /** @hidden */
  100387. export var pbrVertexDeclaration: {
  100388. name: string;
  100389. shader: string;
  100390. };
  100391. }
  100392. declare module BABYLON {
  100393. /** @hidden */
  100394. export var pbrVertexShader: {
  100395. name: string;
  100396. shader: string;
  100397. };
  100398. }
  100399. declare module BABYLON {
  100400. /**
  100401. * The Physically based material base class of BJS.
  100402. *
  100403. * This offers the main features of a standard PBR material.
  100404. * For more information, please refer to the documentation :
  100405. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100406. */
  100407. export abstract class PBRBaseMaterial extends PushMaterial {
  100408. /**
  100409. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100410. */
  100411. static readonly PBRMATERIAL_OPAQUE: number;
  100412. /**
  100413. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100414. */
  100415. static readonly PBRMATERIAL_ALPHATEST: number;
  100416. /**
  100417. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100418. */
  100419. static readonly PBRMATERIAL_ALPHABLEND: number;
  100420. /**
  100421. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100422. * They are also discarded below the alpha cutoff threshold to improve performances.
  100423. */
  100424. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100425. /**
  100426. * Defines the default value of how much AO map is occluding the analytical lights
  100427. * (point spot...).
  100428. */
  100429. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100430. /**
  100431. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  100432. */
  100433. static readonly LIGHTFALLOFF_PHYSICAL: number;
  100434. /**
  100435. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  100436. * to enhance interoperability with other engines.
  100437. */
  100438. static readonly LIGHTFALLOFF_GLTF: number;
  100439. /**
  100440. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  100441. * to enhance interoperability with other materials.
  100442. */
  100443. static readonly LIGHTFALLOFF_STANDARD: number;
  100444. /**
  100445. * Intensity of the direct lights e.g. the four lights available in your scene.
  100446. * This impacts both the direct diffuse and specular highlights.
  100447. */
  100448. protected _directIntensity: number;
  100449. /**
  100450. * Intensity of the emissive part of the material.
  100451. * This helps controlling the emissive effect without modifying the emissive color.
  100452. */
  100453. protected _emissiveIntensity: number;
  100454. /**
  100455. * Intensity of the environment e.g. how much the environment will light the object
  100456. * either through harmonics for rough material or through the refelction for shiny ones.
  100457. */
  100458. protected _environmentIntensity: number;
  100459. /**
  100460. * This is a special control allowing the reduction of the specular highlights coming from the
  100461. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100462. */
  100463. protected _specularIntensity: number;
  100464. /**
  100465. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  100466. */
  100467. private _lightingInfos;
  100468. /**
  100469. * Debug Control allowing disabling the bump map on this material.
  100470. */
  100471. protected _disableBumpMap: boolean;
  100472. /**
  100473. * AKA Diffuse Texture in standard nomenclature.
  100474. */
  100475. protected _albedoTexture: BaseTexture;
  100476. /**
  100477. * AKA Occlusion Texture in other nomenclature.
  100478. */
  100479. protected _ambientTexture: BaseTexture;
  100480. /**
  100481. * AKA Occlusion Texture Intensity in other nomenclature.
  100482. */
  100483. protected _ambientTextureStrength: number;
  100484. /**
  100485. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100486. * 1 means it completely occludes it
  100487. * 0 mean it has no impact
  100488. */
  100489. protected _ambientTextureImpactOnAnalyticalLights: number;
  100490. /**
  100491. * Stores the alpha values in a texture.
  100492. */
  100493. protected _opacityTexture: BaseTexture;
  100494. /**
  100495. * Stores the reflection values in a texture.
  100496. */
  100497. protected _reflectionTexture: BaseTexture;
  100498. /**
  100499. * Stores the refraction values in a texture.
  100500. */
  100501. protected _refractionTexture: BaseTexture;
  100502. /**
  100503. * Stores the emissive values in a texture.
  100504. */
  100505. protected _emissiveTexture: BaseTexture;
  100506. /**
  100507. * AKA Specular texture in other nomenclature.
  100508. */
  100509. protected _reflectivityTexture: BaseTexture;
  100510. /**
  100511. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100512. */
  100513. protected _metallicTexture: BaseTexture;
  100514. /**
  100515. * Specifies the metallic scalar of the metallic/roughness workflow.
  100516. * Can also be used to scale the metalness values of the metallic texture.
  100517. */
  100518. protected _metallic: Nullable<number>;
  100519. /**
  100520. * Specifies the roughness scalar of the metallic/roughness workflow.
  100521. * Can also be used to scale the roughness values of the metallic texture.
  100522. */
  100523. protected _roughness: Nullable<number>;
  100524. /**
  100525. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  100526. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  100527. */
  100528. protected _microSurfaceTexture: BaseTexture;
  100529. /**
  100530. * Stores surface normal data used to displace a mesh in a texture.
  100531. */
  100532. protected _bumpTexture: BaseTexture;
  100533. /**
  100534. * Stores the pre-calculated light information of a mesh in a texture.
  100535. */
  100536. protected _lightmapTexture: BaseTexture;
  100537. /**
  100538. * The color of a material in ambient lighting.
  100539. */
  100540. protected _ambientColor: Color3;
  100541. /**
  100542. * AKA Diffuse Color in other nomenclature.
  100543. */
  100544. protected _albedoColor: Color3;
  100545. /**
  100546. * AKA Specular Color in other nomenclature.
  100547. */
  100548. protected _reflectivityColor: Color3;
  100549. /**
  100550. * The color applied when light is reflected from a material.
  100551. */
  100552. protected _reflectionColor: Color3;
  100553. /**
  100554. * The color applied when light is emitted from a material.
  100555. */
  100556. protected _emissiveColor: Color3;
  100557. /**
  100558. * AKA Glossiness in other nomenclature.
  100559. */
  100560. protected _microSurface: number;
  100561. /**
  100562. * source material index of refraction (IOR)' / 'destination material IOR.
  100563. */
  100564. protected _indexOfRefraction: number;
  100565. /**
  100566. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100567. */
  100568. protected _invertRefractionY: boolean;
  100569. /**
  100570. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100571. * Materials half opaque for instance using refraction could benefit from this control.
  100572. */
  100573. protected _linkRefractionWithTransparency: boolean;
  100574. /**
  100575. * Specifies that the material will use the light map as a show map.
  100576. */
  100577. protected _useLightmapAsShadowmap: boolean;
  100578. /**
  100579. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  100580. * makes the reflect vector face the model (under horizon).
  100581. */
  100582. protected _useHorizonOcclusion: boolean;
  100583. /**
  100584. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  100585. * too much the area relying on ambient texture to define their ambient occlusion.
  100586. */
  100587. protected _useRadianceOcclusion: boolean;
  100588. /**
  100589. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  100590. */
  100591. protected _useAlphaFromAlbedoTexture: boolean;
  100592. /**
  100593. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  100594. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100595. */
  100596. protected _useSpecularOverAlpha: boolean;
  100597. /**
  100598. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  100599. */
  100600. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  100601. /**
  100602. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  100603. */
  100604. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  100605. /**
  100606. * Specifies if the metallic texture contains the roughness information in its green channel.
  100607. */
  100608. protected _useRoughnessFromMetallicTextureGreen: boolean;
  100609. /**
  100610. * Specifies if the metallic texture contains the metallness information in its blue channel.
  100611. */
  100612. protected _useMetallnessFromMetallicTextureBlue: boolean;
  100613. /**
  100614. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  100615. */
  100616. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  100617. /**
  100618. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  100619. */
  100620. protected _useAmbientInGrayScale: boolean;
  100621. /**
  100622. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  100623. * The material will try to infer what glossiness each pixel should be.
  100624. */
  100625. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  100626. /**
  100627. * Defines the falloff type used in this material.
  100628. * It by default is Physical.
  100629. */
  100630. protected _lightFalloff: number;
  100631. /**
  100632. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100633. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100634. */
  100635. protected _useRadianceOverAlpha: boolean;
  100636. /**
  100637. * Allows using an object space normal map (instead of tangent space).
  100638. */
  100639. protected _useObjectSpaceNormalMap: boolean;
  100640. /**
  100641. * Allows using the bump map in parallax mode.
  100642. */
  100643. protected _useParallax: boolean;
  100644. /**
  100645. * Allows using the bump map in parallax occlusion mode.
  100646. */
  100647. protected _useParallaxOcclusion: boolean;
  100648. /**
  100649. * Controls the scale bias of the parallax mode.
  100650. */
  100651. protected _parallaxScaleBias: number;
  100652. /**
  100653. * If sets to true, disables all the lights affecting the material.
  100654. */
  100655. protected _disableLighting: boolean;
  100656. /**
  100657. * Number of Simultaneous lights allowed on the material.
  100658. */
  100659. protected _maxSimultaneousLights: number;
  100660. /**
  100661. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100662. */
  100663. protected _invertNormalMapX: boolean;
  100664. /**
  100665. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100666. */
  100667. protected _invertNormalMapY: boolean;
  100668. /**
  100669. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100670. */
  100671. protected _twoSidedLighting: boolean;
  100672. /**
  100673. * Defines the alpha limits in alpha test mode.
  100674. */
  100675. protected _alphaCutOff: number;
  100676. /**
  100677. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  100678. */
  100679. protected _forceAlphaTest: boolean;
  100680. /**
  100681. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100682. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  100683. */
  100684. protected _useAlphaFresnel: boolean;
  100685. /**
  100686. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100687. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  100688. */
  100689. protected _useLinearAlphaFresnel: boolean;
  100690. /**
  100691. * The transparency mode of the material.
  100692. */
  100693. protected _transparencyMode: Nullable<number>;
  100694. /**
  100695. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  100696. * from cos thetav and roughness:
  100697. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  100698. */
  100699. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  100700. /**
  100701. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  100702. */
  100703. protected _forceIrradianceInFragment: boolean;
  100704. /**
  100705. * Force normal to face away from face.
  100706. */
  100707. protected _forceNormalForward: boolean;
  100708. /**
  100709. * Enables specular anti aliasing in the PBR shader.
  100710. * It will both interacts on the Geometry for analytical and IBL lighting.
  100711. * It also prefilter the roughness map based on the bump values.
  100712. */
  100713. protected _enableSpecularAntiAliasing: boolean;
  100714. /**
  100715. * Default configuration related to image processing available in the PBR Material.
  100716. */
  100717. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100718. /**
  100719. * Keep track of the image processing observer to allow dispose and replace.
  100720. */
  100721. private _imageProcessingObserver;
  100722. /**
  100723. * Attaches a new image processing configuration to the PBR Material.
  100724. * @param configuration
  100725. */
  100726. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100727. /**
  100728. * Stores the available render targets.
  100729. */
  100730. private _renderTargets;
  100731. /**
  100732. * Sets the global ambient color for the material used in lighting calculations.
  100733. */
  100734. private _globalAmbientColor;
  100735. /**
  100736. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  100737. */
  100738. private _useLogarithmicDepth;
  100739. /**
  100740. * If set to true, no lighting calculations will be applied.
  100741. */
  100742. private _unlit;
  100743. private _debugMode;
  100744. /**
  100745. * @hidden
  100746. * This is reserved for the inspector.
  100747. * Defines the material debug mode.
  100748. * It helps seeing only some components of the material while troubleshooting.
  100749. */
  100750. debugMode: number;
  100751. /**
  100752. * @hidden
  100753. * This is reserved for the inspector.
  100754. * Specify from where on screen the debug mode should start.
  100755. * The value goes from -1 (full screen) to 1 (not visible)
  100756. * It helps with side by side comparison against the final render
  100757. * This defaults to -1
  100758. */
  100759. private debugLimit;
  100760. /**
  100761. * @hidden
  100762. * This is reserved for the inspector.
  100763. * As the default viewing range might not be enough (if the ambient is really small for instance)
  100764. * You can use the factor to better multiply the final value.
  100765. */
  100766. private debugFactor;
  100767. /**
  100768. * Defines the clear coat layer parameters for the material.
  100769. */
  100770. readonly clearCoat: PBRClearCoatConfiguration;
  100771. /**
  100772. * Defines the anisotropic parameters for the material.
  100773. */
  100774. readonly anisotropy: PBRAnisotropicConfiguration;
  100775. /**
  100776. * Defines the BRDF parameters for the material.
  100777. */
  100778. readonly brdf: PBRBRDFConfiguration;
  100779. /**
  100780. * Instantiates a new PBRMaterial instance.
  100781. *
  100782. * @param name The material name
  100783. * @param scene The scene the material will be use in.
  100784. */
  100785. constructor(name: string, scene: Scene);
  100786. /**
  100787. * Gets a boolean indicating that current material needs to register RTT
  100788. */
  100789. readonly hasRenderTargetTextures: boolean;
  100790. /**
  100791. * Gets the name of the material class.
  100792. */
  100793. getClassName(): string;
  100794. /**
  100795. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  100796. */
  100797. /**
  100798. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  100799. */
  100800. useLogarithmicDepth: boolean;
  100801. /**
  100802. * Gets the current transparency mode.
  100803. */
  100804. /**
  100805. * Sets the transparency mode of the material.
  100806. *
  100807. * | Value | Type | Description |
  100808. * | ----- | ----------------------------------- | ----------- |
  100809. * | 0 | OPAQUE | |
  100810. * | 1 | ALPHATEST | |
  100811. * | 2 | ALPHABLEND | |
  100812. * | 3 | ALPHATESTANDBLEND | |
  100813. *
  100814. */
  100815. transparencyMode: Nullable<number>;
  100816. /**
  100817. * Returns true if alpha blending should be disabled.
  100818. */
  100819. private readonly _disableAlphaBlending;
  100820. /**
  100821. * Specifies whether or not this material should be rendered in alpha blend mode.
  100822. */
  100823. needAlphaBlending(): boolean;
  100824. /**
  100825. * Specifies if the mesh will require alpha blending.
  100826. * @param mesh - BJS mesh.
  100827. */
  100828. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  100829. /**
  100830. * Specifies whether or not this material should be rendered in alpha test mode.
  100831. */
  100832. needAlphaTesting(): boolean;
  100833. /**
  100834. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  100835. */
  100836. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  100837. /**
  100838. * Gets the texture used for the alpha test.
  100839. */
  100840. getAlphaTestTexture(): BaseTexture;
  100841. /**
  100842. * Specifies that the submesh is ready to be used.
  100843. * @param mesh - BJS mesh.
  100844. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  100845. * @param useInstances - Specifies that instances should be used.
  100846. * @returns - boolean indicating that the submesh is ready or not.
  100847. */
  100848. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100849. /**
  100850. * Specifies if the material uses metallic roughness workflow.
  100851. * @returns boolean specifiying if the material uses metallic roughness workflow.
  100852. */
  100853. isMetallicWorkflow(): boolean;
  100854. private _prepareEffect;
  100855. private _prepareDefines;
  100856. /**
  100857. * Force shader compilation
  100858. */
  100859. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  100860. clipPlane: boolean;
  100861. }>): void;
  100862. /**
  100863. * Initializes the uniform buffer layout for the shader.
  100864. */
  100865. buildUniformLayout(): void;
  100866. /**
  100867. * Unbinds the textures.
  100868. */
  100869. unbind(): void;
  100870. /**
  100871. * Binds the submesh data.
  100872. * @param world - The world matrix.
  100873. * @param mesh - The BJS mesh.
  100874. * @param subMesh - A submesh of the BJS mesh.
  100875. */
  100876. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100877. /**
  100878. * Returns the animatable textures.
  100879. * @returns - Array of animatable textures.
  100880. */
  100881. getAnimatables(): IAnimatable[];
  100882. /**
  100883. * Returns the texture used for reflections.
  100884. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  100885. */
  100886. private _getReflectionTexture;
  100887. /**
  100888. * Returns the texture used for refraction or null if none is used.
  100889. * @returns - Refection texture if present. If no refraction texture and refraction
  100890. * is linked with transparency, returns environment texture. Otherwise, returns null.
  100891. */
  100892. private _getRefractionTexture;
  100893. /**
  100894. * Returns an array of the actively used textures.
  100895. * @returns - Array of BaseTextures
  100896. */
  100897. getActiveTextures(): BaseTexture[];
  100898. /**
  100899. * Checks to see if a texture is used in the material.
  100900. * @param texture - Base texture to use.
  100901. * @returns - Boolean specifying if a texture is used in the material.
  100902. */
  100903. hasTexture(texture: BaseTexture): boolean;
  100904. /**
  100905. * Disposes the resources of the material.
  100906. * @param forceDisposeEffect - Forces the disposal of effects.
  100907. * @param forceDisposeTextures - Forces the disposal of all textures.
  100908. */
  100909. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100910. }
  100911. }
  100912. declare module BABYLON {
  100913. /**
  100914. * The Physically based material of BJS.
  100915. *
  100916. * This offers the main features of a standard PBR material.
  100917. * For more information, please refer to the documentation :
  100918. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100919. */
  100920. export class PBRMaterial extends PBRBaseMaterial {
  100921. /**
  100922. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100923. */
  100924. static readonly PBRMATERIAL_OPAQUE: number;
  100925. /**
  100926. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100927. */
  100928. static readonly PBRMATERIAL_ALPHATEST: number;
  100929. /**
  100930. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100931. */
  100932. static readonly PBRMATERIAL_ALPHABLEND: number;
  100933. /**
  100934. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100935. * They are also discarded below the alpha cutoff threshold to improve performances.
  100936. */
  100937. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100938. /**
  100939. * Defines the default value of how much AO map is occluding the analytical lights
  100940. * (point spot...).
  100941. */
  100942. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100943. /**
  100944. * Intensity of the direct lights e.g. the four lights available in your scene.
  100945. * This impacts both the direct diffuse and specular highlights.
  100946. */
  100947. directIntensity: number;
  100948. /**
  100949. * Intensity of the emissive part of the material.
  100950. * This helps controlling the emissive effect without modifying the emissive color.
  100951. */
  100952. emissiveIntensity: number;
  100953. /**
  100954. * Intensity of the environment e.g. how much the environment will light the object
  100955. * either through harmonics for rough material or through the refelction for shiny ones.
  100956. */
  100957. environmentIntensity: number;
  100958. /**
  100959. * This is a special control allowing the reduction of the specular highlights coming from the
  100960. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100961. */
  100962. specularIntensity: number;
  100963. /**
  100964. * Debug Control allowing disabling the bump map on this material.
  100965. */
  100966. disableBumpMap: boolean;
  100967. /**
  100968. * AKA Diffuse Texture in standard nomenclature.
  100969. */
  100970. albedoTexture: BaseTexture;
  100971. /**
  100972. * AKA Occlusion Texture in other nomenclature.
  100973. */
  100974. ambientTexture: BaseTexture;
  100975. /**
  100976. * AKA Occlusion Texture Intensity in other nomenclature.
  100977. */
  100978. ambientTextureStrength: number;
  100979. /**
  100980. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100981. * 1 means it completely occludes it
  100982. * 0 mean it has no impact
  100983. */
  100984. ambientTextureImpactOnAnalyticalLights: number;
  100985. /**
  100986. * Stores the alpha values in a texture.
  100987. */
  100988. opacityTexture: BaseTexture;
  100989. /**
  100990. * Stores the reflection values in a texture.
  100991. */
  100992. reflectionTexture: Nullable<BaseTexture>;
  100993. /**
  100994. * Stores the emissive values in a texture.
  100995. */
  100996. emissiveTexture: BaseTexture;
  100997. /**
  100998. * AKA Specular texture in other nomenclature.
  100999. */
  101000. reflectivityTexture: BaseTexture;
  101001. /**
  101002. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101003. */
  101004. metallicTexture: BaseTexture;
  101005. /**
  101006. * Specifies the metallic scalar of the metallic/roughness workflow.
  101007. * Can also be used to scale the metalness values of the metallic texture.
  101008. */
  101009. metallic: Nullable<number>;
  101010. /**
  101011. * Specifies the roughness scalar of the metallic/roughness workflow.
  101012. * Can also be used to scale the roughness values of the metallic texture.
  101013. */
  101014. roughness: Nullable<number>;
  101015. /**
  101016. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101017. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101018. */
  101019. microSurfaceTexture: BaseTexture;
  101020. /**
  101021. * Stores surface normal data used to displace a mesh in a texture.
  101022. */
  101023. bumpTexture: BaseTexture;
  101024. /**
  101025. * Stores the pre-calculated light information of a mesh in a texture.
  101026. */
  101027. lightmapTexture: BaseTexture;
  101028. /**
  101029. * Stores the refracted light information in a texture.
  101030. */
  101031. refractionTexture: BaseTexture;
  101032. /**
  101033. * The color of a material in ambient lighting.
  101034. */
  101035. ambientColor: Color3;
  101036. /**
  101037. * AKA Diffuse Color in other nomenclature.
  101038. */
  101039. albedoColor: Color3;
  101040. /**
  101041. * AKA Specular Color in other nomenclature.
  101042. */
  101043. reflectivityColor: Color3;
  101044. /**
  101045. * The color reflected from the material.
  101046. */
  101047. reflectionColor: Color3;
  101048. /**
  101049. * The color emitted from the material.
  101050. */
  101051. emissiveColor: Color3;
  101052. /**
  101053. * AKA Glossiness in other nomenclature.
  101054. */
  101055. microSurface: number;
  101056. /**
  101057. * source material index of refraction (IOR)' / 'destination material IOR.
  101058. */
  101059. indexOfRefraction: number;
  101060. /**
  101061. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101062. */
  101063. invertRefractionY: boolean;
  101064. /**
  101065. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101066. * Materials half opaque for instance using refraction could benefit from this control.
  101067. */
  101068. linkRefractionWithTransparency: boolean;
  101069. /**
  101070. * If true, the light map contains occlusion information instead of lighting info.
  101071. */
  101072. useLightmapAsShadowmap: boolean;
  101073. /**
  101074. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101075. */
  101076. useAlphaFromAlbedoTexture: boolean;
  101077. /**
  101078. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101079. */
  101080. forceAlphaTest: boolean;
  101081. /**
  101082. * Defines the alpha limits in alpha test mode.
  101083. */
  101084. alphaCutOff: number;
  101085. /**
  101086. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101087. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101088. */
  101089. useSpecularOverAlpha: boolean;
  101090. /**
  101091. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101092. */
  101093. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101094. /**
  101095. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101096. */
  101097. useRoughnessFromMetallicTextureAlpha: boolean;
  101098. /**
  101099. * Specifies if the metallic texture contains the roughness information in its green channel.
  101100. */
  101101. useRoughnessFromMetallicTextureGreen: boolean;
  101102. /**
  101103. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101104. */
  101105. useMetallnessFromMetallicTextureBlue: boolean;
  101106. /**
  101107. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101108. */
  101109. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101110. /**
  101111. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101112. */
  101113. useAmbientInGrayScale: boolean;
  101114. /**
  101115. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101116. * The material will try to infer what glossiness each pixel should be.
  101117. */
  101118. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101119. /**
  101120. * BJS is using an harcoded light falloff based on a manually sets up range.
  101121. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101122. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101123. */
  101124. /**
  101125. * BJS is using an harcoded light falloff based on a manually sets up range.
  101126. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101127. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101128. */
  101129. usePhysicalLightFalloff: boolean;
  101130. /**
  101131. * In order to support the falloff compatibility with gltf, a special mode has been added
  101132. * to reproduce the gltf light falloff.
  101133. */
  101134. /**
  101135. * In order to support the falloff compatibility with gltf, a special mode has been added
  101136. * to reproduce the gltf light falloff.
  101137. */
  101138. useGLTFLightFalloff: boolean;
  101139. /**
  101140. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101141. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101142. */
  101143. useRadianceOverAlpha: boolean;
  101144. /**
  101145. * Allows using an object space normal map (instead of tangent space).
  101146. */
  101147. useObjectSpaceNormalMap: boolean;
  101148. /**
  101149. * Allows using the bump map in parallax mode.
  101150. */
  101151. useParallax: boolean;
  101152. /**
  101153. * Allows using the bump map in parallax occlusion mode.
  101154. */
  101155. useParallaxOcclusion: boolean;
  101156. /**
  101157. * Controls the scale bias of the parallax mode.
  101158. */
  101159. parallaxScaleBias: number;
  101160. /**
  101161. * If sets to true, disables all the lights affecting the material.
  101162. */
  101163. disableLighting: boolean;
  101164. /**
  101165. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101166. */
  101167. forceIrradianceInFragment: boolean;
  101168. /**
  101169. * Number of Simultaneous lights allowed on the material.
  101170. */
  101171. maxSimultaneousLights: number;
  101172. /**
  101173. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101174. */
  101175. invertNormalMapX: boolean;
  101176. /**
  101177. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101178. */
  101179. invertNormalMapY: boolean;
  101180. /**
  101181. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101182. */
  101183. twoSidedLighting: boolean;
  101184. /**
  101185. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101186. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101187. */
  101188. useAlphaFresnel: boolean;
  101189. /**
  101190. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101191. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101192. */
  101193. useLinearAlphaFresnel: boolean;
  101194. /**
  101195. * Let user defines the brdf lookup texture used for IBL.
  101196. * A default 8bit version is embedded but you could point at :
  101197. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101198. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101199. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101200. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101201. */
  101202. environmentBRDFTexture: Nullable<BaseTexture>;
  101203. /**
  101204. * Force normal to face away from face.
  101205. */
  101206. forceNormalForward: boolean;
  101207. /**
  101208. * Enables specular anti aliasing in the PBR shader.
  101209. * It will both interacts on the Geometry for analytical and IBL lighting.
  101210. * It also prefilter the roughness map based on the bump values.
  101211. */
  101212. enableSpecularAntiAliasing: boolean;
  101213. /**
  101214. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101215. * makes the reflect vector face the model (under horizon).
  101216. */
  101217. useHorizonOcclusion: boolean;
  101218. /**
  101219. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101220. * too much the area relying on ambient texture to define their ambient occlusion.
  101221. */
  101222. useRadianceOcclusion: boolean;
  101223. /**
  101224. * If set to true, no lighting calculations will be applied.
  101225. */
  101226. unlit: boolean;
  101227. /**
  101228. * Gets the image processing configuration used either in this material.
  101229. */
  101230. /**
  101231. * Sets the Default image processing configuration used either in the this material.
  101232. *
  101233. * If sets to null, the scene one is in use.
  101234. */
  101235. imageProcessingConfiguration: ImageProcessingConfiguration;
  101236. /**
  101237. * Gets wether the color curves effect is enabled.
  101238. */
  101239. /**
  101240. * Sets wether the color curves effect is enabled.
  101241. */
  101242. cameraColorCurvesEnabled: boolean;
  101243. /**
  101244. * Gets wether the color grading effect is enabled.
  101245. */
  101246. /**
  101247. * Gets wether the color grading effect is enabled.
  101248. */
  101249. cameraColorGradingEnabled: boolean;
  101250. /**
  101251. * Gets wether tonemapping is enabled or not.
  101252. */
  101253. /**
  101254. * Sets wether tonemapping is enabled or not
  101255. */
  101256. cameraToneMappingEnabled: boolean;
  101257. /**
  101258. * The camera exposure used on this material.
  101259. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101260. * This corresponds to a photographic exposure.
  101261. */
  101262. /**
  101263. * The camera exposure used on this material.
  101264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101265. * This corresponds to a photographic exposure.
  101266. */
  101267. cameraExposure: number;
  101268. /**
  101269. * Gets The camera contrast used on this material.
  101270. */
  101271. /**
  101272. * Sets The camera contrast used on this material.
  101273. */
  101274. cameraContrast: number;
  101275. /**
  101276. * Gets the Color Grading 2D Lookup Texture.
  101277. */
  101278. /**
  101279. * Sets the Color Grading 2D Lookup Texture.
  101280. */
  101281. cameraColorGradingTexture: Nullable<BaseTexture>;
  101282. /**
  101283. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101284. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101285. * 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;
  101286. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101287. */
  101288. /**
  101289. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101290. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101291. * 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;
  101292. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101293. */
  101294. cameraColorCurves: Nullable<ColorCurves>;
  101295. /**
  101296. * Instantiates a new PBRMaterial instance.
  101297. *
  101298. * @param name The material name
  101299. * @param scene The scene the material will be use in.
  101300. */
  101301. constructor(name: string, scene: Scene);
  101302. /**
  101303. * Returns the name of this material class.
  101304. */
  101305. getClassName(): string;
  101306. /**
  101307. * Makes a duplicate of the current material.
  101308. * @param name - name to use for the new material.
  101309. */
  101310. clone(name: string): PBRMaterial;
  101311. /**
  101312. * Serializes this PBR Material.
  101313. * @returns - An object with the serialized material.
  101314. */
  101315. serialize(): any;
  101316. /**
  101317. * Parses a PBR Material from a serialized object.
  101318. * @param source - Serialized object.
  101319. * @param scene - BJS scene instance.
  101320. * @param rootUrl - url for the scene object
  101321. * @returns - PBRMaterial
  101322. */
  101323. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  101324. }
  101325. }
  101326. declare module BABYLON {
  101327. /** @hidden */
  101328. export var _forceSceneHelpersToBundle: boolean;
  101329. interface Scene {
  101330. /**
  101331. * Creates a default light for the scene.
  101332. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  101333. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  101334. */
  101335. createDefaultLight(replace?: boolean): void;
  101336. /**
  101337. * Creates a default camera for the scene.
  101338. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  101339. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  101340. * @param replace has default false, when true replaces the active camera in the scene
  101341. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  101342. */
  101343. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  101344. /**
  101345. * Creates a default camera and a default light.
  101346. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  101347. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  101348. * @param replace has the default false, when true replaces the active camera/light in the scene
  101349. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  101350. */
  101351. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  101352. /**
  101353. * Creates a new sky box
  101354. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  101355. * @param environmentTexture defines the texture to use as environment texture
  101356. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  101357. * @param scale defines the overall scale of the skybox
  101358. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  101359. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  101360. * @returns a new mesh holding the sky box
  101361. */
  101362. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  101363. /**
  101364. * Creates a new environment
  101365. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  101366. * @param options defines the options you can use to configure the environment
  101367. * @returns the new EnvironmentHelper
  101368. */
  101369. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  101370. /**
  101371. * Creates a new VREXperienceHelper
  101372. * @see http://doc.babylonjs.com/how_to/webvr_helper
  101373. * @param webVROptions defines the options used to create the new VREXperienceHelper
  101374. * @returns a new VREXperienceHelper
  101375. */
  101376. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  101377. /**
  101378. * Creates a new XREXperienceHelper
  101379. * @see http://doc.babylonjs.com/how_to/webxr
  101380. * @returns a promise for a new XREXperienceHelper
  101381. */
  101382. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  101383. }
  101384. }
  101385. declare module BABYLON {
  101386. /**
  101387. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  101388. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  101389. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  101390. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101391. */
  101392. export class VideoDome extends TransformNode {
  101393. /**
  101394. * Define the video source as a Monoscopic panoramic 360 video.
  101395. */
  101396. static readonly MODE_MONOSCOPIC: number;
  101397. /**
  101398. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  101399. */
  101400. static readonly MODE_TOPBOTTOM: number;
  101401. /**
  101402. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  101403. */
  101404. static readonly MODE_SIDEBYSIDE: number;
  101405. private _useDirectMapping;
  101406. /**
  101407. * The video texture being displayed on the sphere
  101408. */
  101409. protected _videoTexture: VideoTexture;
  101410. /**
  101411. * Gets the video texture being displayed on the sphere
  101412. */
  101413. readonly videoTexture: VideoTexture;
  101414. /**
  101415. * The skybox material
  101416. */
  101417. protected _material: BackgroundMaterial;
  101418. /**
  101419. * The surface used for the skybox
  101420. */
  101421. protected _mesh: Mesh;
  101422. /**
  101423. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101424. * Also see the options.resolution property.
  101425. */
  101426. fovMultiplier: number;
  101427. private _videoMode;
  101428. /**
  101429. * Gets or set the current video mode for the video. It can be:
  101430. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  101431. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  101432. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  101433. */
  101434. videoMode: number;
  101435. /**
  101436. * Oberserver used in Stereoscopic VR Mode.
  101437. */
  101438. private _onBeforeCameraRenderObserver;
  101439. /**
  101440. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  101441. * @param name Element's name, child elements will append suffixes for their own names.
  101442. * @param urlsOrVideo defines the url(s) or the video element to use
  101443. * @param options An object containing optional or exposed sub element properties
  101444. */
  101445. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  101446. resolution?: number;
  101447. clickToPlay?: boolean;
  101448. autoPlay?: boolean;
  101449. loop?: boolean;
  101450. size?: number;
  101451. poster?: string;
  101452. useDirectMapping?: boolean;
  101453. }, scene: Scene);
  101454. private _changeVideoMode;
  101455. /**
  101456. * Releases resources associated with this node.
  101457. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101458. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101459. */
  101460. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101461. }
  101462. }
  101463. declare module BABYLON {
  101464. /**
  101465. * This class can be used to get instrumentation data from a Babylon engine
  101466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101467. */
  101468. export class EngineInstrumentation implements IDisposable {
  101469. /**
  101470. * Define the instrumented engine.
  101471. */
  101472. engine: Engine;
  101473. private _captureGPUFrameTime;
  101474. private _gpuFrameTimeToken;
  101475. private _gpuFrameTime;
  101476. private _captureShaderCompilationTime;
  101477. private _shaderCompilationTime;
  101478. private _onBeginFrameObserver;
  101479. private _onEndFrameObserver;
  101480. private _onBeforeShaderCompilationObserver;
  101481. private _onAfterShaderCompilationObserver;
  101482. /**
  101483. * Gets the perf counter used for GPU frame time
  101484. */
  101485. readonly gpuFrameTimeCounter: PerfCounter;
  101486. /**
  101487. * Gets the GPU frame time capture status
  101488. */
  101489. /**
  101490. * Enable or disable the GPU frame time capture
  101491. */
  101492. captureGPUFrameTime: boolean;
  101493. /**
  101494. * Gets the perf counter used for shader compilation time
  101495. */
  101496. readonly shaderCompilationTimeCounter: PerfCounter;
  101497. /**
  101498. * Gets the shader compilation time capture status
  101499. */
  101500. /**
  101501. * Enable or disable the shader compilation time capture
  101502. */
  101503. captureShaderCompilationTime: boolean;
  101504. /**
  101505. * Instantiates a new engine instrumentation.
  101506. * This class can be used to get instrumentation data from a Babylon engine
  101507. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101508. * @param engine Defines the engine to instrument
  101509. */
  101510. constructor(
  101511. /**
  101512. * Define the instrumented engine.
  101513. */
  101514. engine: Engine);
  101515. /**
  101516. * Dispose and release associated resources.
  101517. */
  101518. dispose(): void;
  101519. }
  101520. }
  101521. declare module BABYLON {
  101522. /**
  101523. * This class can be used to get instrumentation data from a Babylon engine
  101524. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  101525. */
  101526. export class SceneInstrumentation implements IDisposable {
  101527. /**
  101528. * Defines the scene to instrument
  101529. */
  101530. scene: Scene;
  101531. private _captureActiveMeshesEvaluationTime;
  101532. private _activeMeshesEvaluationTime;
  101533. private _captureRenderTargetsRenderTime;
  101534. private _renderTargetsRenderTime;
  101535. private _captureFrameTime;
  101536. private _frameTime;
  101537. private _captureRenderTime;
  101538. private _renderTime;
  101539. private _captureInterFrameTime;
  101540. private _interFrameTime;
  101541. private _captureParticlesRenderTime;
  101542. private _particlesRenderTime;
  101543. private _captureSpritesRenderTime;
  101544. private _spritesRenderTime;
  101545. private _capturePhysicsTime;
  101546. private _physicsTime;
  101547. private _captureAnimationsTime;
  101548. private _animationsTime;
  101549. private _captureCameraRenderTime;
  101550. private _cameraRenderTime;
  101551. private _onBeforeActiveMeshesEvaluationObserver;
  101552. private _onAfterActiveMeshesEvaluationObserver;
  101553. private _onBeforeRenderTargetsRenderObserver;
  101554. private _onAfterRenderTargetsRenderObserver;
  101555. private _onAfterRenderObserver;
  101556. private _onBeforeDrawPhaseObserver;
  101557. private _onAfterDrawPhaseObserver;
  101558. private _onBeforeAnimationsObserver;
  101559. private _onBeforeParticlesRenderingObserver;
  101560. private _onAfterParticlesRenderingObserver;
  101561. private _onBeforeSpritesRenderingObserver;
  101562. private _onAfterSpritesRenderingObserver;
  101563. private _onBeforePhysicsObserver;
  101564. private _onAfterPhysicsObserver;
  101565. private _onAfterAnimationsObserver;
  101566. private _onBeforeCameraRenderObserver;
  101567. private _onAfterCameraRenderObserver;
  101568. /**
  101569. * Gets the perf counter used for active meshes evaluation time
  101570. */
  101571. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  101572. /**
  101573. * Gets the active meshes evaluation time capture status
  101574. */
  101575. /**
  101576. * Enable or disable the active meshes evaluation time capture
  101577. */
  101578. captureActiveMeshesEvaluationTime: boolean;
  101579. /**
  101580. * Gets the perf counter used for render targets render time
  101581. */
  101582. readonly renderTargetsRenderTimeCounter: PerfCounter;
  101583. /**
  101584. * Gets the render targets render time capture status
  101585. */
  101586. /**
  101587. * Enable or disable the render targets render time capture
  101588. */
  101589. captureRenderTargetsRenderTime: boolean;
  101590. /**
  101591. * Gets the perf counter used for particles render time
  101592. */
  101593. readonly particlesRenderTimeCounter: PerfCounter;
  101594. /**
  101595. * Gets the particles render time capture status
  101596. */
  101597. /**
  101598. * Enable or disable the particles render time capture
  101599. */
  101600. captureParticlesRenderTime: boolean;
  101601. /**
  101602. * Gets the perf counter used for sprites render time
  101603. */
  101604. readonly spritesRenderTimeCounter: PerfCounter;
  101605. /**
  101606. * Gets the sprites render time capture status
  101607. */
  101608. /**
  101609. * Enable or disable the sprites render time capture
  101610. */
  101611. captureSpritesRenderTime: boolean;
  101612. /**
  101613. * Gets the perf counter used for physics time
  101614. */
  101615. readonly physicsTimeCounter: PerfCounter;
  101616. /**
  101617. * Gets the physics time capture status
  101618. */
  101619. /**
  101620. * Enable or disable the physics time capture
  101621. */
  101622. capturePhysicsTime: boolean;
  101623. /**
  101624. * Gets the perf counter used for animations time
  101625. */
  101626. readonly animationsTimeCounter: PerfCounter;
  101627. /**
  101628. * Gets the animations time capture status
  101629. */
  101630. /**
  101631. * Enable or disable the animations time capture
  101632. */
  101633. captureAnimationsTime: boolean;
  101634. /**
  101635. * Gets the perf counter used for frame time capture
  101636. */
  101637. readonly frameTimeCounter: PerfCounter;
  101638. /**
  101639. * Gets the frame time capture status
  101640. */
  101641. /**
  101642. * Enable or disable the frame time capture
  101643. */
  101644. captureFrameTime: boolean;
  101645. /**
  101646. * Gets the perf counter used for inter-frames time capture
  101647. */
  101648. readonly interFrameTimeCounter: PerfCounter;
  101649. /**
  101650. * Gets the inter-frames time capture status
  101651. */
  101652. /**
  101653. * Enable or disable the inter-frames time capture
  101654. */
  101655. captureInterFrameTime: boolean;
  101656. /**
  101657. * Gets the perf counter used for render time capture
  101658. */
  101659. readonly renderTimeCounter: PerfCounter;
  101660. /**
  101661. * Gets the render time capture status
  101662. */
  101663. /**
  101664. * Enable or disable the render time capture
  101665. */
  101666. captureRenderTime: boolean;
  101667. /**
  101668. * Gets the perf counter used for camera render time capture
  101669. */
  101670. readonly cameraRenderTimeCounter: PerfCounter;
  101671. /**
  101672. * Gets the camera render time capture status
  101673. */
  101674. /**
  101675. * Enable or disable the camera render time capture
  101676. */
  101677. captureCameraRenderTime: boolean;
  101678. /**
  101679. * Gets the perf counter used for draw calls
  101680. */
  101681. readonly drawCallsCounter: PerfCounter;
  101682. /**
  101683. * Gets the perf counter used for texture collisions
  101684. */
  101685. readonly textureCollisionsCounter: PerfCounter;
  101686. /**
  101687. * Instantiates a new scene instrumentation.
  101688. * This class can be used to get instrumentation data from a Babylon engine
  101689. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  101690. * @param scene Defines the scene to instrument
  101691. */
  101692. constructor(
  101693. /**
  101694. * Defines the scene to instrument
  101695. */
  101696. scene: Scene);
  101697. /**
  101698. * Dispose and release associated resources.
  101699. */
  101700. dispose(): void;
  101701. }
  101702. }
  101703. declare module BABYLON {
  101704. /** @hidden */
  101705. export var glowMapGenerationPixelShader: {
  101706. name: string;
  101707. shader: string;
  101708. };
  101709. }
  101710. declare module BABYLON {
  101711. /** @hidden */
  101712. export var glowMapGenerationVertexShader: {
  101713. name: string;
  101714. shader: string;
  101715. };
  101716. }
  101717. declare module BABYLON {
  101718. /**
  101719. * Effect layer options. This helps customizing the behaviour
  101720. * of the effect layer.
  101721. */
  101722. export interface IEffectLayerOptions {
  101723. /**
  101724. * Multiplication factor apply to the canvas size to compute the render target size
  101725. * used to generated the objects (the smaller the faster).
  101726. */
  101727. mainTextureRatio: number;
  101728. /**
  101729. * Enforces a fixed size texture to ensure effect stability across devices.
  101730. */
  101731. mainTextureFixedSize?: number;
  101732. /**
  101733. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  101734. */
  101735. alphaBlendingMode: number;
  101736. /**
  101737. * The camera attached to the layer.
  101738. */
  101739. camera: Nullable<Camera>;
  101740. /**
  101741. * The rendering group to draw the layer in.
  101742. */
  101743. renderingGroupId: number;
  101744. }
  101745. /**
  101746. * The effect layer Helps adding post process effect blended with the main pass.
  101747. *
  101748. * This can be for instance use to generate glow or higlight effects on the scene.
  101749. *
  101750. * The effect layer class can not be used directly and is intented to inherited from to be
  101751. * customized per effects.
  101752. */
  101753. export abstract class EffectLayer {
  101754. private _vertexBuffers;
  101755. private _indexBuffer;
  101756. private _cachedDefines;
  101757. private _effectLayerMapGenerationEffect;
  101758. private _effectLayerOptions;
  101759. private _mergeEffect;
  101760. protected _scene: Scene;
  101761. protected _engine: Engine;
  101762. protected _maxSize: number;
  101763. protected _mainTextureDesiredSize: ISize;
  101764. protected _mainTexture: RenderTargetTexture;
  101765. protected _shouldRender: boolean;
  101766. protected _postProcesses: PostProcess[];
  101767. protected _textures: BaseTexture[];
  101768. protected _emissiveTextureAndColor: {
  101769. texture: Nullable<BaseTexture>;
  101770. color: Color4;
  101771. };
  101772. /**
  101773. * The name of the layer
  101774. */
  101775. name: string;
  101776. /**
  101777. * The clear color of the texture used to generate the glow map.
  101778. */
  101779. neutralColor: Color4;
  101780. /**
  101781. * Specifies wether the highlight layer is enabled or not.
  101782. */
  101783. isEnabled: boolean;
  101784. /**
  101785. * Gets the camera attached to the layer.
  101786. */
  101787. readonly camera: Nullable<Camera>;
  101788. /**
  101789. * Gets the rendering group id the layer should render in.
  101790. */
  101791. readonly renderingGroupId: number;
  101792. /**
  101793. * An event triggered when the effect layer has been disposed.
  101794. */
  101795. onDisposeObservable: Observable<EffectLayer>;
  101796. /**
  101797. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  101798. */
  101799. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  101800. /**
  101801. * An event triggered when the generated texture is being merged in the scene.
  101802. */
  101803. onBeforeComposeObservable: Observable<EffectLayer>;
  101804. /**
  101805. * An event triggered when the generated texture has been merged in the scene.
  101806. */
  101807. onAfterComposeObservable: Observable<EffectLayer>;
  101808. /**
  101809. * An event triggered when the efffect layer changes its size.
  101810. */
  101811. onSizeChangedObservable: Observable<EffectLayer>;
  101812. /** @hidden */
  101813. static _SceneComponentInitialization: (scene: Scene) => void;
  101814. /**
  101815. * Instantiates a new effect Layer and references it in the scene.
  101816. * @param name The name of the layer
  101817. * @param scene The scene to use the layer in
  101818. */
  101819. constructor(
  101820. /** The Friendly of the effect in the scene */
  101821. name: string, scene: Scene);
  101822. /**
  101823. * Get the effect name of the layer.
  101824. * @return The effect name
  101825. */
  101826. abstract getEffectName(): string;
  101827. /**
  101828. * Checks for the readiness of the element composing the layer.
  101829. * @param subMesh the mesh to check for
  101830. * @param useInstances specify wether or not to use instances to render the mesh
  101831. * @return true if ready otherwise, false
  101832. */
  101833. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  101834. /**
  101835. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  101836. * @returns true if the effect requires stencil during the main canvas render pass.
  101837. */
  101838. abstract needStencil(): boolean;
  101839. /**
  101840. * Create the merge effect. This is the shader use to blit the information back
  101841. * to the main canvas at the end of the scene rendering.
  101842. * @returns The effect containing the shader used to merge the effect on the main canvas
  101843. */
  101844. protected abstract _createMergeEffect(): Effect;
  101845. /**
  101846. * Creates the render target textures and post processes used in the effect layer.
  101847. */
  101848. protected abstract _createTextureAndPostProcesses(): void;
  101849. /**
  101850. * Implementation specific of rendering the generating effect on the main canvas.
  101851. * @param effect The effect used to render through
  101852. */
  101853. protected abstract _internalRender(effect: Effect): void;
  101854. /**
  101855. * Sets the required values for both the emissive texture and and the main color.
  101856. */
  101857. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  101858. /**
  101859. * Free any resources and references associated to a mesh.
  101860. * Internal use
  101861. * @param mesh The mesh to free.
  101862. */
  101863. abstract _disposeMesh(mesh: Mesh): void;
  101864. /**
  101865. * Serializes this layer (Glow or Highlight for example)
  101866. * @returns a serialized layer object
  101867. */
  101868. abstract serialize?(): any;
  101869. /**
  101870. * Initializes the effect layer with the required options.
  101871. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  101872. */
  101873. protected _init(options: Partial<IEffectLayerOptions>): void;
  101874. /**
  101875. * Generates the index buffer of the full screen quad blending to the main canvas.
  101876. */
  101877. private _generateIndexBuffer;
  101878. /**
  101879. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  101880. */
  101881. private _genrateVertexBuffer;
  101882. /**
  101883. * Sets the main texture desired size which is the closest power of two
  101884. * of the engine canvas size.
  101885. */
  101886. private _setMainTextureSize;
  101887. /**
  101888. * Creates the main texture for the effect layer.
  101889. */
  101890. protected _createMainTexture(): void;
  101891. /**
  101892. * Adds specific effects defines.
  101893. * @param defines The defines to add specifics to.
  101894. */
  101895. protected _addCustomEffectDefines(defines: string[]): void;
  101896. /**
  101897. * Checks for the readiness of the element composing the layer.
  101898. * @param subMesh the mesh to check for
  101899. * @param useInstances specify wether or not to use instances to render the mesh
  101900. * @param emissiveTexture the associated emissive texture used to generate the glow
  101901. * @return true if ready otherwise, false
  101902. */
  101903. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  101904. /**
  101905. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  101906. */
  101907. render(): void;
  101908. /**
  101909. * Determine if a given mesh will be used in the current effect.
  101910. * @param mesh mesh to test
  101911. * @returns true if the mesh will be used
  101912. */
  101913. hasMesh(mesh: AbstractMesh): boolean;
  101914. /**
  101915. * Returns true if the layer contains information to display, otherwise false.
  101916. * @returns true if the glow layer should be rendered
  101917. */
  101918. shouldRender(): boolean;
  101919. /**
  101920. * Returns true if the mesh should render, otherwise false.
  101921. * @param mesh The mesh to render
  101922. * @returns true if it should render otherwise false
  101923. */
  101924. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  101925. /**
  101926. * Returns true if the mesh can be rendered, otherwise false.
  101927. * @param mesh The mesh to render
  101928. * @param material The material used on the mesh
  101929. * @returns true if it can be rendered otherwise false
  101930. */
  101931. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  101932. /**
  101933. * Returns true if the mesh should render, otherwise false.
  101934. * @param mesh The mesh to render
  101935. * @returns true if it should render otherwise false
  101936. */
  101937. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  101938. /**
  101939. * Renders the submesh passed in parameter to the generation map.
  101940. */
  101941. protected _renderSubMesh(subMesh: SubMesh): void;
  101942. /**
  101943. * Rebuild the required buffers.
  101944. * @hidden Internal use only.
  101945. */
  101946. _rebuild(): void;
  101947. /**
  101948. * Dispose only the render target textures and post process.
  101949. */
  101950. private _disposeTextureAndPostProcesses;
  101951. /**
  101952. * Dispose the highlight layer and free resources.
  101953. */
  101954. dispose(): void;
  101955. /**
  101956. * Gets the class name of the effect layer
  101957. * @returns the string with the class name of the effect layer
  101958. */
  101959. getClassName(): string;
  101960. /**
  101961. * Creates an effect layer from parsed effect layer data
  101962. * @param parsedEffectLayer defines effect layer data
  101963. * @param scene defines the current scene
  101964. * @param rootUrl defines the root URL containing the effect layer information
  101965. * @returns a parsed effect Layer
  101966. */
  101967. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  101968. }
  101969. }
  101970. declare module BABYLON {
  101971. interface AbstractScene {
  101972. /**
  101973. * The list of effect layers (highlights/glow) added to the scene
  101974. * @see http://doc.babylonjs.com/how_to/highlight_layer
  101975. * @see http://doc.babylonjs.com/how_to/glow_layer
  101976. */
  101977. effectLayers: Array<EffectLayer>;
  101978. /**
  101979. * Removes the given effect layer from this scene.
  101980. * @param toRemove defines the effect layer to remove
  101981. * @returns the index of the removed effect layer
  101982. */
  101983. removeEffectLayer(toRemove: EffectLayer): number;
  101984. /**
  101985. * Adds the given effect layer to this scene
  101986. * @param newEffectLayer defines the effect layer to add
  101987. */
  101988. addEffectLayer(newEffectLayer: EffectLayer): void;
  101989. }
  101990. /**
  101991. * Defines the layer scene component responsible to manage any effect layers
  101992. * in a given scene.
  101993. */
  101994. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  101995. /**
  101996. * The component name helpfull to identify the component in the list of scene components.
  101997. */
  101998. readonly name: string;
  101999. /**
  102000. * The scene the component belongs to.
  102001. */
  102002. scene: Scene;
  102003. private _engine;
  102004. private _renderEffects;
  102005. private _needStencil;
  102006. private _previousStencilState;
  102007. /**
  102008. * Creates a new instance of the component for the given scene
  102009. * @param scene Defines the scene to register the component in
  102010. */
  102011. constructor(scene: Scene);
  102012. /**
  102013. * Registers the component in a given scene
  102014. */
  102015. register(): void;
  102016. /**
  102017. * Rebuilds the elements related to this component in case of
  102018. * context lost for instance.
  102019. */
  102020. rebuild(): void;
  102021. /**
  102022. * Serializes the component data to the specified json object
  102023. * @param serializationObject The object to serialize to
  102024. */
  102025. serialize(serializationObject: any): void;
  102026. /**
  102027. * Adds all the element from the container to the scene
  102028. * @param container the container holding the elements
  102029. */
  102030. addFromContainer(container: AbstractScene): void;
  102031. /**
  102032. * Removes all the elements in the container from the scene
  102033. * @param container contains the elements to remove
  102034. */
  102035. removeFromContainer(container: AbstractScene): void;
  102036. /**
  102037. * Disposes the component and the associated ressources.
  102038. */
  102039. dispose(): void;
  102040. private _isReadyForMesh;
  102041. private _renderMainTexture;
  102042. private _setStencil;
  102043. private _setStencilBack;
  102044. private _draw;
  102045. private _drawCamera;
  102046. private _drawRenderingGroup;
  102047. }
  102048. }
  102049. declare module BABYLON {
  102050. /** @hidden */
  102051. export var glowMapMergePixelShader: {
  102052. name: string;
  102053. shader: string;
  102054. };
  102055. }
  102056. declare module BABYLON {
  102057. /** @hidden */
  102058. export var glowMapMergeVertexShader: {
  102059. name: string;
  102060. shader: string;
  102061. };
  102062. }
  102063. declare module BABYLON {
  102064. interface AbstractScene {
  102065. /**
  102066. * Return a the first highlight layer of the scene with a given name.
  102067. * @param name The name of the highlight layer to look for.
  102068. * @return The highlight layer if found otherwise null.
  102069. */
  102070. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  102071. }
  102072. /**
  102073. * Glow layer options. This helps customizing the behaviour
  102074. * of the glow layer.
  102075. */
  102076. export interface IGlowLayerOptions {
  102077. /**
  102078. * Multiplication factor apply to the canvas size to compute the render target size
  102079. * used to generated the glowing objects (the smaller the faster).
  102080. */
  102081. mainTextureRatio: number;
  102082. /**
  102083. * Enforces a fixed size texture to ensure resize independant blur.
  102084. */
  102085. mainTextureFixedSize?: number;
  102086. /**
  102087. * How big is the kernel of the blur texture.
  102088. */
  102089. blurKernelSize: number;
  102090. /**
  102091. * The camera attached to the layer.
  102092. */
  102093. camera: Nullable<Camera>;
  102094. /**
  102095. * Enable MSAA by chosing the number of samples.
  102096. */
  102097. mainTextureSamples?: number;
  102098. /**
  102099. * The rendering group to draw the layer in.
  102100. */
  102101. renderingGroupId: number;
  102102. }
  102103. /**
  102104. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  102105. *
  102106. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  102107. * glowy meshes to your scene.
  102108. *
  102109. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  102110. */
  102111. export class GlowLayer extends EffectLayer {
  102112. /**
  102113. * Effect Name of the layer.
  102114. */
  102115. static readonly EffectName: string;
  102116. /**
  102117. * The default blur kernel size used for the glow.
  102118. */
  102119. static DefaultBlurKernelSize: number;
  102120. /**
  102121. * The default texture size ratio used for the glow.
  102122. */
  102123. static DefaultTextureRatio: number;
  102124. /**
  102125. * Sets the kernel size of the blur.
  102126. */
  102127. /**
  102128. * Gets the kernel size of the blur.
  102129. */
  102130. blurKernelSize: number;
  102131. /**
  102132. * Sets the glow intensity.
  102133. */
  102134. /**
  102135. * Gets the glow intensity.
  102136. */
  102137. intensity: number;
  102138. private _options;
  102139. private _intensity;
  102140. private _horizontalBlurPostprocess1;
  102141. private _verticalBlurPostprocess1;
  102142. private _horizontalBlurPostprocess2;
  102143. private _verticalBlurPostprocess2;
  102144. private _blurTexture1;
  102145. private _blurTexture2;
  102146. private _postProcesses1;
  102147. private _postProcesses2;
  102148. private _includedOnlyMeshes;
  102149. private _excludedMeshes;
  102150. /**
  102151. * Callback used to let the user override the color selection on a per mesh basis
  102152. */
  102153. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  102154. /**
  102155. * Callback used to let the user override the texture selection on a per mesh basis
  102156. */
  102157. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  102158. /**
  102159. * Instantiates a new glow Layer and references it to the scene.
  102160. * @param name The name of the layer
  102161. * @param scene The scene to use the layer in
  102162. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  102163. */
  102164. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  102165. /**
  102166. * Get the effect name of the layer.
  102167. * @return The effect name
  102168. */
  102169. getEffectName(): string;
  102170. /**
  102171. * Create the merge effect. This is the shader use to blit the information back
  102172. * to the main canvas at the end of the scene rendering.
  102173. */
  102174. protected _createMergeEffect(): Effect;
  102175. /**
  102176. * Creates the render target textures and post processes used in the glow layer.
  102177. */
  102178. protected _createTextureAndPostProcesses(): void;
  102179. /**
  102180. * Checks for the readiness of the element composing the layer.
  102181. * @param subMesh the mesh to check for
  102182. * @param useInstances specify wether or not to use instances to render the mesh
  102183. * @param emissiveTexture the associated emissive texture used to generate the glow
  102184. * @return true if ready otherwise, false
  102185. */
  102186. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102187. /**
  102188. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102189. */
  102190. needStencil(): boolean;
  102191. /**
  102192. * Returns true if the mesh can be rendered, otherwise false.
  102193. * @param mesh The mesh to render
  102194. * @param material The material used on the mesh
  102195. * @returns true if it can be rendered otherwise false
  102196. */
  102197. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  102198. /**
  102199. * Implementation specific of rendering the generating effect on the main canvas.
  102200. * @param effect The effect used to render through
  102201. */
  102202. protected _internalRender(effect: Effect): void;
  102203. /**
  102204. * Sets the required values for both the emissive texture and and the main color.
  102205. */
  102206. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102207. /**
  102208. * Returns true if the mesh should render, otherwise false.
  102209. * @param mesh The mesh to render
  102210. * @returns true if it should render otherwise false
  102211. */
  102212. protected _shouldRenderMesh(mesh: Mesh): boolean;
  102213. /**
  102214. * Adds specific effects defines.
  102215. * @param defines The defines to add specifics to.
  102216. */
  102217. protected _addCustomEffectDefines(defines: string[]): void;
  102218. /**
  102219. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  102220. * @param mesh The mesh to exclude from the glow layer
  102221. */
  102222. addExcludedMesh(mesh: Mesh): void;
  102223. /**
  102224. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  102225. * @param mesh The mesh to remove
  102226. */
  102227. removeExcludedMesh(mesh: Mesh): void;
  102228. /**
  102229. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  102230. * @param mesh The mesh to include in the glow layer
  102231. */
  102232. addIncludedOnlyMesh(mesh: Mesh): void;
  102233. /**
  102234. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  102235. * @param mesh The mesh to remove
  102236. */
  102237. removeIncludedOnlyMesh(mesh: Mesh): void;
  102238. /**
  102239. * Determine if a given mesh will be used in the glow layer
  102240. * @param mesh The mesh to test
  102241. * @returns true if the mesh will be highlighted by the current glow layer
  102242. */
  102243. hasMesh(mesh: AbstractMesh): boolean;
  102244. /**
  102245. * Free any resources and references associated to a mesh.
  102246. * Internal use
  102247. * @param mesh The mesh to free.
  102248. * @hidden
  102249. */
  102250. _disposeMesh(mesh: Mesh): void;
  102251. /**
  102252. * Gets the class name of the effect layer
  102253. * @returns the string with the class name of the effect layer
  102254. */
  102255. getClassName(): string;
  102256. /**
  102257. * Serializes this glow layer
  102258. * @returns a serialized glow layer object
  102259. */
  102260. serialize(): any;
  102261. /**
  102262. * Creates a Glow Layer from parsed glow layer data
  102263. * @param parsedGlowLayer defines glow layer data
  102264. * @param scene defines the current scene
  102265. * @param rootUrl defines the root URL containing the glow layer information
  102266. * @returns a parsed Glow Layer
  102267. */
  102268. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  102269. }
  102270. }
  102271. declare module BABYLON {
  102272. /** @hidden */
  102273. export var glowBlurPostProcessPixelShader: {
  102274. name: string;
  102275. shader: string;
  102276. };
  102277. }
  102278. declare module BABYLON {
  102279. interface AbstractScene {
  102280. /**
  102281. * Return a the first highlight layer of the scene with a given name.
  102282. * @param name The name of the highlight layer to look for.
  102283. * @return The highlight layer if found otherwise null.
  102284. */
  102285. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  102286. }
  102287. /**
  102288. * Highlight layer options. This helps customizing the behaviour
  102289. * of the highlight layer.
  102290. */
  102291. export interface IHighlightLayerOptions {
  102292. /**
  102293. * Multiplication factor apply to the canvas size to compute the render target size
  102294. * used to generated the glowing objects (the smaller the faster).
  102295. */
  102296. mainTextureRatio: number;
  102297. /**
  102298. * Enforces a fixed size texture to ensure resize independant blur.
  102299. */
  102300. mainTextureFixedSize?: number;
  102301. /**
  102302. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  102303. * of the picture to blur (the smaller the faster).
  102304. */
  102305. blurTextureSizeRatio: number;
  102306. /**
  102307. * How big in texel of the blur texture is the vertical blur.
  102308. */
  102309. blurVerticalSize: number;
  102310. /**
  102311. * How big in texel of the blur texture is the horizontal blur.
  102312. */
  102313. blurHorizontalSize: number;
  102314. /**
  102315. * Alpha blending mode used to apply the blur. Default is combine.
  102316. */
  102317. alphaBlendingMode: number;
  102318. /**
  102319. * The camera attached to the layer.
  102320. */
  102321. camera: Nullable<Camera>;
  102322. /**
  102323. * Should we display highlight as a solid stroke?
  102324. */
  102325. isStroke?: boolean;
  102326. /**
  102327. * The rendering group to draw the layer in.
  102328. */
  102329. renderingGroupId: number;
  102330. }
  102331. /**
  102332. * The highlight layer Helps adding a glow effect around a mesh.
  102333. *
  102334. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  102335. * glowy meshes to your scene.
  102336. *
  102337. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  102338. */
  102339. export class HighlightLayer extends EffectLayer {
  102340. name: string;
  102341. /**
  102342. * Effect Name of the highlight layer.
  102343. */
  102344. static readonly EffectName: string;
  102345. /**
  102346. * The neutral color used during the preparation of the glow effect.
  102347. * This is black by default as the blend operation is a blend operation.
  102348. */
  102349. static NeutralColor: Color4;
  102350. /**
  102351. * Stencil value used for glowing meshes.
  102352. */
  102353. static GlowingMeshStencilReference: number;
  102354. /**
  102355. * Stencil value used for the other meshes in the scene.
  102356. */
  102357. static NormalMeshStencilReference: number;
  102358. /**
  102359. * Specifies whether or not the inner glow is ACTIVE in the layer.
  102360. */
  102361. innerGlow: boolean;
  102362. /**
  102363. * Specifies whether or not the outer glow is ACTIVE in the layer.
  102364. */
  102365. outerGlow: boolean;
  102366. /**
  102367. * Specifies the horizontal size of the blur.
  102368. */
  102369. /**
  102370. * Gets the horizontal size of the blur.
  102371. */
  102372. blurHorizontalSize: number;
  102373. /**
  102374. * Specifies the vertical size of the blur.
  102375. */
  102376. /**
  102377. * Gets the vertical size of the blur.
  102378. */
  102379. blurVerticalSize: number;
  102380. /**
  102381. * An event triggered when the highlight layer is being blurred.
  102382. */
  102383. onBeforeBlurObservable: Observable<HighlightLayer>;
  102384. /**
  102385. * An event triggered when the highlight layer has been blurred.
  102386. */
  102387. onAfterBlurObservable: Observable<HighlightLayer>;
  102388. private _instanceGlowingMeshStencilReference;
  102389. private _options;
  102390. private _downSamplePostprocess;
  102391. private _horizontalBlurPostprocess;
  102392. private _verticalBlurPostprocess;
  102393. private _blurTexture;
  102394. private _meshes;
  102395. private _excludedMeshes;
  102396. /**
  102397. * Instantiates a new highlight Layer and references it to the scene..
  102398. * @param name The name of the layer
  102399. * @param scene The scene to use the layer in
  102400. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  102401. */
  102402. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  102403. /**
  102404. * Get the effect name of the layer.
  102405. * @return The effect name
  102406. */
  102407. getEffectName(): string;
  102408. /**
  102409. * Create the merge effect. This is the shader use to blit the information back
  102410. * to the main canvas at the end of the scene rendering.
  102411. */
  102412. protected _createMergeEffect(): Effect;
  102413. /**
  102414. * Creates the render target textures and post processes used in the highlight layer.
  102415. */
  102416. protected _createTextureAndPostProcesses(): void;
  102417. /**
  102418. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102419. */
  102420. needStencil(): boolean;
  102421. /**
  102422. * Checks for the readiness of the element composing the layer.
  102423. * @param subMesh the mesh to check for
  102424. * @param useInstances specify wether or not to use instances to render the mesh
  102425. * @param emissiveTexture the associated emissive texture used to generate the glow
  102426. * @return true if ready otherwise, false
  102427. */
  102428. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102429. /**
  102430. * Implementation specific of rendering the generating effect on the main canvas.
  102431. * @param effect The effect used to render through
  102432. */
  102433. protected _internalRender(effect: Effect): void;
  102434. /**
  102435. * Returns true if the layer contains information to display, otherwise false.
  102436. */
  102437. shouldRender(): boolean;
  102438. /**
  102439. * Returns true if the mesh should render, otherwise false.
  102440. * @param mesh The mesh to render
  102441. * @returns true if it should render otherwise false
  102442. */
  102443. protected _shouldRenderMesh(mesh: Mesh): boolean;
  102444. /**
  102445. * Sets the required values for both the emissive texture and and the main color.
  102446. */
  102447. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102448. /**
  102449. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  102450. * @param mesh The mesh to exclude from the highlight layer
  102451. */
  102452. addExcludedMesh(mesh: Mesh): void;
  102453. /**
  102454. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  102455. * @param mesh The mesh to highlight
  102456. */
  102457. removeExcludedMesh(mesh: Mesh): void;
  102458. /**
  102459. * Determine if a given mesh will be highlighted by the current HighlightLayer
  102460. * @param mesh mesh to test
  102461. * @returns true if the mesh will be highlighted by the current HighlightLayer
  102462. */
  102463. hasMesh(mesh: AbstractMesh): boolean;
  102464. /**
  102465. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  102466. * @param mesh The mesh to highlight
  102467. * @param color The color of the highlight
  102468. * @param glowEmissiveOnly Extract the glow from the emissive texture
  102469. */
  102470. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  102471. /**
  102472. * Remove a mesh from the highlight layer in order to make it stop glowing.
  102473. * @param mesh The mesh to highlight
  102474. */
  102475. removeMesh(mesh: Mesh): void;
  102476. /**
  102477. * Force the stencil to the normal expected value for none glowing parts
  102478. */
  102479. private _defaultStencilReference;
  102480. /**
  102481. * Free any resources and references associated to a mesh.
  102482. * Internal use
  102483. * @param mesh The mesh to free.
  102484. * @hidden
  102485. */
  102486. _disposeMesh(mesh: Mesh): void;
  102487. /**
  102488. * Dispose the highlight layer and free resources.
  102489. */
  102490. dispose(): void;
  102491. /**
  102492. * Gets the class name of the effect layer
  102493. * @returns the string with the class name of the effect layer
  102494. */
  102495. getClassName(): string;
  102496. /**
  102497. * Serializes this Highlight layer
  102498. * @returns a serialized Highlight layer object
  102499. */
  102500. serialize(): any;
  102501. /**
  102502. * Creates a Highlight layer from parsed Highlight layer data
  102503. * @param parsedHightlightLayer defines the Highlight layer data
  102504. * @param scene defines the current scene
  102505. * @param rootUrl defines the root URL containing the Highlight layer information
  102506. * @returns a parsed Highlight layer
  102507. */
  102508. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  102509. }
  102510. }
  102511. declare module BABYLON {
  102512. /** @hidden */
  102513. export var lensFlarePixelShader: {
  102514. name: string;
  102515. shader: string;
  102516. };
  102517. }
  102518. declare module BABYLON {
  102519. /** @hidden */
  102520. export var lensFlareVertexShader: {
  102521. name: string;
  102522. shader: string;
  102523. };
  102524. }
  102525. declare module BABYLON {
  102526. /**
  102527. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  102528. * It is usually composed of several `lensFlare`.
  102529. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102530. */
  102531. export class LensFlareSystem {
  102532. /**
  102533. * Define the name of the lens flare system
  102534. */
  102535. name: string;
  102536. /**
  102537. * List of lens flares used in this system.
  102538. */
  102539. lensFlares: LensFlare[];
  102540. /**
  102541. * Define a limit from the border the lens flare can be visible.
  102542. */
  102543. borderLimit: number;
  102544. /**
  102545. * Define a viewport border we do not want to see the lens flare in.
  102546. */
  102547. viewportBorder: number;
  102548. /**
  102549. * Define a predicate which could limit the list of meshes able to occlude the effect.
  102550. */
  102551. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102552. /**
  102553. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  102554. */
  102555. layerMask: number;
  102556. /**
  102557. * Define the id of the lens flare system in the scene.
  102558. * (equal to name by default)
  102559. */
  102560. id: string;
  102561. private _scene;
  102562. private _emitter;
  102563. private _vertexBuffers;
  102564. private _indexBuffer;
  102565. private _effect;
  102566. private _positionX;
  102567. private _positionY;
  102568. private _isEnabled;
  102569. /** @hidden */
  102570. static _SceneComponentInitialization: (scene: Scene) => void;
  102571. /**
  102572. * Instantiates a lens flare system.
  102573. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  102574. * It is usually composed of several `lensFlare`.
  102575. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102576. * @param name Define the name of the lens flare system in the scene
  102577. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  102578. * @param scene Define the scene the lens flare system belongs to
  102579. */
  102580. constructor(
  102581. /**
  102582. * Define the name of the lens flare system
  102583. */
  102584. name: string, emitter: any, scene: Scene);
  102585. /**
  102586. * Define if the lens flare system is enabled.
  102587. */
  102588. isEnabled: boolean;
  102589. /**
  102590. * Get the scene the effects belongs to.
  102591. * @returns the scene holding the lens flare system
  102592. */
  102593. getScene(): Scene;
  102594. /**
  102595. * Get the emitter of the lens flare system.
  102596. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  102597. * @returns the emitter of the lens flare system
  102598. */
  102599. getEmitter(): any;
  102600. /**
  102601. * Set the emitter of the lens flare system.
  102602. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  102603. * @param newEmitter Define the new emitter of the system
  102604. */
  102605. setEmitter(newEmitter: any): void;
  102606. /**
  102607. * Get the lens flare system emitter position.
  102608. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  102609. * @returns the position
  102610. */
  102611. getEmitterPosition(): Vector3;
  102612. /**
  102613. * @hidden
  102614. */
  102615. computeEffectivePosition(globalViewport: Viewport): boolean;
  102616. /** @hidden */
  102617. _isVisible(): boolean;
  102618. /**
  102619. * @hidden
  102620. */
  102621. render(): boolean;
  102622. /**
  102623. * Dispose and release the lens flare with its associated resources.
  102624. */
  102625. dispose(): void;
  102626. /**
  102627. * Parse a lens flare system from a JSON repressentation
  102628. * @param parsedLensFlareSystem Define the JSON to parse
  102629. * @param scene Define the scene the parsed system should be instantiated in
  102630. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  102631. * @returns the parsed system
  102632. */
  102633. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  102634. /**
  102635. * Serialize the current Lens Flare System into a JSON representation.
  102636. * @returns the serialized JSON
  102637. */
  102638. serialize(): any;
  102639. }
  102640. }
  102641. declare module BABYLON {
  102642. /**
  102643. * This represents one of the lens effect in a `lensFlareSystem`.
  102644. * It controls one of the indiviual texture used in the effect.
  102645. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102646. */
  102647. export class LensFlare {
  102648. /**
  102649. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  102650. */
  102651. size: number;
  102652. /**
  102653. * 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.
  102654. */
  102655. position: number;
  102656. /**
  102657. * Define the lens color.
  102658. */
  102659. color: Color3;
  102660. /**
  102661. * Define the lens texture.
  102662. */
  102663. texture: Nullable<Texture>;
  102664. /**
  102665. * Define the alpha mode to render this particular lens.
  102666. */
  102667. alphaMode: number;
  102668. private _system;
  102669. /**
  102670. * Creates a new Lens Flare.
  102671. * This represents one of the lens effect in a `lensFlareSystem`.
  102672. * It controls one of the indiviual texture used in the effect.
  102673. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102674. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  102675. * @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.
  102676. * @param color Define the lens color
  102677. * @param imgUrl Define the lens texture url
  102678. * @param system Define the `lensFlareSystem` this flare is part of
  102679. * @returns The newly created Lens Flare
  102680. */
  102681. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  102682. /**
  102683. * Instantiates a new Lens Flare.
  102684. * This represents one of the lens effect in a `lensFlareSystem`.
  102685. * It controls one of the indiviual texture used in the effect.
  102686. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102687. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  102688. * @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.
  102689. * @param color Define the lens color
  102690. * @param imgUrl Define the lens texture url
  102691. * @param system Define the `lensFlareSystem` this flare is part of
  102692. */
  102693. constructor(
  102694. /**
  102695. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  102696. */
  102697. size: number,
  102698. /**
  102699. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  102700. */
  102701. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  102702. /**
  102703. * Dispose and release the lens flare with its associated resources.
  102704. */
  102705. dispose(): void;
  102706. }
  102707. }
  102708. declare module BABYLON {
  102709. interface AbstractScene {
  102710. /**
  102711. * The list of lens flare system added to the scene
  102712. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102713. */
  102714. lensFlareSystems: Array<LensFlareSystem>;
  102715. /**
  102716. * Removes the given lens flare system from this scene.
  102717. * @param toRemove The lens flare system to remove
  102718. * @returns The index of the removed lens flare system
  102719. */
  102720. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  102721. /**
  102722. * Adds the given lens flare system to this scene
  102723. * @param newLensFlareSystem The lens flare system to add
  102724. */
  102725. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  102726. /**
  102727. * Gets a lens flare system using its name
  102728. * @param name defines the name to look for
  102729. * @returns the lens flare system or null if not found
  102730. */
  102731. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  102732. /**
  102733. * Gets a lens flare system using its id
  102734. * @param id defines the id to look for
  102735. * @returns the lens flare system or null if not found
  102736. */
  102737. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  102738. }
  102739. /**
  102740. * Defines the lens flare scene component responsible to manage any lens flares
  102741. * in a given scene.
  102742. */
  102743. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  102744. /**
  102745. * The component name helpfull to identify the component in the list of scene components.
  102746. */
  102747. readonly name: string;
  102748. /**
  102749. * The scene the component belongs to.
  102750. */
  102751. scene: Scene;
  102752. /**
  102753. * Creates a new instance of the component for the given scene
  102754. * @param scene Defines the scene to register the component in
  102755. */
  102756. constructor(scene: Scene);
  102757. /**
  102758. * Registers the component in a given scene
  102759. */
  102760. register(): void;
  102761. /**
  102762. * Rebuilds the elements related to this component in case of
  102763. * context lost for instance.
  102764. */
  102765. rebuild(): void;
  102766. /**
  102767. * Adds all the element from the container to the scene
  102768. * @param container the container holding the elements
  102769. */
  102770. addFromContainer(container: AbstractScene): void;
  102771. /**
  102772. * Removes all the elements in the container from the scene
  102773. * @param container contains the elements to remove
  102774. */
  102775. removeFromContainer(container: AbstractScene): void;
  102776. /**
  102777. * Serializes the component data to the specified json object
  102778. * @param serializationObject The object to serialize to
  102779. */
  102780. serialize(serializationObject: any): void;
  102781. /**
  102782. * Disposes the component and the associated ressources.
  102783. */
  102784. dispose(): void;
  102785. private _draw;
  102786. }
  102787. }
  102788. declare module BABYLON {
  102789. /**
  102790. * Defines the shadow generator component responsible to manage any shadow generators
  102791. * in a given scene.
  102792. */
  102793. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  102794. /**
  102795. * The component name helpfull to identify the component in the list of scene components.
  102796. */
  102797. readonly name: string;
  102798. /**
  102799. * The scene the component belongs to.
  102800. */
  102801. scene: Scene;
  102802. /**
  102803. * Creates a new instance of the component for the given scene
  102804. * @param scene Defines the scene to register the component in
  102805. */
  102806. constructor(scene: Scene);
  102807. /**
  102808. * Registers the component in a given scene
  102809. */
  102810. register(): void;
  102811. /**
  102812. * Rebuilds the elements related to this component in case of
  102813. * context lost for instance.
  102814. */
  102815. rebuild(): void;
  102816. /**
  102817. * Serializes the component data to the specified json object
  102818. * @param serializationObject The object to serialize to
  102819. */
  102820. serialize(serializationObject: any): void;
  102821. /**
  102822. * Adds all the element from the container to the scene
  102823. * @param container the container holding the elements
  102824. */
  102825. addFromContainer(container: AbstractScene): void;
  102826. /**
  102827. * Removes all the elements in the container from the scene
  102828. * @param container contains the elements to remove
  102829. */
  102830. removeFromContainer(container: AbstractScene): void;
  102831. /**
  102832. * Rebuilds the elements related to this component in case of
  102833. * context lost for instance.
  102834. */
  102835. dispose(): void;
  102836. private _gatherRenderTargets;
  102837. }
  102838. }
  102839. declare module BABYLON {
  102840. /**
  102841. * A directional light is defined by a direction (what a surprise!).
  102842. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102843. * 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.
  102844. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102845. */
  102846. export class DirectionalLight extends ShadowLight {
  102847. private _shadowFrustumSize;
  102848. /**
  102849. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102850. */
  102851. /**
  102852. * Specifies a fix frustum size for the shadow generation.
  102853. */
  102854. shadowFrustumSize: number;
  102855. private _shadowOrthoScale;
  102856. /**
  102857. * Gets the shadow projection scale against the optimal computed one.
  102858. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102859. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102860. */
  102861. /**
  102862. * Sets the shadow projection scale against the optimal computed one.
  102863. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102864. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102865. */
  102866. shadowOrthoScale: number;
  102867. /**
  102868. * Automatically compute the projection matrix to best fit (including all the casters)
  102869. * on each frame.
  102870. */
  102871. autoUpdateExtends: boolean;
  102872. private _orthoLeft;
  102873. private _orthoRight;
  102874. private _orthoTop;
  102875. private _orthoBottom;
  102876. /**
  102877. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102878. * The directional light is emitted from everywhere in the given direction.
  102879. * It can cast shadows.
  102880. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102881. * @param name The friendly name of the light
  102882. * @param direction The direction of the light
  102883. * @param scene The scene the light belongs to
  102884. */
  102885. constructor(name: string, direction: Vector3, scene: Scene);
  102886. /**
  102887. * Returns the string "DirectionalLight".
  102888. * @return The class name
  102889. */
  102890. getClassName(): string;
  102891. /**
  102892. * Returns the integer 1.
  102893. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102894. */
  102895. getTypeID(): number;
  102896. /**
  102897. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102898. * Returns the DirectionalLight Shadow projection matrix.
  102899. */
  102900. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102901. /**
  102902. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102903. * Returns the DirectionalLight Shadow projection matrix.
  102904. */
  102905. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102906. /**
  102907. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102908. * Returns the DirectionalLight Shadow projection matrix.
  102909. */
  102910. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102911. protected _buildUniformLayout(): void;
  102912. /**
  102913. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102914. * @param effect The effect to update
  102915. * @param lightIndex The index of the light in the effect to update
  102916. * @returns The directional light
  102917. */
  102918. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102919. /**
  102920. * Gets the minZ used for shadow according to both the scene and the light.
  102921. *
  102922. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102923. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102924. * @param activeCamera The camera we are returning the min for
  102925. * @returns the depth min z
  102926. */
  102927. getDepthMinZ(activeCamera: Camera): number;
  102928. /**
  102929. * Gets the maxZ used for shadow according to both the scene and the light.
  102930. *
  102931. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102932. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102933. * @param activeCamera The camera we are returning the max for
  102934. * @returns the depth max z
  102935. */
  102936. getDepthMaxZ(activeCamera: Camera): number;
  102937. /**
  102938. * Prepares the list of defines specific to the light type.
  102939. * @param defines the list of defines
  102940. * @param lightIndex defines the index of the light for the effect
  102941. */
  102942. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102943. }
  102944. }
  102945. declare module BABYLON {
  102946. /**
  102947. * A point light is a light defined by an unique point in world space.
  102948. * The light is emitted in every direction from this point.
  102949. * A good example of a point light is a standard light bulb.
  102950. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102951. */
  102952. export class PointLight extends ShadowLight {
  102953. private _shadowAngle;
  102954. /**
  102955. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102956. * This specifies what angle the shadow will use to be created.
  102957. *
  102958. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  102959. */
  102960. /**
  102961. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102962. * This specifies what angle the shadow will use to be created.
  102963. *
  102964. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  102965. */
  102966. shadowAngle: number;
  102967. /**
  102968. * Gets the direction if it has been set.
  102969. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102970. */
  102971. /**
  102972. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102973. */
  102974. direction: Vector3;
  102975. /**
  102976. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  102977. * A PointLight emits the light in every direction.
  102978. * It can cast shadows.
  102979. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  102980. * ```javascript
  102981. * var pointLight = new PointLight("pl", camera.position, scene);
  102982. * ```
  102983. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102984. * @param name The light friendly name
  102985. * @param position The position of the point light in the scene
  102986. * @param scene The scene the lights belongs to
  102987. */
  102988. constructor(name: string, position: Vector3, scene: Scene);
  102989. /**
  102990. * Returns the string "PointLight"
  102991. * @returns the class name
  102992. */
  102993. getClassName(): string;
  102994. /**
  102995. * Returns the integer 0.
  102996. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102997. */
  102998. getTypeID(): number;
  102999. /**
  103000. * Specifies wether or not the shadowmap should be a cube texture.
  103001. * @returns true if the shadowmap needs to be a cube texture.
  103002. */
  103003. needCube(): boolean;
  103004. /**
  103005. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  103006. * @param faceIndex The index of the face we are computed the direction to generate shadow
  103007. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  103008. */
  103009. getShadowDirection(faceIndex?: number): Vector3;
  103010. /**
  103011. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  103012. * - fov = PI / 2
  103013. * - aspect ratio : 1.0
  103014. * - z-near and far equal to the active camera minZ and maxZ.
  103015. * Returns the PointLight.
  103016. */
  103017. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103018. protected _buildUniformLayout(): void;
  103019. /**
  103020. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  103021. * @param effect The effect to update
  103022. * @param lightIndex The index of the light in the effect to update
  103023. * @returns The point light
  103024. */
  103025. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  103026. /**
  103027. * Prepares the list of defines specific to the light type.
  103028. * @param defines the list of defines
  103029. * @param lightIndex defines the index of the light for the effect
  103030. */
  103031. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103032. }
  103033. }
  103034. declare module BABYLON {
  103035. /**
  103036. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103037. * These values define a cone of light starting from the position, emitting toward the direction.
  103038. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103039. * and the exponent defines the speed of the decay of the light with distance (reach).
  103040. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103041. */
  103042. export class SpotLight extends ShadowLight {
  103043. private _angle;
  103044. private _innerAngle;
  103045. private _cosHalfAngle;
  103046. private _lightAngleScale;
  103047. private _lightAngleOffset;
  103048. /**
  103049. * Gets the cone angle of the spot light in Radians.
  103050. */
  103051. /**
  103052. * Sets the cone angle of the spot light in Radians.
  103053. */
  103054. angle: number;
  103055. /**
  103056. * Only used in gltf falloff mode, this defines the angle where
  103057. * the directional falloff will start before cutting at angle which could be seen
  103058. * as outer angle.
  103059. */
  103060. /**
  103061. * Only used in gltf falloff mode, this defines the angle where
  103062. * the directional falloff will start before cutting at angle which could be seen
  103063. * as outer angle.
  103064. */
  103065. innerAngle: number;
  103066. private _shadowAngleScale;
  103067. /**
  103068. * Allows scaling the angle of the light for shadow generation only.
  103069. */
  103070. /**
  103071. * Allows scaling the angle of the light for shadow generation only.
  103072. */
  103073. shadowAngleScale: number;
  103074. /**
  103075. * The light decay speed with the distance from the emission spot.
  103076. */
  103077. exponent: number;
  103078. private _projectionTextureMatrix;
  103079. /**
  103080. * Allows reading the projecton texture
  103081. */
  103082. readonly projectionTextureMatrix: Matrix;
  103083. protected _projectionTextureLightNear: number;
  103084. /**
  103085. * Gets the near clip of the Spotlight for texture projection.
  103086. */
  103087. /**
  103088. * Sets the near clip of the Spotlight for texture projection.
  103089. */
  103090. projectionTextureLightNear: number;
  103091. protected _projectionTextureLightFar: number;
  103092. /**
  103093. * Gets the far clip of the Spotlight for texture projection.
  103094. */
  103095. /**
  103096. * Sets the far clip of the Spotlight for texture projection.
  103097. */
  103098. projectionTextureLightFar: number;
  103099. protected _projectionTextureUpDirection: Vector3;
  103100. /**
  103101. * Gets the Up vector of the Spotlight for texture projection.
  103102. */
  103103. /**
  103104. * Sets the Up vector of the Spotlight for texture projection.
  103105. */
  103106. projectionTextureUpDirection: Vector3;
  103107. private _projectionTexture;
  103108. /**
  103109. * Gets the projection texture of the light.
  103110. */
  103111. /**
  103112. * Sets the projection texture of the light.
  103113. */
  103114. projectionTexture: Nullable<BaseTexture>;
  103115. private _projectionTextureViewLightDirty;
  103116. private _projectionTextureProjectionLightDirty;
  103117. private _projectionTextureDirty;
  103118. private _projectionTextureViewTargetVector;
  103119. private _projectionTextureViewLightMatrix;
  103120. private _projectionTextureProjectionLightMatrix;
  103121. private _projectionTextureScalingMatrix;
  103122. /**
  103123. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103124. * It can cast shadows.
  103125. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103126. * @param name The light friendly name
  103127. * @param position The position of the spot light in the scene
  103128. * @param direction The direction of the light in the scene
  103129. * @param angle The cone angle of the light in Radians
  103130. * @param exponent The light decay speed with the distance from the emission spot
  103131. * @param scene The scene the lights belongs to
  103132. */
  103133. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103134. /**
  103135. * Returns the string "SpotLight".
  103136. * @returns the class name
  103137. */
  103138. getClassName(): string;
  103139. /**
  103140. * Returns the integer 2.
  103141. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103142. */
  103143. getTypeID(): number;
  103144. /**
  103145. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103146. */
  103147. protected _setDirection(value: Vector3): void;
  103148. /**
  103149. * Overrides the position setter to recompute the projection texture view light Matrix.
  103150. */
  103151. protected _setPosition(value: Vector3): void;
  103152. /**
  103153. * 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.
  103154. * Returns the SpotLight.
  103155. */
  103156. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103157. protected _computeProjectionTextureViewLightMatrix(): void;
  103158. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103159. /**
  103160. * Main function for light texture projection matrix computing.
  103161. */
  103162. protected _computeProjectionTextureMatrix(): void;
  103163. protected _buildUniformLayout(): void;
  103164. private _computeAngleValues;
  103165. /**
  103166. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103167. * @param effect The effect to update
  103168. * @param lightIndex The index of the light in the effect to update
  103169. * @returns The spot light
  103170. */
  103171. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103172. /**
  103173. * Disposes the light and the associated resources.
  103174. */
  103175. dispose(): void;
  103176. /**
  103177. * Prepares the list of defines specific to the light type.
  103178. * @param defines the list of defines
  103179. * @param lightIndex defines the index of the light for the effect
  103180. */
  103181. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103182. }
  103183. }
  103184. declare module BABYLON {
  103185. /**
  103186. * Header information of HDR texture files.
  103187. */
  103188. export interface HDRInfo {
  103189. /**
  103190. * The height of the texture in pixels.
  103191. */
  103192. height: number;
  103193. /**
  103194. * The width of the texture in pixels.
  103195. */
  103196. width: number;
  103197. /**
  103198. * The index of the beginning of the data in the binary file.
  103199. */
  103200. dataPosition: number;
  103201. }
  103202. /**
  103203. * This groups tools to convert HDR texture to native colors array.
  103204. */
  103205. export class HDRTools {
  103206. private static Ldexp;
  103207. private static Rgbe2float;
  103208. private static readStringLine;
  103209. /**
  103210. * Reads header information from an RGBE texture stored in a native array.
  103211. * More information on this format are available here:
  103212. * https://en.wikipedia.org/wiki/RGBE_image_format
  103213. *
  103214. * @param uint8array The binary file stored in native array.
  103215. * @return The header information.
  103216. */
  103217. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  103218. /**
  103219. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  103220. * This RGBE texture needs to store the information as a panorama.
  103221. *
  103222. * More information on this format are available here:
  103223. * https://en.wikipedia.org/wiki/RGBE_image_format
  103224. *
  103225. * @param buffer The binary file stored in an array buffer.
  103226. * @param size The expected size of the extracted cubemap.
  103227. * @return The Cube Map information.
  103228. */
  103229. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  103230. /**
  103231. * Returns the pixels data extracted from an RGBE texture.
  103232. * This pixels will be stored left to right up to down in the R G B order in one array.
  103233. *
  103234. * More information on this format are available here:
  103235. * https://en.wikipedia.org/wiki/RGBE_image_format
  103236. *
  103237. * @param uint8array The binary file stored in an array buffer.
  103238. * @param hdrInfo The header information of the file.
  103239. * @return The pixels data in RGB right to left up to down order.
  103240. */
  103241. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  103242. private static RGBE_ReadPixels_RLE;
  103243. }
  103244. }
  103245. declare module BABYLON {
  103246. /**
  103247. * This represents a texture coming from an HDR input.
  103248. *
  103249. * The only supported format is currently panorama picture stored in RGBE format.
  103250. * Example of such files can be found on HDRLib: http://hdrlib.com/
  103251. */
  103252. export class HDRCubeTexture extends BaseTexture {
  103253. private static _facesMapping;
  103254. private _generateHarmonics;
  103255. private _noMipmap;
  103256. private _textureMatrix;
  103257. private _size;
  103258. private _onLoad;
  103259. private _onError;
  103260. /**
  103261. * The texture URL.
  103262. */
  103263. url: string;
  103264. /**
  103265. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  103266. */
  103267. coordinatesMode: number;
  103268. protected _isBlocking: boolean;
  103269. /**
  103270. * Sets wether or not the texture is blocking during loading.
  103271. */
  103272. /**
  103273. * Gets wether or not the texture is blocking during loading.
  103274. */
  103275. isBlocking: boolean;
  103276. protected _rotationY: number;
  103277. /**
  103278. * Sets texture matrix rotation angle around Y axis in radians.
  103279. */
  103280. /**
  103281. * Gets texture matrix rotation angle around Y axis radians.
  103282. */
  103283. rotationY: number;
  103284. /**
  103285. * Gets or sets the center of the bounding box associated with the cube texture
  103286. * It must define where the camera used to render the texture was set
  103287. */
  103288. boundingBoxPosition: Vector3;
  103289. private _boundingBoxSize;
  103290. /**
  103291. * Gets or sets the size of the bounding box associated with the cube texture
  103292. * When defined, the cubemap will switch to local mode
  103293. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103294. * @example https://www.babylonjs-playground.com/#RNASML
  103295. */
  103296. boundingBoxSize: Vector3;
  103297. /**
  103298. * Instantiates an HDRTexture from the following parameters.
  103299. *
  103300. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  103301. * @param scene The scene the texture will be used in
  103302. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  103303. * @param noMipmap Forces to not generate the mipmap if true
  103304. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  103305. * @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)
  103306. * @param reserved Reserved flag for internal use.
  103307. */
  103308. 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>);
  103309. /**
  103310. * Get the current class name of the texture useful for serialization or dynamic coding.
  103311. * @returns "HDRCubeTexture"
  103312. */
  103313. getClassName(): string;
  103314. /**
  103315. * Occurs when the file is raw .hdr file.
  103316. */
  103317. private loadTexture;
  103318. clone(): HDRCubeTexture;
  103319. delayLoad(): void;
  103320. /**
  103321. * Get the texture reflection matrix used to rotate/transform the reflection.
  103322. * @returns the reflection matrix
  103323. */
  103324. getReflectionTextureMatrix(): Matrix;
  103325. /**
  103326. * Set the texture reflection matrix used to rotate/transform the reflection.
  103327. * @param value Define the reflection matrix to set
  103328. */
  103329. setReflectionTextureMatrix(value: Matrix): void;
  103330. /**
  103331. * Parses a JSON representation of an HDR Texture in order to create the texture
  103332. * @param parsedTexture Define the JSON representation
  103333. * @param scene Define the scene the texture should be created in
  103334. * @param rootUrl Define the root url in case we need to load relative dependencies
  103335. * @returns the newly created texture after parsing
  103336. */
  103337. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  103338. serialize(): any;
  103339. }
  103340. }
  103341. declare module BABYLON {
  103342. /**
  103343. * Class used to control physics engine
  103344. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103345. */
  103346. export class PhysicsEngine implements IPhysicsEngine {
  103347. private _physicsPlugin;
  103348. /**
  103349. * Global value used to control the smallest number supported by the simulation
  103350. */
  103351. static Epsilon: number;
  103352. private _impostors;
  103353. private _joints;
  103354. /**
  103355. * Gets the gravity vector used by the simulation
  103356. */
  103357. gravity: Vector3;
  103358. /**
  103359. * Factory used to create the default physics plugin.
  103360. * @returns The default physics plugin
  103361. */
  103362. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  103363. /**
  103364. * Creates a new Physics Engine
  103365. * @param gravity defines the gravity vector used by the simulation
  103366. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  103367. */
  103368. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  103369. /**
  103370. * Sets the gravity vector used by the simulation
  103371. * @param gravity defines the gravity vector to use
  103372. */
  103373. setGravity(gravity: Vector3): void;
  103374. /**
  103375. * Set the time step of the physics engine.
  103376. * Default is 1/60.
  103377. * To slow it down, enter 1/600 for example.
  103378. * To speed it up, 1/30
  103379. * @param newTimeStep defines the new timestep to apply to this world.
  103380. */
  103381. setTimeStep(newTimeStep?: number): void;
  103382. /**
  103383. * Get the time step of the physics engine.
  103384. * @returns the current time step
  103385. */
  103386. getTimeStep(): number;
  103387. /**
  103388. * Release all resources
  103389. */
  103390. dispose(): void;
  103391. /**
  103392. * Gets the name of the current physics plugin
  103393. * @returns the name of the plugin
  103394. */
  103395. getPhysicsPluginName(): string;
  103396. /**
  103397. * Adding a new impostor for the impostor tracking.
  103398. * This will be done by the impostor itself.
  103399. * @param impostor the impostor to add
  103400. */
  103401. addImpostor(impostor: PhysicsImpostor): void;
  103402. /**
  103403. * Remove an impostor from the engine.
  103404. * This impostor and its mesh will not longer be updated by the physics engine.
  103405. * @param impostor the impostor to remove
  103406. */
  103407. removeImpostor(impostor: PhysicsImpostor): void;
  103408. /**
  103409. * Add a joint to the physics engine
  103410. * @param mainImpostor defines the main impostor to which the joint is added.
  103411. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  103412. * @param joint defines the joint that will connect both impostors.
  103413. */
  103414. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103415. /**
  103416. * Removes a joint from the simulation
  103417. * @param mainImpostor defines the impostor used with the joint
  103418. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  103419. * @param joint defines the joint to remove
  103420. */
  103421. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103422. /**
  103423. * Called by the scene. No need to call it.
  103424. * @param delta defines the timespam between frames
  103425. */
  103426. _step(delta: number): void;
  103427. /**
  103428. * Gets the current plugin used to run the simulation
  103429. * @returns current plugin
  103430. */
  103431. getPhysicsPlugin(): IPhysicsEnginePlugin;
  103432. /**
  103433. * Gets the list of physic impostors
  103434. * @returns an array of PhysicsImpostor
  103435. */
  103436. getImpostors(): Array<PhysicsImpostor>;
  103437. /**
  103438. * Gets the impostor for a physics enabled object
  103439. * @param object defines the object impersonated by the impostor
  103440. * @returns the PhysicsImpostor or null if not found
  103441. */
  103442. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103443. /**
  103444. * Gets the impostor for a physics body object
  103445. * @param body defines physics body used by the impostor
  103446. * @returns the PhysicsImpostor or null if not found
  103447. */
  103448. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  103449. }
  103450. }
  103451. declare module BABYLON {
  103452. /** @hidden */
  103453. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  103454. private _useDeltaForWorldStep;
  103455. world: any;
  103456. name: string;
  103457. private _physicsMaterials;
  103458. private _fixedTimeStep;
  103459. BJSCANNON: any;
  103460. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  103461. setGravity(gravity: Vector3): void;
  103462. setTimeStep(timeStep: number): void;
  103463. getTimeStep(): number;
  103464. executeStep(delta: number): void;
  103465. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103466. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103467. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103468. private _processChildMeshes;
  103469. removePhysicsBody(impostor: PhysicsImpostor): void;
  103470. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  103471. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  103472. private _addMaterial;
  103473. private _checkWithEpsilon;
  103474. private _createShape;
  103475. private _createHeightmap;
  103476. private _minus90X;
  103477. private _plus90X;
  103478. private _tmpPosition;
  103479. private _tmpDeltaPosition;
  103480. private _tmpUnityRotation;
  103481. private _updatePhysicsBodyTransformation;
  103482. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103483. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103484. isSupported(): boolean;
  103485. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103486. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103487. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103488. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103489. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103490. getBodyMass(impostor: PhysicsImpostor): number;
  103491. getBodyFriction(impostor: PhysicsImpostor): number;
  103492. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103493. getBodyRestitution(impostor: PhysicsImpostor): number;
  103494. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103495. sleepBody(impostor: PhysicsImpostor): void;
  103496. wakeUpBody(impostor: PhysicsImpostor): void;
  103497. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  103498. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  103499. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  103500. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103501. getRadius(impostor: PhysicsImpostor): number;
  103502. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103503. dispose(): void;
  103504. private _extendNamespace;
  103505. }
  103506. }
  103507. declare module BABYLON {
  103508. /** @hidden */
  103509. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  103510. world: any;
  103511. name: string;
  103512. BJSOIMO: any;
  103513. constructor(iterations?: number, oimoInjection?: any);
  103514. setGravity(gravity: Vector3): void;
  103515. setTimeStep(timeStep: number): void;
  103516. getTimeStep(): number;
  103517. private _tmpImpostorsArray;
  103518. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  103519. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103520. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103521. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103522. private _tmpPositionVector;
  103523. removePhysicsBody(impostor: PhysicsImpostor): void;
  103524. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  103525. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  103526. isSupported(): boolean;
  103527. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103528. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103529. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103530. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103531. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103532. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103533. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103534. getBodyMass(impostor: PhysicsImpostor): number;
  103535. getBodyFriction(impostor: PhysicsImpostor): number;
  103536. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103537. getBodyRestitution(impostor: PhysicsImpostor): number;
  103538. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103539. sleepBody(impostor: PhysicsImpostor): void;
  103540. wakeUpBody(impostor: PhysicsImpostor): void;
  103541. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  103542. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  103543. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103544. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103545. getRadius(impostor: PhysicsImpostor): number;
  103546. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103547. dispose(): void;
  103548. }
  103549. }
  103550. declare module BABYLON {
  103551. interface AbstractScene {
  103552. /**
  103553. * The list of reflection probes added to the scene
  103554. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  103555. */
  103556. reflectionProbes: Array<ReflectionProbe>;
  103557. /**
  103558. * Removes the given reflection probe from this scene.
  103559. * @param toRemove The reflection probe to remove
  103560. * @returns The index of the removed reflection probe
  103561. */
  103562. removeReflectionProbe(toRemove: ReflectionProbe): number;
  103563. /**
  103564. * Adds the given reflection probe to this scene.
  103565. * @param newReflectionProbe The reflection probe to add
  103566. */
  103567. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  103568. }
  103569. /**
  103570. * Class used to generate realtime reflection / refraction cube textures
  103571. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  103572. */
  103573. export class ReflectionProbe {
  103574. /** defines the name of the probe */
  103575. name: string;
  103576. private _scene;
  103577. private _renderTargetTexture;
  103578. private _projectionMatrix;
  103579. private _viewMatrix;
  103580. private _target;
  103581. private _add;
  103582. private _attachedMesh;
  103583. private _invertYAxis;
  103584. /** Gets or sets probe position (center of the cube map) */
  103585. position: Vector3;
  103586. /**
  103587. * Creates a new reflection probe
  103588. * @param name defines the name of the probe
  103589. * @param size defines the texture resolution (for each face)
  103590. * @param scene defines the hosting scene
  103591. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  103592. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  103593. */
  103594. constructor(
  103595. /** defines the name of the probe */
  103596. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  103597. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  103598. samples: number;
  103599. /** Gets or sets the refresh rate to use (on every frame by default) */
  103600. refreshRate: number;
  103601. /**
  103602. * Gets the hosting scene
  103603. * @returns a Scene
  103604. */
  103605. getScene(): Scene;
  103606. /** Gets the internal CubeTexture used to render to */
  103607. readonly cubeTexture: RenderTargetTexture;
  103608. /** Gets the list of meshes to render */
  103609. readonly renderList: Nullable<AbstractMesh[]>;
  103610. /**
  103611. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  103612. * @param mesh defines the mesh to attach to
  103613. */
  103614. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  103615. /**
  103616. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  103617. * @param renderingGroupId The rendering group id corresponding to its index
  103618. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103619. */
  103620. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103621. /**
  103622. * Clean all associated resources
  103623. */
  103624. dispose(): void;
  103625. /**
  103626. * Converts the reflection probe information to a readable string for debug purpose.
  103627. * @param fullDetails Supports for multiple levels of logging within scene loading
  103628. * @returns the human readable reflection probe info
  103629. */
  103630. toString(fullDetails?: boolean): string;
  103631. /**
  103632. * Get the class name of the relfection probe.
  103633. * @returns "ReflectionProbe"
  103634. */
  103635. getClassName(): string;
  103636. /**
  103637. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  103638. * @returns The JSON representation of the texture
  103639. */
  103640. serialize(): any;
  103641. /**
  103642. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  103643. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  103644. * @param scene Define the scene the parsed reflection probe should be instantiated in
  103645. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103646. * @returns The parsed reflection probe if successful
  103647. */
  103648. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  103649. }
  103650. }
  103651. declare module BABYLON {
  103652. /** @hidden */
  103653. export var _BabylonLoaderRegistered: boolean;
  103654. }
  103655. declare module BABYLON {
  103656. /**
  103657. * The Physically based simple base material of BJS.
  103658. *
  103659. * This enables better naming and convention enforcements on top of the pbrMaterial.
  103660. * It is used as the base class for both the specGloss and metalRough conventions.
  103661. */
  103662. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  103663. /**
  103664. * Number of Simultaneous lights allowed on the material.
  103665. */
  103666. maxSimultaneousLights: number;
  103667. /**
  103668. * If sets to true, disables all the lights affecting the material.
  103669. */
  103670. disableLighting: boolean;
  103671. /**
  103672. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  103673. */
  103674. environmentTexture: BaseTexture;
  103675. /**
  103676. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103677. */
  103678. invertNormalMapX: boolean;
  103679. /**
  103680. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103681. */
  103682. invertNormalMapY: boolean;
  103683. /**
  103684. * Normal map used in the model.
  103685. */
  103686. normalTexture: BaseTexture;
  103687. /**
  103688. * Emissivie color used to self-illuminate the model.
  103689. */
  103690. emissiveColor: Color3;
  103691. /**
  103692. * Emissivie texture used to self-illuminate the model.
  103693. */
  103694. emissiveTexture: BaseTexture;
  103695. /**
  103696. * Occlusion Channel Strenght.
  103697. */
  103698. occlusionStrength: number;
  103699. /**
  103700. * Occlusion Texture of the material (adding extra occlusion effects).
  103701. */
  103702. occlusionTexture: BaseTexture;
  103703. /**
  103704. * Defines the alpha limits in alpha test mode.
  103705. */
  103706. alphaCutOff: number;
  103707. /**
  103708. * Gets the current double sided mode.
  103709. */
  103710. /**
  103711. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103712. */
  103713. doubleSided: boolean;
  103714. /**
  103715. * Stores the pre-calculated light information of a mesh in a texture.
  103716. */
  103717. lightmapTexture: BaseTexture;
  103718. /**
  103719. * If true, the light map contains occlusion information instead of lighting info.
  103720. */
  103721. useLightmapAsShadowmap: boolean;
  103722. /**
  103723. * Instantiates a new PBRMaterial instance.
  103724. *
  103725. * @param name The material name
  103726. * @param scene The scene the material will be use in.
  103727. */
  103728. constructor(name: string, scene: Scene);
  103729. getClassName(): string;
  103730. }
  103731. }
  103732. declare module BABYLON {
  103733. /**
  103734. * The PBR material of BJS following the metal roughness convention.
  103735. *
  103736. * This fits to the PBR convention in the GLTF definition:
  103737. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  103738. */
  103739. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  103740. /**
  103741. * The base color has two different interpretations depending on the value of metalness.
  103742. * When the material is a metal, the base color is the specific measured reflectance value
  103743. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  103744. * of the material.
  103745. */
  103746. baseColor: Color3;
  103747. /**
  103748. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  103749. * well as opacity information in the alpha channel.
  103750. */
  103751. baseTexture: BaseTexture;
  103752. /**
  103753. * Specifies the metallic scalar value of the material.
  103754. * Can also be used to scale the metalness values of the metallic texture.
  103755. */
  103756. metallic: number;
  103757. /**
  103758. * Specifies the roughness scalar value of the material.
  103759. * Can also be used to scale the roughness values of the metallic texture.
  103760. */
  103761. roughness: number;
  103762. /**
  103763. * Texture containing both the metallic value in the B channel and the
  103764. * roughness value in the G channel to keep better precision.
  103765. */
  103766. metallicRoughnessTexture: BaseTexture;
  103767. /**
  103768. * Instantiates a new PBRMetalRoughnessMaterial instance.
  103769. *
  103770. * @param name The material name
  103771. * @param scene The scene the material will be use in.
  103772. */
  103773. constructor(name: string, scene: Scene);
  103774. /**
  103775. * Return the currrent class name of the material.
  103776. */
  103777. getClassName(): string;
  103778. /**
  103779. * Makes a duplicate of the current material.
  103780. * @param name - name to use for the new material.
  103781. */
  103782. clone(name: string): PBRMetallicRoughnessMaterial;
  103783. /**
  103784. * Serialize the material to a parsable JSON object.
  103785. */
  103786. serialize(): any;
  103787. /**
  103788. * Parses a JSON object correponding to the serialize function.
  103789. */
  103790. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  103791. }
  103792. }
  103793. declare module BABYLON {
  103794. /**
  103795. * The PBR material of BJS following the specular glossiness convention.
  103796. *
  103797. * This fits to the PBR convention in the GLTF definition:
  103798. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  103799. */
  103800. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  103801. /**
  103802. * Specifies the diffuse color of the material.
  103803. */
  103804. diffuseColor: Color3;
  103805. /**
  103806. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  103807. * channel.
  103808. */
  103809. diffuseTexture: BaseTexture;
  103810. /**
  103811. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  103812. */
  103813. specularColor: Color3;
  103814. /**
  103815. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  103816. */
  103817. glossiness: number;
  103818. /**
  103819. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  103820. */
  103821. specularGlossinessTexture: BaseTexture;
  103822. /**
  103823. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  103824. *
  103825. * @param name The material name
  103826. * @param scene The scene the material will be use in.
  103827. */
  103828. constructor(name: string, scene: Scene);
  103829. /**
  103830. * Return the currrent class name of the material.
  103831. */
  103832. getClassName(): string;
  103833. /**
  103834. * Makes a duplicate of the current material.
  103835. * @param name - name to use for the new material.
  103836. */
  103837. clone(name: string): PBRSpecularGlossinessMaterial;
  103838. /**
  103839. * Serialize the material to a parsable JSON object.
  103840. */
  103841. serialize(): any;
  103842. /**
  103843. * Parses a JSON object correponding to the serialize function.
  103844. */
  103845. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  103846. }
  103847. }
  103848. declare module BABYLON {
  103849. /**
  103850. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  103851. * It can help converting any input color in a desired output one. This can then be used to create effects
  103852. * from sepia, black and white to sixties or futuristic rendering...
  103853. *
  103854. * The only supported format is currently 3dl.
  103855. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  103856. */
  103857. export class ColorGradingTexture extends BaseTexture {
  103858. /**
  103859. * The current texture matrix. (will always be identity in color grading texture)
  103860. */
  103861. private _textureMatrix;
  103862. /**
  103863. * The texture URL.
  103864. */
  103865. url: string;
  103866. /**
  103867. * Empty line regex stored for GC.
  103868. */
  103869. private static _noneEmptyLineRegex;
  103870. private _engine;
  103871. /**
  103872. * Instantiates a ColorGradingTexture from the following parameters.
  103873. *
  103874. * @param url The location of the color gradind data (currently only supporting 3dl)
  103875. * @param scene The scene the texture will be used in
  103876. */
  103877. constructor(url: string, scene: Scene);
  103878. /**
  103879. * Returns the texture matrix used in most of the material.
  103880. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  103881. */
  103882. getTextureMatrix(): Matrix;
  103883. /**
  103884. * Occurs when the file being loaded is a .3dl LUT file.
  103885. */
  103886. private load3dlTexture;
  103887. /**
  103888. * Starts the loading process of the texture.
  103889. */
  103890. private loadTexture;
  103891. /**
  103892. * Clones the color gradind texture.
  103893. */
  103894. clone(): ColorGradingTexture;
  103895. /**
  103896. * Called during delayed load for textures.
  103897. */
  103898. delayLoad(): void;
  103899. /**
  103900. * Parses a color grading texture serialized by Babylon.
  103901. * @param parsedTexture The texture information being parsedTexture
  103902. * @param scene The scene to load the texture in
  103903. * @param rootUrl The root url of the data assets to load
  103904. * @return A color gradind texture
  103905. */
  103906. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  103907. /**
  103908. * Serializes the LUT texture to json format.
  103909. */
  103910. serialize(): any;
  103911. }
  103912. }
  103913. declare module BABYLON {
  103914. /**
  103915. * Direct draw surface info
  103916. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  103917. */
  103918. export interface DDSInfo {
  103919. /**
  103920. * Width of the texture
  103921. */
  103922. width: number;
  103923. /**
  103924. * Width of the texture
  103925. */
  103926. height: number;
  103927. /**
  103928. * Number of Mipmaps for the texture
  103929. * @see https://en.wikipedia.org/wiki/Mipmap
  103930. */
  103931. mipmapCount: number;
  103932. /**
  103933. * If the textures format is a known fourCC format
  103934. * @see https://www.fourcc.org/
  103935. */
  103936. isFourCC: boolean;
  103937. /**
  103938. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103939. */
  103940. isRGB: boolean;
  103941. /**
  103942. * If the texture is a lumincance format
  103943. */
  103944. isLuminance: boolean;
  103945. /**
  103946. * If this is a cube texture
  103947. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  103948. */
  103949. isCube: boolean;
  103950. /**
  103951. * If the texture is a compressed format eg. FOURCC_DXT1
  103952. */
  103953. isCompressed: boolean;
  103954. /**
  103955. * The dxgiFormat of the texture
  103956. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  103957. */
  103958. dxgiFormat: number;
  103959. /**
  103960. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  103961. */
  103962. textureType: number;
  103963. /**
  103964. * Sphericle polynomial created for the dds texture
  103965. */
  103966. sphericalPolynomial?: SphericalPolynomial;
  103967. }
  103968. /**
  103969. * Class used to provide DDS decompression tools
  103970. */
  103971. export class DDSTools {
  103972. /**
  103973. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  103974. */
  103975. static StoreLODInAlphaChannel: boolean;
  103976. /**
  103977. * Gets DDS information from an array buffer
  103978. * @param arrayBuffer defines the array buffer to read data from
  103979. * @returns the DDS information
  103980. */
  103981. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  103982. private static _FloatView;
  103983. private static _Int32View;
  103984. private static _ToHalfFloat;
  103985. private static _FromHalfFloat;
  103986. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  103987. private static _GetHalfFloatRGBAArrayBuffer;
  103988. private static _GetFloatRGBAArrayBuffer;
  103989. private static _GetFloatAsUIntRGBAArrayBuffer;
  103990. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  103991. private static _GetRGBAArrayBuffer;
  103992. private static _ExtractLongWordOrder;
  103993. private static _GetRGBArrayBuffer;
  103994. private static _GetLuminanceArrayBuffer;
  103995. /**
  103996. * Uploads DDS Levels to a Babylon Texture
  103997. * @hidden
  103998. */
  103999. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  104000. }
  104001. interface Engine {
  104002. /**
  104003. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  104004. * @param rootUrl defines the url where the file to load is located
  104005. * @param scene defines the current scene
  104006. * @param lodScale defines scale to apply to the mip map selection
  104007. * @param lodOffset defines offset to apply to the mip map selection
  104008. * @param onLoad defines an optional callback raised when the texture is loaded
  104009. * @param onError defines an optional callback raised if there is an issue to load the texture
  104010. * @param format defines the format of the data
  104011. * @param forcedExtension defines the extension to use to pick the right loader
  104012. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  104013. * @returns the cube texture as an InternalTexture
  104014. */
  104015. 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;
  104016. }
  104017. }
  104018. declare module BABYLON {
  104019. /**
  104020. * Implementation of the DDS Texture Loader.
  104021. * @hidden
  104022. */
  104023. export class _DDSTextureLoader implements IInternalTextureLoader {
  104024. /**
  104025. * Defines wether the loader supports cascade loading the different faces.
  104026. */
  104027. readonly supportCascades: boolean;
  104028. /**
  104029. * This returns if the loader support the current file information.
  104030. * @param extension defines the file extension of the file being loaded
  104031. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104032. * @param fallback defines the fallback internal texture if any
  104033. * @param isBase64 defines whether the texture is encoded as a base64
  104034. * @param isBuffer defines whether the texture data are stored as a buffer
  104035. * @returns true if the loader can load the specified file
  104036. */
  104037. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104038. /**
  104039. * Transform the url before loading if required.
  104040. * @param rootUrl the url of the texture
  104041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104042. * @returns the transformed texture
  104043. */
  104044. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104045. /**
  104046. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104047. * @param rootUrl the url of the texture
  104048. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104049. * @returns the fallback texture
  104050. */
  104051. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104052. /**
  104053. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104054. * @param data contains the texture data
  104055. * @param texture defines the BabylonJS internal texture
  104056. * @param createPolynomials will be true if polynomials have been requested
  104057. * @param onLoad defines the callback to trigger once the texture is ready
  104058. * @param onError defines the callback to trigger in case of error
  104059. */
  104060. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104061. /**
  104062. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104063. * @param data contains the texture data
  104064. * @param texture defines the BabylonJS internal texture
  104065. * @param callback defines the method to call once ready to upload
  104066. */
  104067. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104068. }
  104069. }
  104070. declare module BABYLON {
  104071. /** @hidden */
  104072. export var rgbdEncodePixelShader: {
  104073. name: string;
  104074. shader: string;
  104075. };
  104076. }
  104077. declare module BABYLON {
  104078. /** @hidden */
  104079. export var rgbdDecodePixelShader: {
  104080. name: string;
  104081. shader: string;
  104082. };
  104083. }
  104084. declare module BABYLON {
  104085. /**
  104086. * Raw texture data and descriptor sufficient for WebGL texture upload
  104087. */
  104088. export interface EnvironmentTextureInfo {
  104089. /**
  104090. * Version of the environment map
  104091. */
  104092. version: number;
  104093. /**
  104094. * Width of image
  104095. */
  104096. width: number;
  104097. /**
  104098. * Irradiance information stored in the file.
  104099. */
  104100. irradiance: any;
  104101. /**
  104102. * Specular information stored in the file.
  104103. */
  104104. specular: any;
  104105. }
  104106. /**
  104107. * Sets of helpers addressing the serialization and deserialization of environment texture
  104108. * stored in a BabylonJS env file.
  104109. * Those files are usually stored as .env files.
  104110. */
  104111. export class EnvironmentTextureTools {
  104112. /**
  104113. * Magic number identifying the env file.
  104114. */
  104115. private static _MagicBytes;
  104116. /**
  104117. * Gets the environment info from an env file.
  104118. * @param data The array buffer containing the .env bytes.
  104119. * @returns the environment file info (the json header) if successfully parsed.
  104120. */
  104121. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  104122. /**
  104123. * Creates an environment texture from a loaded cube texture.
  104124. * @param texture defines the cube texture to convert in env file
  104125. * @return a promise containing the environment data if succesfull.
  104126. */
  104127. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  104128. /**
  104129. * Creates a JSON representation of the spherical data.
  104130. * @param texture defines the texture containing the polynomials
  104131. * @return the JSON representation of the spherical info
  104132. */
  104133. private static _CreateEnvTextureIrradiance;
  104134. /**
  104135. * Uploads the texture info contained in the env file to the GPU.
  104136. * @param texture defines the internal texture to upload to
  104137. * @param arrayBuffer defines the buffer cotaining the data to load
  104138. * @param info defines the texture info retrieved through the GetEnvInfo method
  104139. * @returns a promise
  104140. */
  104141. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  104142. /**
  104143. * Uploads the levels of image data to the GPU.
  104144. * @param texture defines the internal texture to upload to
  104145. * @param imageData defines the array buffer views of image data [mipmap][face]
  104146. * @returns a promise
  104147. */
  104148. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  104149. /**
  104150. * Uploads spherical polynomials information to the texture.
  104151. * @param texture defines the texture we are trying to upload the information to
  104152. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  104153. */
  104154. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  104155. /** @hidden */
  104156. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104157. }
  104158. }
  104159. declare module BABYLON {
  104160. /**
  104161. * Implementation of the ENV Texture Loader.
  104162. * @hidden
  104163. */
  104164. export class _ENVTextureLoader implements IInternalTextureLoader {
  104165. /**
  104166. * Defines wether the loader supports cascade loading the different faces.
  104167. */
  104168. readonly supportCascades: boolean;
  104169. /**
  104170. * This returns if the loader support the current file information.
  104171. * @param extension defines the file extension of the file being loaded
  104172. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104173. * @param fallback defines the fallback internal texture if any
  104174. * @param isBase64 defines whether the texture is encoded as a base64
  104175. * @param isBuffer defines whether the texture data are stored as a buffer
  104176. * @returns true if the loader can load the specified file
  104177. */
  104178. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104179. /**
  104180. * Transform the url before loading if required.
  104181. * @param rootUrl the url of the texture
  104182. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104183. * @returns the transformed texture
  104184. */
  104185. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104186. /**
  104187. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104188. * @param rootUrl the url of the texture
  104189. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104190. * @returns the fallback texture
  104191. */
  104192. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104193. /**
  104194. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104195. * @param data contains the texture data
  104196. * @param texture defines the BabylonJS internal texture
  104197. * @param createPolynomials will be true if polynomials have been requested
  104198. * @param onLoad defines the callback to trigger once the texture is ready
  104199. * @param onError defines the callback to trigger in case of error
  104200. */
  104201. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104202. /**
  104203. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104204. * @param data contains the texture data
  104205. * @param texture defines the BabylonJS internal texture
  104206. * @param callback defines the method to call once ready to upload
  104207. */
  104208. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104209. }
  104210. }
  104211. declare module BABYLON {
  104212. /**
  104213. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104214. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104215. */
  104216. export class KhronosTextureContainer {
  104217. /** contents of the KTX container file */
  104218. arrayBuffer: any;
  104219. private static HEADER_LEN;
  104220. private static COMPRESSED_2D;
  104221. private static COMPRESSED_3D;
  104222. private static TEX_2D;
  104223. private static TEX_3D;
  104224. /**
  104225. * Gets the openGL type
  104226. */
  104227. glType: number;
  104228. /**
  104229. * Gets the openGL type size
  104230. */
  104231. glTypeSize: number;
  104232. /**
  104233. * Gets the openGL format
  104234. */
  104235. glFormat: number;
  104236. /**
  104237. * Gets the openGL internal format
  104238. */
  104239. glInternalFormat: number;
  104240. /**
  104241. * Gets the base internal format
  104242. */
  104243. glBaseInternalFormat: number;
  104244. /**
  104245. * Gets image width in pixel
  104246. */
  104247. pixelWidth: number;
  104248. /**
  104249. * Gets image height in pixel
  104250. */
  104251. pixelHeight: number;
  104252. /**
  104253. * Gets image depth in pixels
  104254. */
  104255. pixelDepth: number;
  104256. /**
  104257. * Gets the number of array elements
  104258. */
  104259. numberOfArrayElements: number;
  104260. /**
  104261. * Gets the number of faces
  104262. */
  104263. numberOfFaces: number;
  104264. /**
  104265. * Gets the number of mipmap levels
  104266. */
  104267. numberOfMipmapLevels: number;
  104268. /**
  104269. * Gets the bytes of key value data
  104270. */
  104271. bytesOfKeyValueData: number;
  104272. /**
  104273. * Gets the load type
  104274. */
  104275. loadType: number;
  104276. /**
  104277. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  104278. */
  104279. isInvalid: boolean;
  104280. /**
  104281. * Creates a new KhronosTextureContainer
  104282. * @param arrayBuffer contents of the KTX container file
  104283. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  104284. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  104285. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  104286. */
  104287. constructor(
  104288. /** contents of the KTX container file */
  104289. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  104290. /**
  104291. * Uploads KTX content to a Babylon Texture.
  104292. * It is assumed that the texture has already been created & is currently bound
  104293. * @hidden
  104294. */
  104295. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  104296. private _upload2DCompressedLevels;
  104297. }
  104298. }
  104299. declare module BABYLON {
  104300. /**
  104301. * Implementation of the KTX Texture Loader.
  104302. * @hidden
  104303. */
  104304. export class _KTXTextureLoader implements IInternalTextureLoader {
  104305. /**
  104306. * Defines wether the loader supports cascade loading the different faces.
  104307. */
  104308. readonly supportCascades: boolean;
  104309. /**
  104310. * This returns if the loader support the current file information.
  104311. * @param extension defines the file extension of the file being loaded
  104312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104313. * @param fallback defines the fallback internal texture if any
  104314. * @param isBase64 defines whether the texture is encoded as a base64
  104315. * @param isBuffer defines whether the texture data are stored as a buffer
  104316. * @returns true if the loader can load the specified file
  104317. */
  104318. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104319. /**
  104320. * Transform the url before loading if required.
  104321. * @param rootUrl the url of the texture
  104322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104323. * @returns the transformed texture
  104324. */
  104325. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104326. /**
  104327. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104328. * @param rootUrl the url of the texture
  104329. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104330. * @returns the fallback texture
  104331. */
  104332. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104333. /**
  104334. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104335. * @param data contains the texture data
  104336. * @param texture defines the BabylonJS internal texture
  104337. * @param createPolynomials will be true if polynomials have been requested
  104338. * @param onLoad defines the callback to trigger once the texture is ready
  104339. * @param onError defines the callback to trigger in case of error
  104340. */
  104341. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104342. /**
  104343. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104344. * @param data contains the texture data
  104345. * @param texture defines the BabylonJS internal texture
  104346. * @param callback defines the method to call once ready to upload
  104347. */
  104348. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  104349. }
  104350. }
  104351. declare module BABYLON {
  104352. /**
  104353. * Based on jsTGALoader - Javascript loader for TGA file
  104354. * By Vincent Thibault
  104355. * @see http://blog.robrowser.com/javascript-tga-loader.html
  104356. */
  104357. export class TGATools {
  104358. private static _TYPE_INDEXED;
  104359. private static _TYPE_RGB;
  104360. private static _TYPE_GREY;
  104361. private static _TYPE_RLE_INDEXED;
  104362. private static _TYPE_RLE_RGB;
  104363. private static _TYPE_RLE_GREY;
  104364. private static _ORIGIN_MASK;
  104365. private static _ORIGIN_SHIFT;
  104366. private static _ORIGIN_BL;
  104367. private static _ORIGIN_BR;
  104368. private static _ORIGIN_UL;
  104369. private static _ORIGIN_UR;
  104370. /**
  104371. * Gets the header of a TGA file
  104372. * @param data defines the TGA data
  104373. * @returns the header
  104374. */
  104375. static GetTGAHeader(data: Uint8Array): any;
  104376. /**
  104377. * Uploads TGA content to a Babylon Texture
  104378. * @hidden
  104379. */
  104380. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  104381. /** @hidden */
  104382. 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;
  104383. /** @hidden */
  104384. 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;
  104385. /** @hidden */
  104386. 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;
  104387. /** @hidden */
  104388. 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;
  104389. /** @hidden */
  104390. 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;
  104391. /** @hidden */
  104392. 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;
  104393. }
  104394. }
  104395. declare module BABYLON {
  104396. /**
  104397. * Implementation of the TGA Texture Loader.
  104398. * @hidden
  104399. */
  104400. export class _TGATextureLoader implements IInternalTextureLoader {
  104401. /**
  104402. * Defines wether the loader supports cascade loading the different faces.
  104403. */
  104404. readonly supportCascades: boolean;
  104405. /**
  104406. * This returns if the loader support the current file information.
  104407. * @param extension defines the file extension of the file being loaded
  104408. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104409. * @param fallback defines the fallback internal texture if any
  104410. * @param isBase64 defines whether the texture is encoded as a base64
  104411. * @param isBuffer defines whether the texture data are stored as a buffer
  104412. * @returns true if the loader can load the specified file
  104413. */
  104414. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104415. /**
  104416. * Transform the url before loading if required.
  104417. * @param rootUrl the url of the texture
  104418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104419. * @returns the transformed texture
  104420. */
  104421. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104422. /**
  104423. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104424. * @param rootUrl the url of the texture
  104425. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104426. * @returns the fallback texture
  104427. */
  104428. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104429. /**
  104430. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104431. * @param data contains the texture data
  104432. * @param texture defines the BabylonJS internal texture
  104433. * @param createPolynomials will be true if polynomials have been requested
  104434. * @param onLoad defines the callback to trigger once the texture is ready
  104435. * @param onError defines the callback to trigger in case of error
  104436. */
  104437. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104438. /**
  104439. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104440. * @param data contains the texture data
  104441. * @param texture defines the BabylonJS internal texture
  104442. * @param callback defines the method to call once ready to upload
  104443. */
  104444. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104445. }
  104446. }
  104447. declare module BABYLON {
  104448. /**
  104449. * 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.
  104450. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104451. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104452. */
  104453. export class CustomProceduralTexture extends ProceduralTexture {
  104454. private _animate;
  104455. private _time;
  104456. private _config;
  104457. private _texturePath;
  104458. /**
  104459. * Instantiates a new Custom Procedural Texture.
  104460. * 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.
  104461. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104462. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104463. * @param name Define the name of the texture
  104464. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  104465. * @param size Define the size of the texture to create
  104466. * @param scene Define the scene the texture belongs to
  104467. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  104468. * @param generateMipMaps Define if the texture should creates mip maps or not
  104469. */
  104470. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104471. private _loadJson;
  104472. /**
  104473. * Is the texture ready to be used ? (rendered at least once)
  104474. * @returns true if ready, otherwise, false.
  104475. */
  104476. isReady(): boolean;
  104477. /**
  104478. * Render the texture to its associated render target.
  104479. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  104480. */
  104481. render(useCameraPostProcess?: boolean): void;
  104482. /**
  104483. * Update the list of dependant textures samplers in the shader.
  104484. */
  104485. updateTextures(): void;
  104486. /**
  104487. * Update the uniform values of the procedural texture in the shader.
  104488. */
  104489. updateShaderUniforms(): void;
  104490. /**
  104491. * Define if the texture animates or not.
  104492. */
  104493. animate: boolean;
  104494. }
  104495. }
  104496. declare module BABYLON {
  104497. /** @hidden */
  104498. export var noisePixelShader: {
  104499. name: string;
  104500. shader: string;
  104501. };
  104502. }
  104503. declare module BABYLON {
  104504. /**
  104505. * Class used to generate noise procedural textures
  104506. */
  104507. export class NoiseProceduralTexture extends ProceduralTexture {
  104508. private _time;
  104509. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  104510. brightness: number;
  104511. /** Defines the number of octaves to process */
  104512. octaves: number;
  104513. /** Defines the level of persistence (0.8 by default) */
  104514. persistence: number;
  104515. /** Gets or sets animation speed factor (default is 1) */
  104516. animationSpeedFactor: number;
  104517. /**
  104518. * Creates a new NoiseProceduralTexture
  104519. * @param name defines the name fo the texture
  104520. * @param size defines the size of the texture (default is 256)
  104521. * @param scene defines the hosting scene
  104522. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  104523. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  104524. */
  104525. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104526. private _updateShaderUniforms;
  104527. protected _getDefines(): string;
  104528. /** Generate the current state of the procedural texture */
  104529. render(useCameraPostProcess?: boolean): void;
  104530. /**
  104531. * Serializes this noise procedural texture
  104532. * @returns a serialized noise procedural texture object
  104533. */
  104534. serialize(): any;
  104535. /**
  104536. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  104537. * @param parsedTexture defines parsed texture data
  104538. * @param scene defines the current scene
  104539. * @param rootUrl defines the root URL containing noise procedural texture information
  104540. * @returns a parsed NoiseProceduralTexture
  104541. */
  104542. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  104543. }
  104544. }
  104545. declare module BABYLON {
  104546. /**
  104547. * Raw cube texture where the raw buffers are passed in
  104548. */
  104549. export class RawCubeTexture extends CubeTexture {
  104550. /**
  104551. * Creates a cube texture where the raw buffers are passed in.
  104552. * @param scene defines the scene the texture is attached to
  104553. * @param data defines the array of data to use to create each face
  104554. * @param size defines the size of the textures
  104555. * @param format defines the format of the data
  104556. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104557. * @param generateMipMaps defines if the engine should generate the mip levels
  104558. * @param invertY defines if data must be stored with Y axis inverted
  104559. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104560. * @param compression defines the compression used (null by default)
  104561. */
  104562. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  104563. /**
  104564. * Updates the raw cube texture.
  104565. * @param data defines the data to store
  104566. * @param format defines the data format
  104567. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104568. * @param invertY defines if data must be stored with Y axis inverted
  104569. * @param compression defines the compression used (null by default)
  104570. * @param level defines which level of the texture to update
  104571. */
  104572. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  104573. /**
  104574. * Updates a raw cube texture with RGBD encoded data.
  104575. * @param data defines the array of data [mipmap][face] to use to create each face
  104576. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  104577. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  104578. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  104579. * @returns a promsie that resolves when the operation is complete
  104580. */
  104581. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  104582. /**
  104583. * Clones the raw cube texture.
  104584. * @return a new cube texture
  104585. */
  104586. clone(): CubeTexture;
  104587. /** @hidden */
  104588. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104589. }
  104590. }
  104591. declare module BABYLON {
  104592. /**
  104593. * Class used to store 3D textures containing user data
  104594. */
  104595. export class RawTexture3D extends Texture {
  104596. /** Gets or sets the texture format to use */
  104597. format: number;
  104598. private _engine;
  104599. /**
  104600. * Create a new RawTexture3D
  104601. * @param data defines the data of the texture
  104602. * @param width defines the width of the texture
  104603. * @param height defines the height of the texture
  104604. * @param depth defines the depth of the texture
  104605. * @param format defines the texture format to use
  104606. * @param scene defines the hosting scene
  104607. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  104608. * @param invertY defines if texture must be stored with Y axis inverted
  104609. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  104610. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  104611. */
  104612. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  104613. /** Gets or sets the texture format to use */
  104614. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  104615. /**
  104616. * Update the texture with new data
  104617. * @param data defines the data to store in the texture
  104618. */
  104619. update(data: ArrayBufferView): void;
  104620. }
  104621. }
  104622. declare module BABYLON {
  104623. /**
  104624. * Creates a refraction texture used by refraction channel of the standard material.
  104625. * It is like a mirror but to see through a material.
  104626. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104627. */
  104628. export class RefractionTexture extends RenderTargetTexture {
  104629. /**
  104630. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  104631. * 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.
  104632. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104633. */
  104634. refractionPlane: Plane;
  104635. /**
  104636. * Define how deep under the surface we should see.
  104637. */
  104638. depth: number;
  104639. /**
  104640. * Creates a refraction texture used by refraction channel of the standard material.
  104641. * It is like a mirror but to see through a material.
  104642. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104643. * @param name Define the texture name
  104644. * @param size Define the size of the underlying texture
  104645. * @param scene Define the scene the refraction belongs to
  104646. * @param generateMipMaps Define if we need to generate mips level for the refraction
  104647. */
  104648. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  104649. /**
  104650. * Clone the refraction texture.
  104651. * @returns the cloned texture
  104652. */
  104653. clone(): RefractionTexture;
  104654. /**
  104655. * Serialize the texture to a JSON representation you could use in Parse later on
  104656. * @returns the serialized JSON representation
  104657. */
  104658. serialize(): any;
  104659. }
  104660. }
  104661. declare module BABYLON {
  104662. /**
  104663. * Configuration for Draco compression
  104664. */
  104665. export interface IDracoCompressionConfiguration {
  104666. /**
  104667. * Configuration for the decoder.
  104668. */
  104669. decoder?: {
  104670. /**
  104671. * The url to the WebAssembly module.
  104672. */
  104673. wasmUrl?: string;
  104674. /**
  104675. * The url to the WebAssembly binary.
  104676. */
  104677. wasmBinaryUrl?: string;
  104678. /**
  104679. * The url to the fallback JavaScript module.
  104680. */
  104681. fallbackUrl?: string;
  104682. };
  104683. }
  104684. /**
  104685. * Draco compression (https://google.github.io/draco/)
  104686. *
  104687. * This class wraps the Draco module.
  104688. *
  104689. * **Encoder**
  104690. *
  104691. * The encoder is not currently implemented.
  104692. *
  104693. * **Decoder**
  104694. *
  104695. * 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.
  104696. *
  104697. * To update the configuration, use the following code:
  104698. * ```javascript
  104699. * DracoCompression.Configuration = {
  104700. * decoder: {
  104701. * wasmUrl: "<url to the WebAssembly library>",
  104702. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  104703. * fallbackUrl: "<url to the fallback JavaScript library>",
  104704. * }
  104705. * };
  104706. * ```
  104707. *
  104708. * 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.
  104709. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  104710. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  104711. *
  104712. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  104713. * ```javascript
  104714. * var dracoCompression = new DracoCompression();
  104715. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  104716. * [VertexBuffer.PositionKind]: 0
  104717. * });
  104718. * ```
  104719. *
  104720. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  104721. */
  104722. export class DracoCompression implements IDisposable {
  104723. private static _DecoderModulePromise;
  104724. /**
  104725. * The configuration. Defaults to the following urls:
  104726. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  104727. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  104728. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  104729. */
  104730. static Configuration: IDracoCompressionConfiguration;
  104731. /**
  104732. * Returns true if the decoder is available.
  104733. */
  104734. static readonly DecoderAvailable: boolean;
  104735. /**
  104736. * Constructor
  104737. */
  104738. constructor();
  104739. /**
  104740. * Stop all async operations and release resources.
  104741. */
  104742. dispose(): void;
  104743. /**
  104744. * Decode Draco compressed mesh data to vertex data.
  104745. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  104746. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  104747. * @returns A promise that resolves with the decoded vertex data
  104748. */
  104749. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  104750. [kind: string]: number;
  104751. }): Promise<VertexData>;
  104752. private static _GetDecoderModule;
  104753. private static _LoadScriptAsync;
  104754. private static _LoadFileAsync;
  104755. }
  104756. }
  104757. declare module BABYLON {
  104758. /**
  104759. * Class for building Constructive Solid Geometry
  104760. */
  104761. export class CSG {
  104762. private polygons;
  104763. /**
  104764. * The world matrix
  104765. */
  104766. matrix: Matrix;
  104767. /**
  104768. * Stores the position
  104769. */
  104770. position: Vector3;
  104771. /**
  104772. * Stores the rotation
  104773. */
  104774. rotation: Vector3;
  104775. /**
  104776. * Stores the rotation quaternion
  104777. */
  104778. rotationQuaternion: Nullable<Quaternion>;
  104779. /**
  104780. * Stores the scaling vector
  104781. */
  104782. scaling: Vector3;
  104783. /**
  104784. * Convert the Mesh to CSG
  104785. * @param mesh The Mesh to convert to CSG
  104786. * @returns A new CSG from the Mesh
  104787. */
  104788. static FromMesh(mesh: Mesh): CSG;
  104789. /**
  104790. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  104791. * @param polygons Polygons used to construct a CSG solid
  104792. */
  104793. private static FromPolygons;
  104794. /**
  104795. * Clones, or makes a deep copy, of the CSG
  104796. * @returns A new CSG
  104797. */
  104798. clone(): CSG;
  104799. /**
  104800. * Unions this CSG with another CSG
  104801. * @param csg The CSG to union against this CSG
  104802. * @returns The unioned CSG
  104803. */
  104804. union(csg: CSG): CSG;
  104805. /**
  104806. * Unions this CSG with another CSG in place
  104807. * @param csg The CSG to union against this CSG
  104808. */
  104809. unionInPlace(csg: CSG): void;
  104810. /**
  104811. * Subtracts this CSG with another CSG
  104812. * @param csg The CSG to subtract against this CSG
  104813. * @returns A new CSG
  104814. */
  104815. subtract(csg: CSG): CSG;
  104816. /**
  104817. * Subtracts this CSG with another CSG in place
  104818. * @param csg The CSG to subtact against this CSG
  104819. */
  104820. subtractInPlace(csg: CSG): void;
  104821. /**
  104822. * Intersect this CSG with another CSG
  104823. * @param csg The CSG to intersect against this CSG
  104824. * @returns A new CSG
  104825. */
  104826. intersect(csg: CSG): CSG;
  104827. /**
  104828. * Intersects this CSG with another CSG in place
  104829. * @param csg The CSG to intersect against this CSG
  104830. */
  104831. intersectInPlace(csg: CSG): void;
  104832. /**
  104833. * Return a new CSG solid with solid and empty space switched. This solid is
  104834. * not modified.
  104835. * @returns A new CSG solid with solid and empty space switched
  104836. */
  104837. inverse(): CSG;
  104838. /**
  104839. * Inverses the CSG in place
  104840. */
  104841. inverseInPlace(): void;
  104842. /**
  104843. * This is used to keep meshes transformations so they can be restored
  104844. * when we build back a Babylon Mesh
  104845. * NB : All CSG operations are performed in world coordinates
  104846. * @param csg The CSG to copy the transform attributes from
  104847. * @returns This CSG
  104848. */
  104849. copyTransformAttributes(csg: CSG): CSG;
  104850. /**
  104851. * Build Raw mesh from CSG
  104852. * Coordinates here are in world space
  104853. * @param name The name of the mesh geometry
  104854. * @param scene The Scene
  104855. * @param keepSubMeshes Specifies if the submeshes should be kept
  104856. * @returns A new Mesh
  104857. */
  104858. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  104859. /**
  104860. * Build Mesh from CSG taking material and transforms into account
  104861. * @param name The name of the Mesh
  104862. * @param material The material of the Mesh
  104863. * @param scene The Scene
  104864. * @param keepSubMeshes Specifies if submeshes should be kept
  104865. * @returns The new Mesh
  104866. */
  104867. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  104868. }
  104869. }
  104870. declare module BABYLON {
  104871. /**
  104872. * Class used to create a trail following a mesh
  104873. */
  104874. export class TrailMesh extends Mesh {
  104875. private _generator;
  104876. private _autoStart;
  104877. private _running;
  104878. private _diameter;
  104879. private _length;
  104880. private _sectionPolygonPointsCount;
  104881. private _sectionVectors;
  104882. private _sectionNormalVectors;
  104883. private _beforeRenderObserver;
  104884. /**
  104885. * @constructor
  104886. * @param name The value used by scene.getMeshByName() to do a lookup.
  104887. * @param generator The mesh to generate a trail.
  104888. * @param scene The scene to add this mesh to.
  104889. * @param diameter Diameter of trailing mesh. Default is 1.
  104890. * @param length Length of trailing mesh. Default is 60.
  104891. * @param autoStart Automatically start trailing mesh. Default true.
  104892. */
  104893. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  104894. /**
  104895. * "TrailMesh"
  104896. * @returns "TrailMesh"
  104897. */
  104898. getClassName(): string;
  104899. private _createMesh;
  104900. /**
  104901. * Start trailing mesh.
  104902. */
  104903. start(): void;
  104904. /**
  104905. * Stop trailing mesh.
  104906. */
  104907. stop(): void;
  104908. /**
  104909. * Update trailing mesh geometry.
  104910. */
  104911. update(): void;
  104912. /**
  104913. * Returns a new TrailMesh object.
  104914. * @param name is a string, the name given to the new mesh
  104915. * @param newGenerator use new generator object for cloned trail mesh
  104916. * @returns a new mesh
  104917. */
  104918. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  104919. /**
  104920. * Serializes this trail mesh
  104921. * @param serializationObject object to write serialization to
  104922. */
  104923. serialize(serializationObject: any): void;
  104924. /**
  104925. * Parses a serialized trail mesh
  104926. * @param parsedMesh the serialized mesh
  104927. * @param scene the scene to create the trail mesh in
  104928. * @returns the created trail mesh
  104929. */
  104930. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  104931. }
  104932. }
  104933. declare module BABYLON {
  104934. /**
  104935. * Class containing static functions to help procedurally build meshes
  104936. */
  104937. export class RibbonBuilder {
  104938. /**
  104939. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104940. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  104941. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  104942. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  104943. * * 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
  104944. * * 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
  104945. * * 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
  104946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104947. * * If you create a double-sided mesh, you can choose what parts of 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
  104948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104949. * * 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
  104950. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  104951. * * 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
  104952. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  104953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104954. * @param name defines the name of the mesh
  104955. * @param options defines the options used to create the mesh
  104956. * @param scene defines the hosting scene
  104957. * @returns the ribbon mesh
  104958. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  104959. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104960. */
  104961. static CreateRibbon(name: string, options: {
  104962. pathArray: Vector3[][];
  104963. closeArray?: boolean;
  104964. closePath?: boolean;
  104965. offset?: number;
  104966. updatable?: boolean;
  104967. sideOrientation?: number;
  104968. frontUVs?: Vector4;
  104969. backUVs?: Vector4;
  104970. instance?: Mesh;
  104971. invertUV?: boolean;
  104972. uvs?: Vector2[];
  104973. colors?: Color4[];
  104974. }, scene?: Nullable<Scene>): Mesh;
  104975. }
  104976. }
  104977. declare module BABYLON {
  104978. /**
  104979. * Class containing static functions to help procedurally build meshes
  104980. */
  104981. export class TorusKnotBuilder {
  104982. /**
  104983. * Creates a torus knot mesh
  104984. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  104985. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  104986. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  104987. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  104988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104989. * * If you create a double-sided mesh, you can choose what parts of 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
  104990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104991. * @param name defines the name of the mesh
  104992. * @param options defines the options used to create the mesh
  104993. * @param scene defines the hosting scene
  104994. * @returns the torus knot mesh
  104995. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  104996. */
  104997. static CreateTorusKnot(name: string, options: {
  104998. radius?: number;
  104999. tube?: number;
  105000. radialSegments?: number;
  105001. tubularSegments?: number;
  105002. p?: number;
  105003. q?: number;
  105004. updatable?: boolean;
  105005. sideOrientation?: number;
  105006. frontUVs?: Vector4;
  105007. backUVs?: Vector4;
  105008. }, scene: any): Mesh;
  105009. }
  105010. }
  105011. declare module BABYLON {
  105012. /**
  105013. * Polygon
  105014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105015. */
  105016. export class Polygon {
  105017. /**
  105018. * Creates a rectangle
  105019. * @param xmin bottom X coord
  105020. * @param ymin bottom Y coord
  105021. * @param xmax top X coord
  105022. * @param ymax top Y coord
  105023. * @returns points that make the resulting rectation
  105024. */
  105025. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105026. /**
  105027. * Creates a circle
  105028. * @param radius radius of circle
  105029. * @param cx scale in x
  105030. * @param cy scale in y
  105031. * @param numberOfSides number of sides that make up the circle
  105032. * @returns points that make the resulting circle
  105033. */
  105034. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105035. /**
  105036. * Creates a polygon from input string
  105037. * @param input Input polygon data
  105038. * @returns the parsed points
  105039. */
  105040. static Parse(input: string): Vector2[];
  105041. /**
  105042. * Starts building a polygon from x and y coordinates
  105043. * @param x x coordinate
  105044. * @param y y coordinate
  105045. * @returns the started path2
  105046. */
  105047. static StartingAt(x: number, y: number): Path2;
  105048. }
  105049. /**
  105050. * Builds a polygon
  105051. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105052. */
  105053. export class PolygonMeshBuilder {
  105054. private _points;
  105055. private _outlinepoints;
  105056. private _holes;
  105057. private _name;
  105058. private _scene;
  105059. private _epoints;
  105060. private _eholes;
  105061. private _addToepoint;
  105062. /**
  105063. * Babylon reference to the earcut plugin.
  105064. */
  105065. bjsEarcut: any;
  105066. /**
  105067. * Creates a PolygonMeshBuilder
  105068. * @param name name of the builder
  105069. * @param contours Path of the polygon
  105070. * @param scene scene to add to
  105071. * @param earcutInjection can be used to inject your own earcut reference
  105072. */
  105073. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105074. /**
  105075. * Adds a whole within the polygon
  105076. * @param hole Array of points defining the hole
  105077. * @returns this
  105078. */
  105079. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105080. /**
  105081. * Creates the polygon
  105082. * @param updatable If the mesh should be updatable
  105083. * @param depth The depth of the mesh created
  105084. * @returns the created mesh
  105085. */
  105086. build(updatable?: boolean, depth?: number): Mesh;
  105087. /**
  105088. * Adds a side to the polygon
  105089. * @param positions points that make the polygon
  105090. * @param normals normals of the polygon
  105091. * @param uvs uvs of the polygon
  105092. * @param indices indices of the polygon
  105093. * @param bounds bounds of the polygon
  105094. * @param points points of the polygon
  105095. * @param depth depth of the polygon
  105096. * @param flip flip of the polygon
  105097. */
  105098. private addSide;
  105099. }
  105100. }
  105101. declare module BABYLON {
  105102. /**
  105103. * Class containing static functions to help procedurally build meshes
  105104. */
  105105. export class PolygonBuilder {
  105106. /**
  105107. * Creates a polygon mesh
  105108. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105109. * * 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
  105110. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105113. * * Remember you can only change the shape positions, not their number when updating a polygon
  105114. * @param name defines the name of the mesh
  105115. * @param options defines the options used to create the mesh
  105116. * @param scene defines the hosting scene
  105117. * @param earcutInjection can be used to inject your own earcut reference
  105118. * @returns the polygon mesh
  105119. */
  105120. static CreatePolygon(name: string, options: {
  105121. shape: Vector3[];
  105122. holes?: Vector3[][];
  105123. depth?: number;
  105124. faceUV?: Vector4[];
  105125. faceColors?: Color4[];
  105126. updatable?: boolean;
  105127. sideOrientation?: number;
  105128. frontUVs?: Vector4;
  105129. backUVs?: Vector4;
  105130. }, scene: Scene, earcutInjection?: any): Mesh;
  105131. /**
  105132. * Creates an extruded polygon mesh, with depth in the Y direction.
  105133. * * 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)
  105134. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105135. * @param name defines the name of the mesh
  105136. * @param options defines the options used to create the mesh
  105137. * @param scene defines the hosting scene
  105138. * @param earcutInjection can be used to inject your own earcut reference
  105139. * @returns the polygon mesh
  105140. */
  105141. static ExtrudePolygon(name: string, options: {
  105142. shape: Vector3[];
  105143. holes?: Vector3[][];
  105144. depth?: number;
  105145. faceUV?: Vector4[];
  105146. faceColors?: Color4[];
  105147. updatable?: boolean;
  105148. sideOrientation?: number;
  105149. frontUVs?: Vector4;
  105150. backUVs?: Vector4;
  105151. }, scene: Scene, earcutInjection?: any): Mesh;
  105152. }
  105153. }
  105154. declare module BABYLON {
  105155. /**
  105156. * Class containing static functions to help procedurally build meshes
  105157. */
  105158. export class ShapeBuilder {
  105159. /**
  105160. * 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.
  105161. * * 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.
  105162. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105163. * * 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.
  105164. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105165. * * 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
  105166. * * 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
  105167. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105169. * * If you create a double-sided mesh, you can choose what parts of 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
  105170. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105172. * @param name defines the name of the mesh
  105173. * @param options defines the options used to create the mesh
  105174. * @param scene defines the hosting scene
  105175. * @returns the extruded shape mesh
  105176. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105177. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105178. */
  105179. static ExtrudeShape(name: string, options: {
  105180. shape: Vector3[];
  105181. path: Vector3[];
  105182. scale?: number;
  105183. rotation?: number;
  105184. cap?: number;
  105185. updatable?: boolean;
  105186. sideOrientation?: number;
  105187. frontUVs?: Vector4;
  105188. backUVs?: Vector4;
  105189. instance?: Mesh;
  105190. invertUV?: boolean;
  105191. }, scene?: Nullable<Scene>): Mesh;
  105192. /**
  105193. * Creates an custom extruded shape mesh.
  105194. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105195. * * 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.
  105196. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105197. * * 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
  105198. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105199. * * 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
  105200. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105201. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105202. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105203. * * 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
  105204. * * 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
  105205. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105207. * * If you create a double-sided mesh, you can choose what parts of 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
  105208. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105210. * @param name defines the name of the mesh
  105211. * @param options defines the options used to create the mesh
  105212. * @param scene defines the hosting scene
  105213. * @returns the custom extruded shape mesh
  105214. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105215. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105216. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105217. */
  105218. static ExtrudeShapeCustom(name: string, options: {
  105219. shape: Vector3[];
  105220. path: Vector3[];
  105221. scaleFunction?: any;
  105222. rotationFunction?: any;
  105223. ribbonCloseArray?: boolean;
  105224. ribbonClosePath?: boolean;
  105225. cap?: number;
  105226. updatable?: boolean;
  105227. sideOrientation?: number;
  105228. frontUVs?: Vector4;
  105229. backUVs?: Vector4;
  105230. instance?: Mesh;
  105231. invertUV?: boolean;
  105232. }, scene: Scene): Mesh;
  105233. private static _ExtrudeShapeGeneric;
  105234. }
  105235. }
  105236. declare module BABYLON {
  105237. /**
  105238. * Class containing static functions to help procedurally build meshes
  105239. */
  105240. export class LatheBuilder {
  105241. /**
  105242. * Creates lathe mesh.
  105243. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105244. * * 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
  105245. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105246. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105247. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105248. * * 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
  105249. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105250. * * 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
  105251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105252. * * If you create a double-sided mesh, you can choose what parts of 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
  105253. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105255. * @param name defines the name of the mesh
  105256. * @param options defines the options used to create the mesh
  105257. * @param scene defines the hosting scene
  105258. * @returns the lathe mesh
  105259. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105260. */
  105261. static CreateLathe(name: string, options: {
  105262. shape: Vector3[];
  105263. radius?: number;
  105264. tessellation?: number;
  105265. clip?: number;
  105266. arc?: number;
  105267. closed?: boolean;
  105268. updatable?: boolean;
  105269. sideOrientation?: number;
  105270. frontUVs?: Vector4;
  105271. backUVs?: Vector4;
  105272. cap?: number;
  105273. invertUV?: boolean;
  105274. }, scene: Scene): Mesh;
  105275. }
  105276. }
  105277. declare module BABYLON {
  105278. /**
  105279. * Class containing static functions to help procedurally build meshes
  105280. */
  105281. export class TubeBuilder {
  105282. /**
  105283. * Creates a tube mesh.
  105284. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105285. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105286. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105287. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105288. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105289. * * 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)
  105290. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105291. * * 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
  105292. * * 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
  105293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105294. * * If you create a double-sided mesh, you can choose what parts of 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
  105295. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105297. * @param name defines the name of the mesh
  105298. * @param options defines the options used to create the mesh
  105299. * @param scene defines the hosting scene
  105300. * @returns the tube mesh
  105301. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105302. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105303. */
  105304. static CreateTube(name: string, options: {
  105305. path: Vector3[];
  105306. radius?: number;
  105307. tessellation?: number;
  105308. radiusFunction?: {
  105309. (i: number, distance: number): number;
  105310. };
  105311. cap?: number;
  105312. arc?: number;
  105313. updatable?: boolean;
  105314. sideOrientation?: number;
  105315. frontUVs?: Vector4;
  105316. backUVs?: Vector4;
  105317. instance?: Mesh;
  105318. invertUV?: boolean;
  105319. }, scene: Scene): Mesh;
  105320. }
  105321. }
  105322. declare module BABYLON {
  105323. /**
  105324. * Class containing static functions to help procedurally build meshes
  105325. */
  105326. export class IcoSphereBuilder {
  105327. /**
  105328. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105329. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105330. * * 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`)
  105331. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105332. * * 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
  105333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105334. * * If you create a double-sided mesh, you can choose what parts of 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
  105335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105336. * @param name defines the name of the mesh
  105337. * @param options defines the options used to create the mesh
  105338. * @param scene defines the hosting scene
  105339. * @returns the icosahedron mesh
  105340. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105341. */
  105342. static CreateIcoSphere(name: string, options: {
  105343. radius?: number;
  105344. radiusX?: number;
  105345. radiusY?: number;
  105346. radiusZ?: number;
  105347. flat?: boolean;
  105348. subdivisions?: number;
  105349. sideOrientation?: number;
  105350. frontUVs?: Vector4;
  105351. backUVs?: Vector4;
  105352. updatable?: boolean;
  105353. }, scene: Scene): Mesh;
  105354. }
  105355. }
  105356. declare module BABYLON {
  105357. /**
  105358. * Class containing static functions to help procedurally build meshes
  105359. */
  105360. export class DecalBuilder {
  105361. /**
  105362. * Creates a decal mesh.
  105363. * 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
  105364. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105365. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105366. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105367. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105368. * @param name defines the name of the mesh
  105369. * @param sourceMesh defines the mesh where the decal must be applied
  105370. * @param options defines the options used to create the mesh
  105371. * @param scene defines the hosting scene
  105372. * @returns the decal mesh
  105373. * @see https://doc.babylonjs.com/how_to/decals
  105374. */
  105375. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105376. position?: Vector3;
  105377. normal?: Vector3;
  105378. size?: Vector3;
  105379. angle?: number;
  105380. }): Mesh;
  105381. }
  105382. }
  105383. declare module BABYLON {
  105384. /**
  105385. * Class containing static functions to help procedurally build meshes
  105386. */
  105387. export class MeshBuilder {
  105388. /**
  105389. * Creates a box mesh
  105390. * * The parameter `size` sets the size (float) of each box side (default 1)
  105391. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105392. * * 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)
  105393. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105395. * * If you create a double-sided mesh, you can choose what parts of 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
  105396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105397. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105398. * @param name defines the name of the mesh
  105399. * @param options defines the options used to create the mesh
  105400. * @param scene defines the hosting scene
  105401. * @returns the box mesh
  105402. */
  105403. static CreateBox(name: string, options: {
  105404. size?: number;
  105405. width?: number;
  105406. height?: number;
  105407. depth?: number;
  105408. faceUV?: Vector4[];
  105409. faceColors?: Color4[];
  105410. sideOrientation?: number;
  105411. frontUVs?: Vector4;
  105412. backUVs?: Vector4;
  105413. updatable?: boolean;
  105414. }, scene?: Nullable<Scene>): Mesh;
  105415. /**
  105416. * Creates a sphere mesh
  105417. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105418. * * 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`)
  105419. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105420. * * 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
  105421. * * 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)
  105422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105423. * * If you create a double-sided mesh, you can choose what parts of 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
  105424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105425. * @param name defines the name of the mesh
  105426. * @param options defines the options used to create the mesh
  105427. * @param scene defines the hosting scene
  105428. * @returns the sphere mesh
  105429. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105430. */
  105431. static CreateSphere(name: string, options: {
  105432. segments?: number;
  105433. diameter?: number;
  105434. diameterX?: number;
  105435. diameterY?: number;
  105436. diameterZ?: number;
  105437. arc?: number;
  105438. slice?: number;
  105439. sideOrientation?: number;
  105440. frontUVs?: Vector4;
  105441. backUVs?: Vector4;
  105442. updatable?: boolean;
  105443. }, scene: any): Mesh;
  105444. /**
  105445. * Creates a plane polygonal mesh. By default, this is a disc
  105446. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105447. * * 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
  105448. * * 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
  105449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105450. * * If you create a double-sided mesh, you can choose what parts of 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
  105451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105452. * @param name defines the name of the mesh
  105453. * @param options defines the options used to create the mesh
  105454. * @param scene defines the hosting scene
  105455. * @returns the plane polygonal mesh
  105456. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105457. */
  105458. static CreateDisc(name: string, options: {
  105459. radius?: number;
  105460. tessellation?: number;
  105461. arc?: number;
  105462. updatable?: boolean;
  105463. sideOrientation?: number;
  105464. frontUVs?: Vector4;
  105465. backUVs?: Vector4;
  105466. }, scene?: Nullable<Scene>): Mesh;
  105467. /**
  105468. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105469. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105470. * * 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`)
  105471. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105472. * * 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
  105473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105474. * * If you create a double-sided mesh, you can choose what parts of 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
  105475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105476. * @param name defines the name of the mesh
  105477. * @param options defines the options used to create the mesh
  105478. * @param scene defines the hosting scene
  105479. * @returns the icosahedron mesh
  105480. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105481. */
  105482. static CreateIcoSphere(name: string, options: {
  105483. radius?: number;
  105484. radiusX?: number;
  105485. radiusY?: number;
  105486. radiusZ?: number;
  105487. flat?: boolean;
  105488. subdivisions?: number;
  105489. sideOrientation?: number;
  105490. frontUVs?: Vector4;
  105491. backUVs?: Vector4;
  105492. updatable?: boolean;
  105493. }, scene: Scene): Mesh;
  105494. /**
  105495. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105496. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105497. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105498. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105499. * * 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
  105500. * * 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
  105501. * * 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
  105502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105503. * * If you create a double-sided mesh, you can choose what parts of 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
  105504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105505. * * 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
  105506. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105507. * * 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
  105508. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105510. * @param name defines the name of the mesh
  105511. * @param options defines the options used to create the mesh
  105512. * @param scene defines the hosting scene
  105513. * @returns the ribbon mesh
  105514. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105515. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105516. */
  105517. static CreateRibbon(name: string, options: {
  105518. pathArray: Vector3[][];
  105519. closeArray?: boolean;
  105520. closePath?: boolean;
  105521. offset?: number;
  105522. updatable?: boolean;
  105523. sideOrientation?: number;
  105524. frontUVs?: Vector4;
  105525. backUVs?: Vector4;
  105526. instance?: Mesh;
  105527. invertUV?: boolean;
  105528. uvs?: Vector2[];
  105529. colors?: Color4[];
  105530. }, scene?: Nullable<Scene>): Mesh;
  105531. /**
  105532. * Creates a cylinder or a cone mesh
  105533. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105534. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105535. * * 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.
  105536. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105537. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105538. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105539. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105540. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105541. * * 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).
  105542. * * 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
  105543. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105544. * * 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
  105545. * * 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.
  105546. * * If `enclose` is false, a ring surface is one element.
  105547. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105548. * * 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
  105549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105550. * * If you create a double-sided mesh, you can choose what parts of 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
  105551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105552. * @param name defines the name of the mesh
  105553. * @param options defines the options used to create the mesh
  105554. * @param scene defines the hosting scene
  105555. * @returns the cylinder mesh
  105556. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105557. */
  105558. static CreateCylinder(name: string, options: {
  105559. height?: number;
  105560. diameterTop?: number;
  105561. diameterBottom?: number;
  105562. diameter?: number;
  105563. tessellation?: number;
  105564. subdivisions?: number;
  105565. arc?: number;
  105566. faceColors?: Color4[];
  105567. faceUV?: Vector4[];
  105568. updatable?: boolean;
  105569. hasRings?: boolean;
  105570. enclose?: boolean;
  105571. sideOrientation?: number;
  105572. frontUVs?: Vector4;
  105573. backUVs?: Vector4;
  105574. }, scene: any): Mesh;
  105575. /**
  105576. * Creates a torus mesh
  105577. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105578. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105579. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105581. * * If you create a double-sided mesh, you can choose what parts of 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
  105582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105583. * @param name defines the name of the mesh
  105584. * @param options defines the options used to create the mesh
  105585. * @param scene defines the hosting scene
  105586. * @returns the torus mesh
  105587. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105588. */
  105589. static CreateTorus(name: string, options: {
  105590. diameter?: number;
  105591. thickness?: number;
  105592. tessellation?: number;
  105593. updatable?: boolean;
  105594. sideOrientation?: number;
  105595. frontUVs?: Vector4;
  105596. backUVs?: Vector4;
  105597. }, scene: any): Mesh;
  105598. /**
  105599. * Creates a torus knot mesh
  105600. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105601. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105602. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105603. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105605. * * If you create a double-sided mesh, you can choose what parts of 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
  105606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105607. * @param name defines the name of the mesh
  105608. * @param options defines the options used to create the mesh
  105609. * @param scene defines the hosting scene
  105610. * @returns the torus knot mesh
  105611. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105612. */
  105613. static CreateTorusKnot(name: string, options: {
  105614. radius?: number;
  105615. tube?: number;
  105616. radialSegments?: number;
  105617. tubularSegments?: number;
  105618. p?: number;
  105619. q?: number;
  105620. updatable?: boolean;
  105621. sideOrientation?: number;
  105622. frontUVs?: Vector4;
  105623. backUVs?: Vector4;
  105624. }, scene: any): Mesh;
  105625. /**
  105626. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  105627. * * 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
  105628. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  105629. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  105630. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  105631. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  105632. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  105633. * * 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
  105634. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  105635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  105637. * @param name defines the name of the new line system
  105638. * @param options defines the options used to create the line system
  105639. * @param scene defines the hosting scene
  105640. * @returns a new line system mesh
  105641. */
  105642. static CreateLineSystem(name: string, options: {
  105643. lines: Vector3[][];
  105644. updatable?: boolean;
  105645. instance?: Nullable<LinesMesh>;
  105646. colors?: Nullable<Color4[][]>;
  105647. useVertexAlpha?: boolean;
  105648. }, scene: Nullable<Scene>): LinesMesh;
  105649. /**
  105650. * Creates a line mesh
  105651. * 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
  105652. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105653. * * The parameter `points` is an array successive Vector3
  105654. * * 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
  105655. * * The optional parameter `colors` is an array of successive Color4, one per line point
  105656. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  105657. * * When updating an instance, remember that only point positions can change, not the number of points
  105658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105659. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  105660. * @param name defines the name of the new line system
  105661. * @param options defines the options used to create the line system
  105662. * @param scene defines the hosting scene
  105663. * @returns a new line mesh
  105664. */
  105665. static CreateLines(name: string, options: {
  105666. points: Vector3[];
  105667. updatable?: boolean;
  105668. instance?: Nullable<LinesMesh>;
  105669. colors?: Color4[];
  105670. useVertexAlpha?: boolean;
  105671. }, scene?: Nullable<Scene>): LinesMesh;
  105672. /**
  105673. * Creates a dashed line mesh
  105674. * * 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
  105675. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105676. * * The parameter `points` is an array successive Vector3
  105677. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  105678. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  105679. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105680. * * 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
  105681. * * When updating an instance, remember that only point positions can change, not the number of points
  105682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105683. * @param name defines the name of the mesh
  105684. * @param options defines the options used to create the mesh
  105685. * @param scene defines the hosting scene
  105686. * @returns the dashed line mesh
  105687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  105688. */
  105689. static CreateDashedLines(name: string, options: {
  105690. points: Vector3[];
  105691. dashSize?: number;
  105692. gapSize?: number;
  105693. dashNb?: number;
  105694. updatable?: boolean;
  105695. instance?: LinesMesh;
  105696. }, scene?: Nullable<Scene>): LinesMesh;
  105697. /**
  105698. * 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.
  105699. * * 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.
  105700. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105701. * * 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.
  105702. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105703. * * 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
  105704. * * 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
  105705. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105707. * * If you create a double-sided mesh, you can choose what parts of 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
  105708. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105710. * @param name defines the name of the mesh
  105711. * @param options defines the options used to create the mesh
  105712. * @param scene defines the hosting scene
  105713. * @returns the extruded shape mesh
  105714. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105715. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105716. */
  105717. static ExtrudeShape(name: string, options: {
  105718. shape: Vector3[];
  105719. path: Vector3[];
  105720. scale?: number;
  105721. rotation?: number;
  105722. cap?: number;
  105723. updatable?: boolean;
  105724. sideOrientation?: number;
  105725. frontUVs?: Vector4;
  105726. backUVs?: Vector4;
  105727. instance?: Mesh;
  105728. invertUV?: boolean;
  105729. }, scene?: Nullable<Scene>): Mesh;
  105730. /**
  105731. * Creates an custom extruded shape mesh.
  105732. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105733. * * 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.
  105734. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105735. * * 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
  105736. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105737. * * 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
  105738. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105739. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105740. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105741. * * 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
  105742. * * 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
  105743. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105745. * * If you create a double-sided mesh, you can choose what parts of 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
  105746. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105748. * @param name defines the name of the mesh
  105749. * @param options defines the options used to create the mesh
  105750. * @param scene defines the hosting scene
  105751. * @returns the custom extruded shape mesh
  105752. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105753. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105755. */
  105756. static ExtrudeShapeCustom(name: string, options: {
  105757. shape: Vector3[];
  105758. path: Vector3[];
  105759. scaleFunction?: any;
  105760. rotationFunction?: any;
  105761. ribbonCloseArray?: boolean;
  105762. ribbonClosePath?: boolean;
  105763. cap?: number;
  105764. updatable?: boolean;
  105765. sideOrientation?: number;
  105766. frontUVs?: Vector4;
  105767. backUVs?: Vector4;
  105768. instance?: Mesh;
  105769. invertUV?: boolean;
  105770. }, scene: Scene): Mesh;
  105771. /**
  105772. * Creates lathe mesh.
  105773. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105774. * * 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
  105775. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105776. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105777. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105778. * * 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
  105779. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105780. * * 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
  105781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105782. * * If you create a double-sided mesh, you can choose what parts of 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
  105783. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105785. * @param name defines the name of the mesh
  105786. * @param options defines the options used to create the mesh
  105787. * @param scene defines the hosting scene
  105788. * @returns the lathe mesh
  105789. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105790. */
  105791. static CreateLathe(name: string, options: {
  105792. shape: Vector3[];
  105793. radius?: number;
  105794. tessellation?: number;
  105795. clip?: number;
  105796. arc?: number;
  105797. closed?: boolean;
  105798. updatable?: boolean;
  105799. sideOrientation?: number;
  105800. frontUVs?: Vector4;
  105801. backUVs?: Vector4;
  105802. cap?: number;
  105803. invertUV?: boolean;
  105804. }, scene: Scene): Mesh;
  105805. /**
  105806. * Creates a plane mesh
  105807. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105808. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105809. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105811. * * If you create a double-sided mesh, you can choose what parts of 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
  105812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105813. * @param name defines the name of the mesh
  105814. * @param options defines the options used to create the mesh
  105815. * @param scene defines the hosting scene
  105816. * @returns the plane mesh
  105817. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105818. */
  105819. static CreatePlane(name: string, options: {
  105820. size?: number;
  105821. width?: number;
  105822. height?: number;
  105823. sideOrientation?: number;
  105824. frontUVs?: Vector4;
  105825. backUVs?: Vector4;
  105826. updatable?: boolean;
  105827. sourcePlane?: Plane;
  105828. }, scene: Scene): Mesh;
  105829. /**
  105830. * Creates a ground mesh
  105831. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105832. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105834. * @param name defines the name of the mesh
  105835. * @param options defines the options used to create the mesh
  105836. * @param scene defines the hosting scene
  105837. * @returns the ground mesh
  105838. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105839. */
  105840. static CreateGround(name: string, options: {
  105841. width?: number;
  105842. height?: number;
  105843. subdivisions?: number;
  105844. subdivisionsX?: number;
  105845. subdivisionsY?: number;
  105846. updatable?: boolean;
  105847. }, scene: any): Mesh;
  105848. /**
  105849. * Creates a tiled ground mesh
  105850. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105851. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105852. * * 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
  105853. * * 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
  105854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105855. * @param name defines the name of the mesh
  105856. * @param options defines the options used to create the mesh
  105857. * @param scene defines the hosting scene
  105858. * @returns the tiled ground mesh
  105859. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105860. */
  105861. static CreateTiledGround(name: string, options: {
  105862. xmin: number;
  105863. zmin: number;
  105864. xmax: number;
  105865. zmax: number;
  105866. subdivisions?: {
  105867. w: number;
  105868. h: number;
  105869. };
  105870. precision?: {
  105871. w: number;
  105872. h: number;
  105873. };
  105874. updatable?: boolean;
  105875. }, scene: Scene): Mesh;
  105876. /**
  105877. * Creates a ground mesh from a height map
  105878. * * The parameter `url` sets the URL of the height map image resource.
  105879. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105880. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105881. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105882. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105883. * * 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.
  105884. * * 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).
  105885. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105887. * @param name defines the name of the mesh
  105888. * @param url defines the url to the height map
  105889. * @param options defines the options used to create the mesh
  105890. * @param scene defines the hosting scene
  105891. * @returns the ground mesh
  105892. * @see https://doc.babylonjs.com/babylon101/height_map
  105893. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105894. */
  105895. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105896. width?: number;
  105897. height?: number;
  105898. subdivisions?: number;
  105899. minHeight?: number;
  105900. maxHeight?: number;
  105901. colorFilter?: Color3;
  105902. alphaFilter?: number;
  105903. updatable?: boolean;
  105904. onReady?: (mesh: GroundMesh) => void;
  105905. }, scene: Scene): GroundMesh;
  105906. /**
  105907. * Creates a polygon mesh
  105908. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105909. * * 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
  105910. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105913. * * Remember you can only change the shape positions, not their number when updating a polygon
  105914. * @param name defines the name of the mesh
  105915. * @param options defines the options used to create the mesh
  105916. * @param scene defines the hosting scene
  105917. * @param earcutInjection can be used to inject your own earcut reference
  105918. * @returns the polygon mesh
  105919. */
  105920. static CreatePolygon(name: string, options: {
  105921. shape: Vector3[];
  105922. holes?: Vector3[][];
  105923. depth?: number;
  105924. faceUV?: Vector4[];
  105925. faceColors?: Color4[];
  105926. updatable?: boolean;
  105927. sideOrientation?: number;
  105928. frontUVs?: Vector4;
  105929. backUVs?: Vector4;
  105930. }, scene: Scene, earcutInjection?: any): Mesh;
  105931. /**
  105932. * Creates an extruded polygon mesh, with depth in the Y direction.
  105933. * * 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)
  105934. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105935. * @param name defines the name of the mesh
  105936. * @param options defines the options used to create the mesh
  105937. * @param scene defines the hosting scene
  105938. * @param earcutInjection can be used to inject your own earcut reference
  105939. * @returns the polygon mesh
  105940. */
  105941. static ExtrudePolygon(name: string, options: {
  105942. shape: Vector3[];
  105943. holes?: Vector3[][];
  105944. depth?: number;
  105945. faceUV?: Vector4[];
  105946. faceColors?: Color4[];
  105947. updatable?: boolean;
  105948. sideOrientation?: number;
  105949. frontUVs?: Vector4;
  105950. backUVs?: Vector4;
  105951. }, scene: Scene, earcutInjection?: any): Mesh;
  105952. /**
  105953. * Creates a tube mesh.
  105954. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105955. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105956. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105957. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105958. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105959. * * 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)
  105960. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105961. * * 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
  105962. * * 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
  105963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105964. * * If you create a double-sided mesh, you can choose what parts of 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
  105965. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105967. * @param name defines the name of the mesh
  105968. * @param options defines the options used to create the mesh
  105969. * @param scene defines the hosting scene
  105970. * @returns the tube mesh
  105971. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105972. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105973. */
  105974. static CreateTube(name: string, options: {
  105975. path: Vector3[];
  105976. radius?: number;
  105977. tessellation?: number;
  105978. radiusFunction?: {
  105979. (i: number, distance: number): number;
  105980. };
  105981. cap?: number;
  105982. arc?: number;
  105983. updatable?: boolean;
  105984. sideOrientation?: number;
  105985. frontUVs?: Vector4;
  105986. backUVs?: Vector4;
  105987. instance?: Mesh;
  105988. invertUV?: boolean;
  105989. }, scene: Scene): Mesh;
  105990. /**
  105991. * Creates a polyhedron mesh
  105992. * * 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
  105993. * * The parameter `size` (positive float, default 1) sets the polygon size
  105994. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105995. * * 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`
  105996. * * 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
  105997. * * 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)`)
  105998. * * 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
  105999. * * 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
  106000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106001. * * If you create a double-sided mesh, you can choose what parts of 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
  106002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106003. * @param name defines the name of the mesh
  106004. * @param options defines the options used to create the mesh
  106005. * @param scene defines the hosting scene
  106006. * @returns the polyhedron mesh
  106007. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106008. */
  106009. static CreatePolyhedron(name: string, options: {
  106010. type?: number;
  106011. size?: number;
  106012. sizeX?: number;
  106013. sizeY?: number;
  106014. sizeZ?: number;
  106015. custom?: any;
  106016. faceUV?: Vector4[];
  106017. faceColors?: Color4[];
  106018. flat?: boolean;
  106019. updatable?: boolean;
  106020. sideOrientation?: number;
  106021. frontUVs?: Vector4;
  106022. backUVs?: Vector4;
  106023. }, scene: Scene): Mesh;
  106024. /**
  106025. * Creates a decal mesh.
  106026. * 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
  106027. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106028. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106029. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106030. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106031. * @param name defines the name of the mesh
  106032. * @param sourceMesh defines the mesh where the decal must be applied
  106033. * @param options defines the options used to create the mesh
  106034. * @param scene defines the hosting scene
  106035. * @returns the decal mesh
  106036. * @see https://doc.babylonjs.com/how_to/decals
  106037. */
  106038. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106039. position?: Vector3;
  106040. normal?: Vector3;
  106041. size?: Vector3;
  106042. angle?: number;
  106043. }): Mesh;
  106044. }
  106045. }
  106046. declare module BABYLON {
  106047. /**
  106048. * A simplifier interface for future simplification implementations
  106049. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106050. */
  106051. export interface ISimplifier {
  106052. /**
  106053. * Simplification of a given mesh according to the given settings.
  106054. * Since this requires computation, it is assumed that the function runs async.
  106055. * @param settings The settings of the simplification, including quality and distance
  106056. * @param successCallback A callback that will be called after the mesh was simplified.
  106057. * @param errorCallback in case of an error, this callback will be called. optional.
  106058. */
  106059. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106060. }
  106061. /**
  106062. * Expected simplification settings.
  106063. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106064. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106065. */
  106066. export interface ISimplificationSettings {
  106067. /**
  106068. * Gets or sets the expected quality
  106069. */
  106070. quality: number;
  106071. /**
  106072. * Gets or sets the distance when this optimized version should be used
  106073. */
  106074. distance: number;
  106075. /**
  106076. * Gets an already optimized mesh
  106077. */
  106078. optimizeMesh?: boolean;
  106079. }
  106080. /**
  106081. * Class used to specify simplification options
  106082. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106083. */
  106084. export class SimplificationSettings implements ISimplificationSettings {
  106085. /** expected quality */
  106086. quality: number;
  106087. /** distance when this optimized version should be used */
  106088. distance: number;
  106089. /** already optimized mesh */
  106090. optimizeMesh?: boolean | undefined;
  106091. /**
  106092. * Creates a SimplificationSettings
  106093. * @param quality expected quality
  106094. * @param distance distance when this optimized version should be used
  106095. * @param optimizeMesh already optimized mesh
  106096. */
  106097. constructor(
  106098. /** expected quality */
  106099. quality: number,
  106100. /** distance when this optimized version should be used */
  106101. distance: number,
  106102. /** already optimized mesh */
  106103. optimizeMesh?: boolean | undefined);
  106104. }
  106105. /**
  106106. * Interface used to define a simplification task
  106107. */
  106108. export interface ISimplificationTask {
  106109. /**
  106110. * Array of settings
  106111. */
  106112. settings: Array<ISimplificationSettings>;
  106113. /**
  106114. * Simplification type
  106115. */
  106116. simplificationType: SimplificationType;
  106117. /**
  106118. * Mesh to simplify
  106119. */
  106120. mesh: Mesh;
  106121. /**
  106122. * Callback called on success
  106123. */
  106124. successCallback?: () => void;
  106125. /**
  106126. * Defines if parallel processing can be used
  106127. */
  106128. parallelProcessing: boolean;
  106129. }
  106130. /**
  106131. * Queue used to order the simplification tasks
  106132. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106133. */
  106134. export class SimplificationQueue {
  106135. private _simplificationArray;
  106136. /**
  106137. * Gets a boolean indicating that the process is still running
  106138. */
  106139. running: boolean;
  106140. /**
  106141. * Creates a new queue
  106142. */
  106143. constructor();
  106144. /**
  106145. * Adds a new simplification task
  106146. * @param task defines a task to add
  106147. */
  106148. addTask(task: ISimplificationTask): void;
  106149. /**
  106150. * Execute next task
  106151. */
  106152. executeNext(): void;
  106153. /**
  106154. * Execute a simplification task
  106155. * @param task defines the task to run
  106156. */
  106157. runSimplification(task: ISimplificationTask): void;
  106158. private getSimplifier;
  106159. }
  106160. /**
  106161. * The implemented types of simplification
  106162. * At the moment only Quadratic Error Decimation is implemented
  106163. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106164. */
  106165. export enum SimplificationType {
  106166. /** Quadratic error decimation */
  106167. QUADRATIC = 0
  106168. }
  106169. }
  106170. declare module BABYLON {
  106171. interface Scene {
  106172. /** @hidden (Backing field) */
  106173. _simplificationQueue: SimplificationQueue;
  106174. /**
  106175. * Gets or sets the simplification queue attached to the scene
  106176. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106177. */
  106178. simplificationQueue: SimplificationQueue;
  106179. }
  106180. interface Mesh {
  106181. /**
  106182. * Simplify the mesh according to the given array of settings.
  106183. * Function will return immediately and will simplify async
  106184. * @param settings a collection of simplification settings
  106185. * @param parallelProcessing should all levels calculate parallel or one after the other
  106186. * @param simplificationType the type of simplification to run
  106187. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106188. * @returns the current mesh
  106189. */
  106190. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106191. }
  106192. /**
  106193. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106194. * created in a scene
  106195. */
  106196. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106197. /**
  106198. * The component name helpfull to identify the component in the list of scene components.
  106199. */
  106200. readonly name: string;
  106201. /**
  106202. * The scene the component belongs to.
  106203. */
  106204. scene: Scene;
  106205. /**
  106206. * Creates a new instance of the component for the given scene
  106207. * @param scene Defines the scene to register the component in
  106208. */
  106209. constructor(scene: Scene);
  106210. /**
  106211. * Registers the component in a given scene
  106212. */
  106213. register(): void;
  106214. /**
  106215. * Rebuilds the elements related to this component in case of
  106216. * context lost for instance.
  106217. */
  106218. rebuild(): void;
  106219. /**
  106220. * Disposes the component and the associated ressources
  106221. */
  106222. dispose(): void;
  106223. private _beforeCameraUpdate;
  106224. }
  106225. }
  106226. declare module BABYLON {
  106227. /**
  106228. * Class used to enable access to IndexedDB
  106229. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106230. */
  106231. export class Database implements IOfflineProvider {
  106232. private _callbackManifestChecked;
  106233. private _currentSceneUrl;
  106234. private _db;
  106235. private _enableSceneOffline;
  106236. private _enableTexturesOffline;
  106237. private _manifestVersionFound;
  106238. private _mustUpdateRessources;
  106239. private _hasReachedQuota;
  106240. private _isSupported;
  106241. private _idbFactory;
  106242. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106243. private static IsUASupportingBlobStorage;
  106244. /**
  106245. * Gets a boolean indicating if Database storate is enabled (off by default)
  106246. */
  106247. static IDBStorageEnabled: boolean;
  106248. /**
  106249. * Gets a boolean indicating if scene must be saved in the database
  106250. */
  106251. readonly enableSceneOffline: boolean;
  106252. /**
  106253. * Gets a boolean indicating if textures must be saved in the database
  106254. */
  106255. readonly enableTexturesOffline: boolean;
  106256. /**
  106257. * Creates a new Database
  106258. * @param urlToScene defines the url to load the scene
  106259. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106260. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106261. */
  106262. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106263. private static _ParseURL;
  106264. private static _ReturnFullUrlLocation;
  106265. private _checkManifestFile;
  106266. /**
  106267. * Open the database and make it available
  106268. * @param successCallback defines the callback to call on success
  106269. * @param errorCallback defines the callback to call on error
  106270. */
  106271. open(successCallback: () => void, errorCallback: () => void): void;
  106272. /**
  106273. * Loads an image from the database
  106274. * @param url defines the url to load from
  106275. * @param image defines the target DOM image
  106276. */
  106277. loadImage(url: string, image: HTMLImageElement): void;
  106278. private _loadImageFromDBAsync;
  106279. private _saveImageIntoDBAsync;
  106280. private _checkVersionFromDB;
  106281. private _loadVersionFromDBAsync;
  106282. private _saveVersionIntoDBAsync;
  106283. /**
  106284. * Loads a file from database
  106285. * @param url defines the URL to load from
  106286. * @param sceneLoaded defines a callback to call on success
  106287. * @param progressCallBack defines a callback to call when progress changed
  106288. * @param errorCallback defines a callback to call on error
  106289. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106290. */
  106291. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  106292. private _loadFileAsync;
  106293. private _saveFileAsync;
  106294. /**
  106295. * Validates if xhr data is correct
  106296. * @param xhr defines the request to validate
  106297. * @param dataType defines the expected data type
  106298. * @returns true if data is correct
  106299. */
  106300. private static _ValidateXHRData;
  106301. }
  106302. }
  106303. declare module BABYLON {
  106304. /** @hidden */
  106305. export var gpuUpdateParticlesPixelShader: {
  106306. name: string;
  106307. shader: string;
  106308. };
  106309. }
  106310. declare module BABYLON {
  106311. /** @hidden */
  106312. export var gpuUpdateParticlesVertexShader: {
  106313. name: string;
  106314. shader: string;
  106315. };
  106316. }
  106317. declare module BABYLON {
  106318. /** @hidden */
  106319. export var clipPlaneFragmentDeclaration2: {
  106320. name: string;
  106321. shader: string;
  106322. };
  106323. }
  106324. declare module BABYLON {
  106325. /** @hidden */
  106326. export var gpuRenderParticlesPixelShader: {
  106327. name: string;
  106328. shader: string;
  106329. };
  106330. }
  106331. declare module BABYLON {
  106332. /** @hidden */
  106333. export var clipPlaneVertexDeclaration2: {
  106334. name: string;
  106335. shader: string;
  106336. };
  106337. }
  106338. declare module BABYLON {
  106339. /** @hidden */
  106340. export var gpuRenderParticlesVertexShader: {
  106341. name: string;
  106342. shader: string;
  106343. };
  106344. }
  106345. declare module BABYLON {
  106346. /**
  106347. * This represents a GPU particle system in Babylon
  106348. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106349. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106350. */
  106351. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  106352. /**
  106353. * The layer mask we are rendering the particles through.
  106354. */
  106355. layerMask: number;
  106356. private _capacity;
  106357. private _activeCount;
  106358. private _currentActiveCount;
  106359. private _accumulatedCount;
  106360. private _renderEffect;
  106361. private _updateEffect;
  106362. private _buffer0;
  106363. private _buffer1;
  106364. private _spriteBuffer;
  106365. private _updateVAO;
  106366. private _renderVAO;
  106367. private _targetIndex;
  106368. private _sourceBuffer;
  106369. private _targetBuffer;
  106370. private _engine;
  106371. private _currentRenderId;
  106372. private _started;
  106373. private _stopped;
  106374. private _timeDelta;
  106375. private _randomTexture;
  106376. private _randomTexture2;
  106377. private _attributesStrideSize;
  106378. private _updateEffectOptions;
  106379. private _randomTextureSize;
  106380. private _actualFrame;
  106381. private readonly _rawTextureWidth;
  106382. /**
  106383. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106384. */
  106385. static readonly IsSupported: boolean;
  106386. /**
  106387. * An event triggered when the system is disposed.
  106388. */
  106389. onDisposeObservable: Observable<GPUParticleSystem>;
  106390. /**
  106391. * Gets the maximum number of particles active at the same time.
  106392. * @returns The max number of active particles.
  106393. */
  106394. getCapacity(): number;
  106395. /**
  106396. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106397. * to override the particles.
  106398. */
  106399. forceDepthWrite: boolean;
  106400. /**
  106401. * Gets or set the number of active particles
  106402. */
  106403. activeParticleCount: number;
  106404. private _preWarmDone;
  106405. /**
  106406. * Is this system ready to be used/rendered
  106407. * @return true if the system is ready
  106408. */
  106409. isReady(): boolean;
  106410. /**
  106411. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106412. * @returns True if it has been started, otherwise false.
  106413. */
  106414. isStarted(): boolean;
  106415. /**
  106416. * Starts the particle system and begins to emit
  106417. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106418. */
  106419. start(delay?: number): void;
  106420. /**
  106421. * Stops the particle system.
  106422. */
  106423. stop(): void;
  106424. /**
  106425. * Remove all active particles
  106426. */
  106427. reset(): void;
  106428. /**
  106429. * Returns the string "GPUParticleSystem"
  106430. * @returns a string containing the class name
  106431. */
  106432. getClassName(): string;
  106433. private _colorGradientsTexture;
  106434. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  106435. /**
  106436. * Adds a new color gradient
  106437. * @param gradient defines the gradient to use (between 0 and 1)
  106438. * @param color1 defines the color to affect to the specified gradient
  106439. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106440. * @returns the current particle system
  106441. */
  106442. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  106443. /**
  106444. * Remove a specific color gradient
  106445. * @param gradient defines the gradient to remove
  106446. * @returns the current particle system
  106447. */
  106448. removeColorGradient(gradient: number): GPUParticleSystem;
  106449. private _angularSpeedGradientsTexture;
  106450. private _sizeGradientsTexture;
  106451. private _velocityGradientsTexture;
  106452. private _limitVelocityGradientsTexture;
  106453. private _dragGradientsTexture;
  106454. private _addFactorGradient;
  106455. /**
  106456. * Adds a new size gradient
  106457. * @param gradient defines the gradient to use (between 0 and 1)
  106458. * @param factor defines the size factor to affect to the specified gradient
  106459. * @returns the current particle system
  106460. */
  106461. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  106462. /**
  106463. * Remove a specific size gradient
  106464. * @param gradient defines the gradient to remove
  106465. * @returns the current particle system
  106466. */
  106467. removeSizeGradient(gradient: number): GPUParticleSystem;
  106468. /**
  106469. * Adds a new angular speed gradient
  106470. * @param gradient defines the gradient to use (between 0 and 1)
  106471. * @param factor defines the angular speed to affect to the specified gradient
  106472. * @returns the current particle system
  106473. */
  106474. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  106475. /**
  106476. * Remove a specific angular speed gradient
  106477. * @param gradient defines the gradient to remove
  106478. * @returns the current particle system
  106479. */
  106480. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  106481. /**
  106482. * Adds a new velocity gradient
  106483. * @param gradient defines the gradient to use (between 0 and 1)
  106484. * @param factor defines the velocity to affect to the specified gradient
  106485. * @returns the current particle system
  106486. */
  106487. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106488. /**
  106489. * Remove a specific velocity gradient
  106490. * @param gradient defines the gradient to remove
  106491. * @returns the current particle system
  106492. */
  106493. removeVelocityGradient(gradient: number): GPUParticleSystem;
  106494. /**
  106495. * Adds a new limit velocity gradient
  106496. * @param gradient defines the gradient to use (between 0 and 1)
  106497. * @param factor defines the limit velocity value to affect to the specified gradient
  106498. * @returns the current particle system
  106499. */
  106500. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106501. /**
  106502. * Remove a specific limit velocity gradient
  106503. * @param gradient defines the gradient to remove
  106504. * @returns the current particle system
  106505. */
  106506. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  106507. /**
  106508. * Adds a new drag gradient
  106509. * @param gradient defines the gradient to use (between 0 and 1)
  106510. * @param factor defines the drag value to affect to the specified gradient
  106511. * @returns the current particle system
  106512. */
  106513. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  106514. /**
  106515. * Remove a specific drag gradient
  106516. * @param gradient defines the gradient to remove
  106517. * @returns the current particle system
  106518. */
  106519. removeDragGradient(gradient: number): GPUParticleSystem;
  106520. /**
  106521. * Not supported by GPUParticleSystem
  106522. * @param gradient defines the gradient to use (between 0 and 1)
  106523. * @param factor defines the emit rate value to affect to the specified gradient
  106524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106525. * @returns the current particle system
  106526. */
  106527. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106528. /**
  106529. * Not supported by GPUParticleSystem
  106530. * @param gradient defines the gradient to remove
  106531. * @returns the current particle system
  106532. */
  106533. removeEmitRateGradient(gradient: number): IParticleSystem;
  106534. /**
  106535. * Not supported by GPUParticleSystem
  106536. * @param gradient defines the gradient to use (between 0 and 1)
  106537. * @param factor defines the start size value to affect to the specified gradient
  106538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106539. * @returns the current particle system
  106540. */
  106541. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106542. /**
  106543. * Not supported by GPUParticleSystem
  106544. * @param gradient defines the gradient to remove
  106545. * @returns the current particle system
  106546. */
  106547. removeStartSizeGradient(gradient: number): IParticleSystem;
  106548. /**
  106549. * Not supported by GPUParticleSystem
  106550. * @param gradient defines the gradient to use (between 0 and 1)
  106551. * @param min defines the color remap minimal range
  106552. * @param max defines the color remap maximal range
  106553. * @returns the current particle system
  106554. */
  106555. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  106556. /**
  106557. * Not supported by GPUParticleSystem
  106558. * @param gradient defines the gradient to remove
  106559. * @returns the current particle system
  106560. */
  106561. removeColorRemapGradient(): IParticleSystem;
  106562. /**
  106563. * Not supported by GPUParticleSystem
  106564. * @param gradient defines the gradient to use (between 0 and 1)
  106565. * @param min defines the alpha remap minimal range
  106566. * @param max defines the alpha remap maximal range
  106567. * @returns the current particle system
  106568. */
  106569. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  106570. /**
  106571. * Not supported by GPUParticleSystem
  106572. * @param gradient defines the gradient to remove
  106573. * @returns the current particle system
  106574. */
  106575. removeAlphaRemapGradient(): IParticleSystem;
  106576. /**
  106577. * Not supported by GPUParticleSystem
  106578. * @param gradient defines the gradient to use (between 0 and 1)
  106579. * @param color defines the color to affect to the specified gradient
  106580. * @returns the current particle system
  106581. */
  106582. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  106583. /**
  106584. * Not supported by GPUParticleSystem
  106585. * @param gradient defines the gradient to remove
  106586. * @returns the current particle system
  106587. */
  106588. removeRampGradient(): IParticleSystem;
  106589. /**
  106590. * Not supported by GPUParticleSystem
  106591. * @returns the list of ramp gradients
  106592. */
  106593. getRampGradients(): Nullable<Array<Color3Gradient>>;
  106594. /**
  106595. * Not supported by GPUParticleSystem
  106596. * Gets or sets a boolean indicating that ramp gradients must be used
  106597. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  106598. */
  106599. useRampGradients: boolean;
  106600. /**
  106601. * Not supported by GPUParticleSystem
  106602. * @param gradient defines the gradient to use (between 0 and 1)
  106603. * @param factor defines the life time factor to affect to the specified gradient
  106604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106605. * @returns the current particle system
  106606. */
  106607. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106608. /**
  106609. * Not supported by GPUParticleSystem
  106610. * @param gradient defines the gradient to remove
  106611. * @returns the current particle system
  106612. */
  106613. removeLifeTimeGradient(gradient: number): IParticleSystem;
  106614. /**
  106615. * Instantiates a GPU particle system.
  106616. * 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.
  106617. * @param name The name of the particle system
  106618. * @param options The options used to create the system
  106619. * @param scene The scene the particle system belongs to
  106620. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  106621. */
  106622. constructor(name: string, options: Partial<{
  106623. capacity: number;
  106624. randomTextureSize: number;
  106625. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  106626. protected _reset(): void;
  106627. private _createUpdateVAO;
  106628. private _createRenderVAO;
  106629. private _initialize;
  106630. /** @hidden */
  106631. _recreateUpdateEffect(): void;
  106632. /** @hidden */
  106633. _recreateRenderEffect(): void;
  106634. /**
  106635. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  106636. * @param preWarm defines if we are in the pre-warmimg phase
  106637. */
  106638. animate(preWarm?: boolean): void;
  106639. private _createFactorGradientTexture;
  106640. private _createSizeGradientTexture;
  106641. private _createAngularSpeedGradientTexture;
  106642. private _createVelocityGradientTexture;
  106643. private _createLimitVelocityGradientTexture;
  106644. private _createDragGradientTexture;
  106645. private _createColorGradientTexture;
  106646. /**
  106647. * Renders the particle system in its current state
  106648. * @param preWarm defines if the system should only update the particles but not render them
  106649. * @returns the current number of particles
  106650. */
  106651. render(preWarm?: boolean): number;
  106652. /**
  106653. * Rebuilds the particle system
  106654. */
  106655. rebuild(): void;
  106656. private _releaseBuffers;
  106657. private _releaseVAOs;
  106658. /**
  106659. * Disposes the particle system and free the associated resources
  106660. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106661. */
  106662. dispose(disposeTexture?: boolean): void;
  106663. /**
  106664. * Clones the particle system.
  106665. * @param name The name of the cloned object
  106666. * @param newEmitter The new emitter to use
  106667. * @returns the cloned particle system
  106668. */
  106669. clone(name: string, newEmitter: any): GPUParticleSystem;
  106670. /**
  106671. * Serializes the particle system to a JSON object.
  106672. * @returns the JSON object
  106673. */
  106674. serialize(): any;
  106675. /**
  106676. * Parses a JSON object to create a GPU particle system.
  106677. * @param parsedParticleSystem The JSON object to parse
  106678. * @param scene The scene to create the particle system in
  106679. * @param rootUrl The root url to use to load external dependencies like texture
  106680. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  106681. * @returns the parsed GPU particle system
  106682. */
  106683. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  106684. }
  106685. }
  106686. declare module BABYLON {
  106687. /**
  106688. * Represents a set of particle systems working together to create a specific effect
  106689. */
  106690. export class ParticleSystemSet implements IDisposable {
  106691. private _emitterCreationOptions;
  106692. private _emitterNode;
  106693. /**
  106694. * Gets the particle system list
  106695. */
  106696. systems: IParticleSystem[];
  106697. /**
  106698. * Gets the emitter node used with this set
  106699. */
  106700. readonly emitterNode: Nullable<TransformNode>;
  106701. /**
  106702. * Creates a new emitter mesh as a sphere
  106703. * @param options defines the options used to create the sphere
  106704. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  106705. * @param scene defines the hosting scene
  106706. */
  106707. setEmitterAsSphere(options: {
  106708. diameter: number;
  106709. segments: number;
  106710. color: Color3;
  106711. }, renderingGroupId: number, scene: Scene): void;
  106712. /**
  106713. * Starts all particle systems of the set
  106714. * @param emitter defines an optional mesh to use as emitter for the particle systems
  106715. */
  106716. start(emitter?: AbstractMesh): void;
  106717. /**
  106718. * Release all associated resources
  106719. */
  106720. dispose(): void;
  106721. /**
  106722. * Serialize the set into a JSON compatible object
  106723. * @returns a JSON compatible representation of the set
  106724. */
  106725. serialize(): any;
  106726. /**
  106727. * Parse a new ParticleSystemSet from a serialized source
  106728. * @param data defines a JSON compatible representation of the set
  106729. * @param scene defines the hosting scene
  106730. * @param gpu defines if we want GPU particles or CPU particles
  106731. * @returns a new ParticleSystemSet
  106732. */
  106733. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  106734. }
  106735. }
  106736. declare module BABYLON {
  106737. /**
  106738. * This class is made for on one-liner static method to help creating particle system set.
  106739. */
  106740. export class ParticleHelper {
  106741. /**
  106742. * Gets or sets base Assets URL
  106743. */
  106744. static BaseAssetsUrl: string;
  106745. /**
  106746. * Create a default particle system that you can tweak
  106747. * @param emitter defines the emitter to use
  106748. * @param capacity defines the system capacity (default is 500 particles)
  106749. * @param scene defines the hosting scene
  106750. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  106751. * @returns the new Particle system
  106752. */
  106753. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  106754. /**
  106755. * This is the main static method (one-liner) of this helper to create different particle systems
  106756. * @param type This string represents the type to the particle system to create
  106757. * @param scene The scene where the particle system should live
  106758. * @param gpu If the system will use gpu
  106759. * @returns the ParticleSystemSet created
  106760. */
  106761. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  106762. /**
  106763. * Static function used to export a particle system to a ParticleSystemSet variable.
  106764. * Please note that the emitter shape is not exported
  106765. * @param systems defines the particle systems to export
  106766. * @returns the created particle system set
  106767. */
  106768. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  106769. }
  106770. }
  106771. declare module BABYLON {
  106772. interface Engine {
  106773. /**
  106774. * Create an effect to use with particle systems.
  106775. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  106776. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  106777. * @param uniformsNames defines a list of attribute names
  106778. * @param samplers defines an array of string used to represent textures
  106779. * @param defines defines the string containing the defines to use to compile the shaders
  106780. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106781. * @param onCompiled defines a function to call when the effect creation is successful
  106782. * @param onError defines a function to call when the effect creation has failed
  106783. * @returns the new Effect
  106784. */
  106785. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  106786. }
  106787. interface Mesh {
  106788. /**
  106789. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  106790. * @returns an array of IParticleSystem
  106791. */
  106792. getEmittedParticleSystems(): IParticleSystem[];
  106793. /**
  106794. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  106795. * @returns an array of IParticleSystem
  106796. */
  106797. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  106798. }
  106799. /**
  106800. * @hidden
  106801. */
  106802. export var _IDoNeedToBeInTheBuild: number;
  106803. }
  106804. declare module BABYLON {
  106805. interface Scene {
  106806. /** @hidden (Backing field) */
  106807. _physicsEngine: Nullable<IPhysicsEngine>;
  106808. /**
  106809. * Gets the current physics engine
  106810. * @returns a IPhysicsEngine or null if none attached
  106811. */
  106812. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  106813. /**
  106814. * Enables physics to the current scene
  106815. * @param gravity defines the scene's gravity for the physics engine
  106816. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  106817. * @return a boolean indicating if the physics engine was initialized
  106818. */
  106819. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  106820. /**
  106821. * Disables and disposes the physics engine associated with the scene
  106822. */
  106823. disablePhysicsEngine(): void;
  106824. /**
  106825. * Gets a boolean indicating if there is an active physics engine
  106826. * @returns a boolean indicating if there is an active physics engine
  106827. */
  106828. isPhysicsEnabled(): boolean;
  106829. /**
  106830. * Deletes a physics compound impostor
  106831. * @param compound defines the compound to delete
  106832. */
  106833. deleteCompoundImpostor(compound: any): void;
  106834. /**
  106835. * An event triggered when physic simulation is about to be run
  106836. */
  106837. onBeforePhysicsObservable: Observable<Scene>;
  106838. /**
  106839. * An event triggered when physic simulation has been done
  106840. */
  106841. onAfterPhysicsObservable: Observable<Scene>;
  106842. }
  106843. interface AbstractMesh {
  106844. /** @hidden */
  106845. _physicsImpostor: Nullable<PhysicsImpostor>;
  106846. /**
  106847. * Gets or sets impostor used for physic simulation
  106848. * @see http://doc.babylonjs.com/features/physics_engine
  106849. */
  106850. physicsImpostor: Nullable<PhysicsImpostor>;
  106851. /**
  106852. * Gets the current physics impostor
  106853. * @see http://doc.babylonjs.com/features/physics_engine
  106854. * @returns a physics impostor or null
  106855. */
  106856. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  106857. /** Apply a physic impulse to the mesh
  106858. * @param force defines the force to apply
  106859. * @param contactPoint defines where to apply the force
  106860. * @returns the current mesh
  106861. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  106862. */
  106863. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  106864. /**
  106865. * Creates a physic joint between two meshes
  106866. * @param otherMesh defines the other mesh to use
  106867. * @param pivot1 defines the pivot to use on this mesh
  106868. * @param pivot2 defines the pivot to use on the other mesh
  106869. * @param options defines additional options (can be plugin dependent)
  106870. * @returns the current mesh
  106871. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  106872. */
  106873. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  106874. /** @hidden */
  106875. _disposePhysicsObserver: Nullable<Observer<Node>>;
  106876. }
  106877. /**
  106878. * Defines the physics engine scene component responsible to manage a physics engine
  106879. */
  106880. export class PhysicsEngineSceneComponent implements ISceneComponent {
  106881. /**
  106882. * The component name helpful to identify the component in the list of scene components.
  106883. */
  106884. readonly name: string;
  106885. /**
  106886. * The scene the component belongs to.
  106887. */
  106888. scene: Scene;
  106889. /**
  106890. * Creates a new instance of the component for the given scene
  106891. * @param scene Defines the scene to register the component in
  106892. */
  106893. constructor(scene: Scene);
  106894. /**
  106895. * Registers the component in a given scene
  106896. */
  106897. register(): void;
  106898. /**
  106899. * Rebuilds the elements related to this component in case of
  106900. * context lost for instance.
  106901. */
  106902. rebuild(): void;
  106903. /**
  106904. * Disposes the component and the associated ressources
  106905. */
  106906. dispose(): void;
  106907. }
  106908. }
  106909. declare module BABYLON {
  106910. /**
  106911. * A helper for physics simulations
  106912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106913. */
  106914. export class PhysicsHelper {
  106915. private _scene;
  106916. private _physicsEngine;
  106917. /**
  106918. * Initializes the Physics helper
  106919. * @param scene Babylon.js scene
  106920. */
  106921. constructor(scene: Scene);
  106922. /**
  106923. * Applies a radial explosion impulse
  106924. * @param origin the origin of the explosion
  106925. * @param radius the explosion radius
  106926. * @param strength the explosion strength
  106927. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106928. * @returns A physics radial explosion event, or null
  106929. */
  106930. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106931. /**
  106932. * Applies a radial explosion force
  106933. * @param origin the origin of the explosion
  106934. * @param radius the explosion radius
  106935. * @param strength the explosion strength
  106936. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106937. * @returns A physics radial explosion event, or null
  106938. */
  106939. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106940. /**
  106941. * Creates a gravitational field
  106942. * @param origin the origin of the explosion
  106943. * @param radius the explosion radius
  106944. * @param strength the explosion strength
  106945. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106946. * @returns A physics gravitational field event, or null
  106947. */
  106948. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  106949. /**
  106950. * Creates a physics updraft event
  106951. * @param origin the origin of the updraft
  106952. * @param radius the radius of the updraft
  106953. * @param strength the strength of the updraft
  106954. * @param height the height of the updraft
  106955. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  106956. * @returns A physics updraft event, or null
  106957. */
  106958. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  106959. /**
  106960. * Creates a physics vortex event
  106961. * @param origin the of the vortex
  106962. * @param radius the radius of the vortex
  106963. * @param strength the strength of the vortex
  106964. * @param height the height of the vortex
  106965. * @returns a Physics vortex event, or null
  106966. * A physics vortex event or null
  106967. */
  106968. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  106969. }
  106970. /**
  106971. * Represents a physics radial explosion event
  106972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106973. */
  106974. export class PhysicsRadialExplosionEvent {
  106975. private _scene;
  106976. private _sphere;
  106977. private _sphereOptions;
  106978. private _rays;
  106979. private _dataFetched;
  106980. /**
  106981. * Initializes a radial explosioin event
  106982. * @param scene BabylonJS scene
  106983. */
  106984. constructor(scene: Scene);
  106985. /**
  106986. * Returns the data related to the radial explosion event (sphere & rays).
  106987. * @returns The radial explosion event data
  106988. */
  106989. getData(): PhysicsRadialExplosionEventData;
  106990. /**
  106991. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  106992. * @param impostor A physics imposter
  106993. * @param origin the origin of the explosion
  106994. * @param radius the explosion radius
  106995. * @param strength the explosion strength
  106996. * @param falloff possible options: Constant & Linear
  106997. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  106998. */
  106999. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107000. /**
  107001. * Disposes the sphere.
  107002. * @param force Specifies if the sphere should be disposed by force
  107003. */
  107004. dispose(force?: boolean): void;
  107005. /*** Helpers ***/
  107006. private _prepareSphere;
  107007. private _intersectsWithSphere;
  107008. }
  107009. /**
  107010. * Represents a gravitational field event
  107011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107012. */
  107013. export class PhysicsGravitationalFieldEvent {
  107014. private _physicsHelper;
  107015. private _scene;
  107016. private _origin;
  107017. private _radius;
  107018. private _strength;
  107019. private _falloff;
  107020. private _tickCallback;
  107021. private _sphere;
  107022. private _dataFetched;
  107023. /**
  107024. * Initializes the physics gravitational field event
  107025. * @param physicsHelper A physics helper
  107026. * @param scene BabylonJS scene
  107027. * @param origin The origin position of the gravitational field event
  107028. * @param radius The radius of the gravitational field event
  107029. * @param strength The strength of the gravitational field event
  107030. * @param falloff The falloff for the gravitational field event
  107031. */
  107032. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107033. /**
  107034. * Returns the data related to the gravitational field event (sphere).
  107035. * @returns A gravitational field event
  107036. */
  107037. getData(): PhysicsGravitationalFieldEventData;
  107038. /**
  107039. * Enables the gravitational field.
  107040. */
  107041. enable(): void;
  107042. /**
  107043. * Disables the gravitational field.
  107044. */
  107045. disable(): void;
  107046. /**
  107047. * Disposes the sphere.
  107048. * @param force The force to dispose from the gravitational field event
  107049. */
  107050. dispose(force?: boolean): void;
  107051. private _tick;
  107052. }
  107053. /**
  107054. * Represents a physics updraft event
  107055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107056. */
  107057. export class PhysicsUpdraftEvent {
  107058. private _scene;
  107059. private _origin;
  107060. private _radius;
  107061. private _strength;
  107062. private _height;
  107063. private _updraftMode;
  107064. private _physicsEngine;
  107065. private _originTop;
  107066. private _originDirection;
  107067. private _tickCallback;
  107068. private _cylinder;
  107069. private _cylinderPosition;
  107070. private _dataFetched;
  107071. /**
  107072. * Initializes the physics updraft event
  107073. * @param _scene BabylonJS scene
  107074. * @param _origin The origin position of the updraft
  107075. * @param _radius The radius of the updraft
  107076. * @param _strength The strength of the updraft
  107077. * @param _height The height of the updraft
  107078. * @param _updraftMode The mode of the updraft
  107079. */
  107080. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107081. /**
  107082. * Returns the data related to the updraft event (cylinder).
  107083. * @returns A physics updraft event
  107084. */
  107085. getData(): PhysicsUpdraftEventData;
  107086. /**
  107087. * Enables the updraft.
  107088. */
  107089. enable(): void;
  107090. /**
  107091. * Disables the cortex.
  107092. */
  107093. disable(): void;
  107094. /**
  107095. * Disposes the sphere.
  107096. * @param force Specifies if the updraft should be disposed by force
  107097. */
  107098. dispose(force?: boolean): void;
  107099. private getImpostorForceAndContactPoint;
  107100. private _tick;
  107101. /*** Helpers ***/
  107102. private _prepareCylinder;
  107103. private _intersectsWithCylinder;
  107104. }
  107105. /**
  107106. * Represents a physics vortex event
  107107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107108. */
  107109. export class PhysicsVortexEvent {
  107110. private _scene;
  107111. private _origin;
  107112. private _radius;
  107113. private _strength;
  107114. private _height;
  107115. private _physicsEngine;
  107116. private _originTop;
  107117. private _centripetalForceThreshold;
  107118. private _updraftMultiplier;
  107119. private _tickCallback;
  107120. private _cylinder;
  107121. private _cylinderPosition;
  107122. private _dataFetched;
  107123. /**
  107124. * Initializes the physics vortex event
  107125. * @param _scene The BabylonJS scene
  107126. * @param _origin The origin position of the vortex
  107127. * @param _radius The radius of the vortex
  107128. * @param _strength The strength of the vortex
  107129. * @param _height The height of the vortex
  107130. */
  107131. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107132. /**
  107133. * Returns the data related to the vortex event (cylinder).
  107134. * @returns The physics vortex event data
  107135. */
  107136. getData(): PhysicsVortexEventData;
  107137. /**
  107138. * Enables the vortex.
  107139. */
  107140. enable(): void;
  107141. /**
  107142. * Disables the cortex.
  107143. */
  107144. disable(): void;
  107145. /**
  107146. * Disposes the sphere.
  107147. * @param force
  107148. */
  107149. dispose(force?: boolean): void;
  107150. private getImpostorForceAndContactPoint;
  107151. private _tick;
  107152. /*** Helpers ***/
  107153. private _prepareCylinder;
  107154. private _intersectsWithCylinder;
  107155. }
  107156. /**
  107157. * The strenght of the force in correspondence to the distance of the affected object
  107158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107159. */
  107160. export enum PhysicsRadialImpulseFalloff {
  107161. /** Defines that impulse is constant in strength across it's whole radius */
  107162. Constant = 0,
  107163. /** DEfines that impulse gets weaker if it's further from the origin */
  107164. Linear = 1
  107165. }
  107166. /**
  107167. * The strength of the force in correspondence to the distance of the affected object
  107168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107169. */
  107170. export enum PhysicsUpdraftMode {
  107171. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107172. Center = 0,
  107173. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107174. Perpendicular = 1
  107175. }
  107176. /**
  107177. * Interface for a physics force and contact point
  107178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107179. */
  107180. export interface PhysicsForceAndContactPoint {
  107181. /**
  107182. * The force applied at the contact point
  107183. */
  107184. force: Vector3;
  107185. /**
  107186. * The contact point
  107187. */
  107188. contactPoint: Vector3;
  107189. }
  107190. /**
  107191. * Interface for radial explosion event data
  107192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107193. */
  107194. export interface PhysicsRadialExplosionEventData {
  107195. /**
  107196. * A sphere used for the radial explosion event
  107197. */
  107198. sphere: Mesh;
  107199. /**
  107200. * An array of rays for the radial explosion event
  107201. */
  107202. rays: Array<Ray>;
  107203. }
  107204. /**
  107205. * Interface for gravitational field event data
  107206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107207. */
  107208. export interface PhysicsGravitationalFieldEventData {
  107209. /**
  107210. * A sphere mesh used for the gravitational field event
  107211. */
  107212. sphere: Mesh;
  107213. }
  107214. /**
  107215. * Interface for updraft event data
  107216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107217. */
  107218. export interface PhysicsUpdraftEventData {
  107219. /**
  107220. * A cylinder used for the updraft event
  107221. */
  107222. cylinder: Mesh;
  107223. }
  107224. /**
  107225. * Interface for vortex event data
  107226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107227. */
  107228. export interface PhysicsVortexEventData {
  107229. /**
  107230. * A cylinder used for the vortex event
  107231. */
  107232. cylinder: Mesh;
  107233. }
  107234. }
  107235. declare module BABYLON {
  107236. /**
  107237. * AmmoJS Physics plugin
  107238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107239. * @see https://github.com/kripken/ammo.js/
  107240. */
  107241. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107242. private _useDeltaForWorldStep;
  107243. /**
  107244. * Reference to the Ammo library
  107245. */
  107246. bjsAMMO: any;
  107247. /**
  107248. * Created ammoJS world which physics bodies are added to
  107249. */
  107250. world: any;
  107251. /**
  107252. * Name of the plugin
  107253. */
  107254. name: string;
  107255. private _timeStep;
  107256. private _fixedTimeStep;
  107257. private _maxSteps;
  107258. private _tmpQuaternion;
  107259. private _tmpAmmoTransform;
  107260. private _tmpAmmoQuaternion;
  107261. private _tmpAmmoConcreteContactResultCallback;
  107262. private _collisionConfiguration;
  107263. private _dispatcher;
  107264. private _overlappingPairCache;
  107265. private _solver;
  107266. private _tmpAmmoVectorA;
  107267. private _tmpAmmoVectorB;
  107268. private _tmpAmmoVectorC;
  107269. private _tmpContactCallbackResult;
  107270. private static readonly DISABLE_COLLISION_FLAG;
  107271. private static readonly KINEMATIC_FLAG;
  107272. private static readonly DISABLE_DEACTIVATION_FLAG;
  107273. /**
  107274. * Initializes the ammoJS plugin
  107275. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107276. * @param ammoInjection can be used to inject your own ammo reference
  107277. */
  107278. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107279. /**
  107280. * Sets the gravity of the physics world (m/(s^2))
  107281. * @param gravity Gravity to set
  107282. */
  107283. setGravity(gravity: Vector3): void;
  107284. /**
  107285. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107286. * @param timeStep timestep to use in seconds
  107287. */
  107288. setTimeStep(timeStep: number): void;
  107289. /**
  107290. * 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)
  107291. * @param fixedTimeStep fixedTimeStep to use in seconds
  107292. */
  107293. setFixedTimeStep(fixedTimeStep: number): void;
  107294. /**
  107295. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107296. * @param maxSteps the maximum number of steps by the physics engine per frame
  107297. */
  107298. setMaxSteps(maxSteps: number): void;
  107299. /**
  107300. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107301. * @returns the current timestep in seconds
  107302. */
  107303. getTimeStep(): number;
  107304. private _isImpostorInContact;
  107305. private _isImpostorPairInContact;
  107306. private _stepSimulation;
  107307. /**
  107308. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107309. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107310. * After the step the babylon meshes are set to the position of the physics imposters
  107311. * @param delta amount of time to step forward
  107312. * @param impostors array of imposters to update before/after the step
  107313. */
  107314. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107315. private _tmpVector;
  107316. private _tmpMatrix;
  107317. /**
  107318. * Applies an implulse on the imposter
  107319. * @param impostor imposter to apply impulse
  107320. * @param force amount of force to be applied to the imposter
  107321. * @param contactPoint the location to apply the impulse on the imposter
  107322. */
  107323. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107324. /**
  107325. * Applies a force on the imposter
  107326. * @param impostor imposter to apply force
  107327. * @param force amount of force to be applied to the imposter
  107328. * @param contactPoint the location to apply the force on the imposter
  107329. */
  107330. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107331. /**
  107332. * Creates a physics body using the plugin
  107333. * @param impostor the imposter to create the physics body on
  107334. */
  107335. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107336. /**
  107337. * Removes the physics body from the imposter and disposes of the body's memory
  107338. * @param impostor imposter to remove the physics body from
  107339. */
  107340. removePhysicsBody(impostor: PhysicsImpostor): void;
  107341. /**
  107342. * Generates a joint
  107343. * @param impostorJoint the imposter joint to create the joint with
  107344. */
  107345. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107346. /**
  107347. * Removes a joint
  107348. * @param impostorJoint the imposter joint to remove the joint from
  107349. */
  107350. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107351. private _addMeshVerts;
  107352. private _createShape;
  107353. /**
  107354. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107355. * @param impostor imposter containing the physics body and babylon object
  107356. */
  107357. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107358. /**
  107359. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107360. * @param impostor imposter containing the physics body and babylon object
  107361. * @param newPosition new position
  107362. * @param newRotation new rotation
  107363. */
  107364. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107365. /**
  107366. * If this plugin is supported
  107367. * @returns true if its supported
  107368. */
  107369. isSupported(): boolean;
  107370. /**
  107371. * Sets the linear velocity of the physics body
  107372. * @param impostor imposter to set the velocity on
  107373. * @param velocity velocity to set
  107374. */
  107375. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107376. /**
  107377. * Sets the angular velocity of the physics body
  107378. * @param impostor imposter to set the velocity on
  107379. * @param velocity velocity to set
  107380. */
  107381. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107382. /**
  107383. * gets the linear velocity
  107384. * @param impostor imposter to get linear velocity from
  107385. * @returns linear velocity
  107386. */
  107387. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107388. /**
  107389. * gets the angular velocity
  107390. * @param impostor imposter to get angular velocity from
  107391. * @returns angular velocity
  107392. */
  107393. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107394. /**
  107395. * Sets the mass of physics body
  107396. * @param impostor imposter to set the mass on
  107397. * @param mass mass to set
  107398. */
  107399. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107400. /**
  107401. * Gets the mass of the physics body
  107402. * @param impostor imposter to get the mass from
  107403. * @returns mass
  107404. */
  107405. getBodyMass(impostor: PhysicsImpostor): number;
  107406. /**
  107407. * Gets friction of the impostor
  107408. * @param impostor impostor to get friction from
  107409. * @returns friction value
  107410. */
  107411. getBodyFriction(impostor: PhysicsImpostor): number;
  107412. /**
  107413. * Sets friction of the impostor
  107414. * @param impostor impostor to set friction on
  107415. * @param friction friction value
  107416. */
  107417. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107418. /**
  107419. * Gets restitution of the impostor
  107420. * @param impostor impostor to get restitution from
  107421. * @returns restitution value
  107422. */
  107423. getBodyRestitution(impostor: PhysicsImpostor): number;
  107424. /**
  107425. * Sets resitution of the impostor
  107426. * @param impostor impostor to set resitution on
  107427. * @param restitution resitution value
  107428. */
  107429. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107430. /**
  107431. * Sleeps the physics body and stops it from being active
  107432. * @param impostor impostor to sleep
  107433. */
  107434. sleepBody(impostor: PhysicsImpostor): void;
  107435. /**
  107436. * Activates the physics body
  107437. * @param impostor impostor to activate
  107438. */
  107439. wakeUpBody(impostor: PhysicsImpostor): void;
  107440. /**
  107441. * Updates the distance parameters of the joint
  107442. * @param joint joint to update
  107443. * @param maxDistance maximum distance of the joint
  107444. * @param minDistance minimum distance of the joint
  107445. */
  107446. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107447. /**
  107448. * Sets a motor on the joint
  107449. * @param joint joint to set motor on
  107450. * @param speed speed of the motor
  107451. * @param maxForce maximum force of the motor
  107452. * @param motorIndex index of the motor
  107453. */
  107454. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107455. /**
  107456. * Sets the motors limit
  107457. * @param joint joint to set limit on
  107458. * @param upperLimit upper limit
  107459. * @param lowerLimit lower limit
  107460. */
  107461. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107462. /**
  107463. * Syncs the position and rotation of a mesh with the impostor
  107464. * @param mesh mesh to sync
  107465. * @param impostor impostor to update the mesh with
  107466. */
  107467. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107468. /**
  107469. * Gets the radius of the impostor
  107470. * @param impostor impostor to get radius from
  107471. * @returns the radius
  107472. */
  107473. getRadius(impostor: PhysicsImpostor): number;
  107474. /**
  107475. * Gets the box size of the impostor
  107476. * @param impostor impostor to get box size from
  107477. * @param result the resulting box size
  107478. */
  107479. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107480. /**
  107481. * Disposes of the impostor
  107482. */
  107483. dispose(): void;
  107484. }
  107485. }
  107486. declare module BABYLON {
  107487. /** @hidden */
  107488. export var blackAndWhitePixelShader: {
  107489. name: string;
  107490. shader: string;
  107491. };
  107492. }
  107493. declare module BABYLON {
  107494. /**
  107495. * Post process used to render in black and white
  107496. */
  107497. export class BlackAndWhitePostProcess extends PostProcess {
  107498. /**
  107499. * Linear about to convert he result to black and white (default: 1)
  107500. */
  107501. degree: number;
  107502. /**
  107503. * Creates a black and white post process
  107504. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  107505. * @param name The name of the effect.
  107506. * @param options The required width/height ratio to downsize to before computing the render pass.
  107507. * @param camera The camera to apply the render pass to.
  107508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107509. * @param engine The engine which the post process will be applied. (default: current engine)
  107510. * @param reusable If the post process can be reused on the same frame. (default: false)
  107511. */
  107512. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107513. }
  107514. }
  107515. declare module BABYLON {
  107516. /**
  107517. * This represents a set of one or more post processes in Babylon.
  107518. * A post process can be used to apply a shader to a texture after it is rendered.
  107519. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107520. */
  107521. export class PostProcessRenderEffect {
  107522. private _postProcesses;
  107523. private _getPostProcesses;
  107524. private _singleInstance;
  107525. private _cameras;
  107526. private _indicesForCamera;
  107527. /**
  107528. * Name of the effect
  107529. * @hidden
  107530. */
  107531. _name: string;
  107532. /**
  107533. * Instantiates a post process render effect.
  107534. * A post process can be used to apply a shader to a texture after it is rendered.
  107535. * @param engine The engine the effect is tied to
  107536. * @param name The name of the effect
  107537. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  107538. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  107539. */
  107540. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  107541. /**
  107542. * Checks if all the post processes in the effect are supported.
  107543. */
  107544. readonly isSupported: boolean;
  107545. /**
  107546. * Updates the current state of the effect
  107547. * @hidden
  107548. */
  107549. _update(): void;
  107550. /**
  107551. * Attaches the effect on cameras
  107552. * @param cameras The camera to attach to.
  107553. * @hidden
  107554. */
  107555. _attachCameras(cameras: Camera): void;
  107556. /**
  107557. * Attaches the effect on cameras
  107558. * @param cameras The camera to attach to.
  107559. * @hidden
  107560. */
  107561. _attachCameras(cameras: Camera[]): void;
  107562. /**
  107563. * Detatches the effect on cameras
  107564. * @param cameras The camera to detatch from.
  107565. * @hidden
  107566. */
  107567. _detachCameras(cameras: Camera): void;
  107568. /**
  107569. * Detatches the effect on cameras
  107570. * @param cameras The camera to detatch from.
  107571. * @hidden
  107572. */
  107573. _detachCameras(cameras: Camera[]): void;
  107574. /**
  107575. * Enables the effect on given cameras
  107576. * @param cameras The camera to enable.
  107577. * @hidden
  107578. */
  107579. _enable(cameras: Camera): void;
  107580. /**
  107581. * Enables the effect on given cameras
  107582. * @param cameras The camera to enable.
  107583. * @hidden
  107584. */
  107585. _enable(cameras: Nullable<Camera[]>): void;
  107586. /**
  107587. * Disables the effect on the given cameras
  107588. * @param cameras The camera to disable.
  107589. * @hidden
  107590. */
  107591. _disable(cameras: Camera): void;
  107592. /**
  107593. * Disables the effect on the given cameras
  107594. * @param cameras The camera to disable.
  107595. * @hidden
  107596. */
  107597. _disable(cameras: Nullable<Camera[]>): void;
  107598. /**
  107599. * Gets a list of the post processes contained in the effect.
  107600. * @param camera The camera to get the post processes on.
  107601. * @returns The list of the post processes in the effect.
  107602. */
  107603. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  107604. }
  107605. }
  107606. declare module BABYLON {
  107607. /** @hidden */
  107608. export var extractHighlightsPixelShader: {
  107609. name: string;
  107610. shader: string;
  107611. };
  107612. }
  107613. declare module BABYLON {
  107614. /**
  107615. * 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.
  107616. */
  107617. export class ExtractHighlightsPostProcess extends PostProcess {
  107618. /**
  107619. * The luminance threshold, pixels below this value will be set to black.
  107620. */
  107621. threshold: number;
  107622. /** @hidden */
  107623. _exposure: number;
  107624. /**
  107625. * Post process which has the input texture to be used when performing highlight extraction
  107626. * @hidden
  107627. */
  107628. _inputPostProcess: Nullable<PostProcess>;
  107629. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107630. }
  107631. }
  107632. declare module BABYLON {
  107633. /** @hidden */
  107634. export var bloomMergePixelShader: {
  107635. name: string;
  107636. shader: string;
  107637. };
  107638. }
  107639. declare module BABYLON {
  107640. /**
  107641. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  107642. */
  107643. export class BloomMergePostProcess extends PostProcess {
  107644. /** Weight of the bloom to be added to the original input. */
  107645. weight: number;
  107646. /**
  107647. * Creates a new instance of @see BloomMergePostProcess
  107648. * @param name The name of the effect.
  107649. * @param originalFromInput Post process which's input will be used for the merge.
  107650. * @param blurred Blurred highlights post process which's output will be used.
  107651. * @param weight Weight of the bloom to be added to the original input.
  107652. * @param options The required width/height ratio to downsize to before computing the render pass.
  107653. * @param camera The camera to apply the render pass to.
  107654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107655. * @param engine The engine which the post process will be applied. (default: current engine)
  107656. * @param reusable If the post process can be reused on the same frame. (default: false)
  107657. * @param textureType Type of textures used when performing the post process. (default: 0)
  107658. * @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)
  107659. */
  107660. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  107661. /** Weight of the bloom to be added to the original input. */
  107662. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107663. }
  107664. }
  107665. declare module BABYLON {
  107666. /**
  107667. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  107668. */
  107669. export class BloomEffect extends PostProcessRenderEffect {
  107670. private bloomScale;
  107671. /**
  107672. * @hidden Internal
  107673. */
  107674. _effects: Array<PostProcess>;
  107675. /**
  107676. * @hidden Internal
  107677. */
  107678. _downscale: ExtractHighlightsPostProcess;
  107679. private _blurX;
  107680. private _blurY;
  107681. private _merge;
  107682. /**
  107683. * The luminance threshold to find bright areas of the image to bloom.
  107684. */
  107685. threshold: number;
  107686. /**
  107687. * The strength of the bloom.
  107688. */
  107689. weight: number;
  107690. /**
  107691. * Specifies the size of the bloom blur kernel, relative to the final output size
  107692. */
  107693. kernel: number;
  107694. /**
  107695. * Creates a new instance of @see BloomEffect
  107696. * @param scene The scene the effect belongs to.
  107697. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  107698. * @param bloomKernel The size of the kernel to be used when applying the blur.
  107699. * @param bloomWeight The the strength of bloom.
  107700. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  107701. * @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)
  107702. */
  107703. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  107704. /**
  107705. * Disposes each of the internal effects for a given camera.
  107706. * @param camera The camera to dispose the effect on.
  107707. */
  107708. disposeEffects(camera: Camera): void;
  107709. /**
  107710. * @hidden Internal
  107711. */
  107712. _updateEffects(): void;
  107713. /**
  107714. * Internal
  107715. * @returns if all the contained post processes are ready.
  107716. * @hidden
  107717. */
  107718. _isReady(): boolean;
  107719. }
  107720. }
  107721. declare module BABYLON {
  107722. /** @hidden */
  107723. export var chromaticAberrationPixelShader: {
  107724. name: string;
  107725. shader: string;
  107726. };
  107727. }
  107728. declare module BABYLON {
  107729. /**
  107730. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  107731. */
  107732. export class ChromaticAberrationPostProcess extends PostProcess {
  107733. /**
  107734. * The amount of seperation of rgb channels (default: 30)
  107735. */
  107736. aberrationAmount: number;
  107737. /**
  107738. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  107739. */
  107740. radialIntensity: number;
  107741. /**
  107742. * 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))
  107743. */
  107744. direction: Vector2;
  107745. /**
  107746. * 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))
  107747. */
  107748. centerPosition: Vector2;
  107749. /**
  107750. * Creates a new instance ChromaticAberrationPostProcess
  107751. * @param name The name of the effect.
  107752. * @param screenWidth The width of the screen to apply the effect on.
  107753. * @param screenHeight The height of the screen to apply the effect on.
  107754. * @param options The required width/height ratio to downsize to before computing the render pass.
  107755. * @param camera The camera to apply the render pass to.
  107756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107757. * @param engine The engine which the post process will be applied. (default: current engine)
  107758. * @param reusable If the post process can be reused on the same frame. (default: false)
  107759. * @param textureType Type of textures used when performing the post process. (default: 0)
  107760. * @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)
  107761. */
  107762. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107763. }
  107764. }
  107765. declare module BABYLON {
  107766. /** @hidden */
  107767. export var circleOfConfusionPixelShader: {
  107768. name: string;
  107769. shader: string;
  107770. };
  107771. }
  107772. declare module BABYLON {
  107773. /**
  107774. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  107775. */
  107776. export class CircleOfConfusionPostProcess extends PostProcess {
  107777. /**
  107778. * 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.
  107779. */
  107780. lensSize: number;
  107781. /**
  107782. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  107783. */
  107784. fStop: number;
  107785. /**
  107786. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  107787. */
  107788. focusDistance: number;
  107789. /**
  107790. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  107791. */
  107792. focalLength: number;
  107793. private _depthTexture;
  107794. /**
  107795. * Creates a new instance CircleOfConfusionPostProcess
  107796. * @param name The name of the effect.
  107797. * @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.
  107798. * @param options The required width/height ratio to downsize to before computing the render pass.
  107799. * @param camera The camera to apply the render pass to.
  107800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107801. * @param engine The engine which the post process will be applied. (default: current engine)
  107802. * @param reusable If the post process can be reused on the same frame. (default: false)
  107803. * @param textureType Type of textures used when performing the post process. (default: 0)
  107804. * @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)
  107805. */
  107806. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107807. /**
  107808. * 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.
  107809. */
  107810. depthTexture: RenderTargetTexture;
  107811. }
  107812. }
  107813. declare module BABYLON {
  107814. /** @hidden */
  107815. export var colorCorrectionPixelShader: {
  107816. name: string;
  107817. shader: string;
  107818. };
  107819. }
  107820. declare module BABYLON {
  107821. /**
  107822. *
  107823. * This post-process allows the modification of rendered colors by using
  107824. * a 'look-up table' (LUT). This effect is also called Color Grading.
  107825. *
  107826. * The object needs to be provided an url to a texture containing the color
  107827. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  107828. * Use an image editing software to tweak the LUT to match your needs.
  107829. *
  107830. * For an example of a color LUT, see here:
  107831. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  107832. * For explanations on color grading, see here:
  107833. * @see http://udn.epicgames.com/Three/ColorGrading.html
  107834. *
  107835. */
  107836. export class ColorCorrectionPostProcess extends PostProcess {
  107837. private _colorTableTexture;
  107838. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107839. }
  107840. }
  107841. declare module BABYLON {
  107842. /** @hidden */
  107843. export var convolutionPixelShader: {
  107844. name: string;
  107845. shader: string;
  107846. };
  107847. }
  107848. declare module BABYLON {
  107849. /**
  107850. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  107851. * input texture to perform effects such as edge detection or sharpening
  107852. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  107853. */
  107854. export class ConvolutionPostProcess extends PostProcess {
  107855. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107856. kernel: number[];
  107857. /**
  107858. * Creates a new instance ConvolutionPostProcess
  107859. * @param name The name of the effect.
  107860. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  107861. * @param options The required width/height ratio to downsize to before computing the render pass.
  107862. * @param camera The camera to apply the render pass to.
  107863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107864. * @param engine The engine which the post process will be applied. (default: current engine)
  107865. * @param reusable If the post process can be reused on the same frame. (default: false)
  107866. * @param textureType Type of textures used when performing the post process. (default: 0)
  107867. */
  107868. constructor(name: string,
  107869. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107870. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  107871. /**
  107872. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107873. */
  107874. static EdgeDetect0Kernel: number[];
  107875. /**
  107876. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107877. */
  107878. static EdgeDetect1Kernel: number[];
  107879. /**
  107880. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107881. */
  107882. static EdgeDetect2Kernel: number[];
  107883. /**
  107884. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107885. */
  107886. static SharpenKernel: number[];
  107887. /**
  107888. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107889. */
  107890. static EmbossKernel: number[];
  107891. /**
  107892. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107893. */
  107894. static GaussianKernel: number[];
  107895. }
  107896. }
  107897. declare module BABYLON {
  107898. /**
  107899. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  107900. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  107901. * based on samples that have a large difference in distance than the center pixel.
  107902. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  107903. */
  107904. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  107905. direction: Vector2;
  107906. /**
  107907. * Creates a new instance CircleOfConfusionPostProcess
  107908. * @param name The name of the effect.
  107909. * @param scene The scene the effect belongs to.
  107910. * @param direction The direction the blur should be applied.
  107911. * @param kernel The size of the kernel used to blur.
  107912. * @param options The required width/height ratio to downsize to before computing the render pass.
  107913. * @param camera The camera to apply the render pass to.
  107914. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  107915. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  107916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107917. * @param engine The engine which the post process will be applied. (default: current engine)
  107918. * @param reusable If the post process can be reused on the same frame. (default: false)
  107919. * @param textureType Type of textures used when performing the post process. (default: 0)
  107920. * @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)
  107921. */
  107922. 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);
  107923. }
  107924. }
  107925. declare module BABYLON {
  107926. /** @hidden */
  107927. export var depthOfFieldMergePixelShader: {
  107928. name: string;
  107929. shader: string;
  107930. };
  107931. }
  107932. declare module BABYLON {
  107933. /**
  107934. * Options to be set when merging outputs from the default pipeline.
  107935. */
  107936. export class DepthOfFieldMergePostProcessOptions {
  107937. /**
  107938. * The original image to merge on top of
  107939. */
  107940. originalFromInput: PostProcess;
  107941. /**
  107942. * Parameters to perform the merge of the depth of field effect
  107943. */
  107944. depthOfField?: {
  107945. circleOfConfusion: PostProcess;
  107946. blurSteps: Array<PostProcess>;
  107947. };
  107948. /**
  107949. * Parameters to perform the merge of bloom effect
  107950. */
  107951. bloom?: {
  107952. blurred: PostProcess;
  107953. weight: number;
  107954. };
  107955. }
  107956. /**
  107957. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  107958. */
  107959. export class DepthOfFieldMergePostProcess extends PostProcess {
  107960. private blurSteps;
  107961. /**
  107962. * Creates a new instance of DepthOfFieldMergePostProcess
  107963. * @param name The name of the effect.
  107964. * @param originalFromInput Post process which's input will be used for the merge.
  107965. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  107966. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  107967. * @param options The required width/height ratio to downsize to before computing the render pass.
  107968. * @param camera The camera to apply the render pass to.
  107969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107970. * @param engine The engine which the post process will be applied. (default: current engine)
  107971. * @param reusable If the post process can be reused on the same frame. (default: false)
  107972. * @param textureType Type of textures used when performing the post process. (default: 0)
  107973. * @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)
  107974. */
  107975. 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);
  107976. /**
  107977. * Updates the effect with the current post process compile time values and recompiles the shader.
  107978. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  107979. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  107980. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  107981. * @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
  107982. * @param onCompiled Called when the shader has been compiled.
  107983. * @param onError Called if there is an error when compiling a shader.
  107984. */
  107985. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  107986. }
  107987. }
  107988. declare module BABYLON {
  107989. /**
  107990. * Specifies the level of max blur that should be applied when using the depth of field effect
  107991. */
  107992. export enum DepthOfFieldEffectBlurLevel {
  107993. /**
  107994. * Subtle blur
  107995. */
  107996. Low = 0,
  107997. /**
  107998. * Medium blur
  107999. */
  108000. Medium = 1,
  108001. /**
  108002. * Large blur
  108003. */
  108004. High = 2
  108005. }
  108006. /**
  108007. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108008. */
  108009. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108010. private _circleOfConfusion;
  108011. /**
  108012. * @hidden Internal, blurs from high to low
  108013. */
  108014. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108015. private _depthOfFieldBlurY;
  108016. private _dofMerge;
  108017. /**
  108018. * @hidden Internal post processes in depth of field effect
  108019. */
  108020. _effects: Array<PostProcess>;
  108021. /**
  108022. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108023. */
  108024. focalLength: number;
  108025. /**
  108026. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108027. */
  108028. fStop: number;
  108029. /**
  108030. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108031. */
  108032. focusDistance: number;
  108033. /**
  108034. * 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.
  108035. */
  108036. lensSize: number;
  108037. /**
  108038. * Creates a new instance DepthOfFieldEffect
  108039. * @param scene The scene the effect belongs to.
  108040. * @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.
  108041. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108042. * @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)
  108043. */
  108044. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108045. /**
  108046. * 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.
  108047. */
  108048. depthTexture: RenderTargetTexture;
  108049. /**
  108050. * Disposes each of the internal effects for a given camera.
  108051. * @param camera The camera to dispose the effect on.
  108052. */
  108053. disposeEffects(camera: Camera): void;
  108054. /**
  108055. * @hidden Internal
  108056. */
  108057. _updateEffects(): void;
  108058. /**
  108059. * Internal
  108060. * @returns if all the contained post processes are ready.
  108061. * @hidden
  108062. */
  108063. _isReady(): boolean;
  108064. }
  108065. }
  108066. declare module BABYLON {
  108067. /** @hidden */
  108068. export var displayPassPixelShader: {
  108069. name: string;
  108070. shader: string;
  108071. };
  108072. }
  108073. declare module BABYLON {
  108074. /**
  108075. * DisplayPassPostProcess which produces an output the same as it's input
  108076. */
  108077. export class DisplayPassPostProcess extends PostProcess {
  108078. /**
  108079. * Creates the DisplayPassPostProcess
  108080. * @param name The name of the effect.
  108081. * @param options The required width/height ratio to downsize to before computing the render pass.
  108082. * @param camera The camera to apply the render pass to.
  108083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108084. * @param engine The engine which the post process will be applied. (default: current engine)
  108085. * @param reusable If the post process can be reused on the same frame. (default: false)
  108086. */
  108087. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108088. }
  108089. }
  108090. declare module BABYLON {
  108091. /** @hidden */
  108092. export var filterPixelShader: {
  108093. name: string;
  108094. shader: string;
  108095. };
  108096. }
  108097. declare module BABYLON {
  108098. /**
  108099. * Applies a kernel filter to the image
  108100. */
  108101. export class FilterPostProcess extends PostProcess {
  108102. /** The matrix to be applied to the image */
  108103. kernelMatrix: Matrix;
  108104. /**
  108105. *
  108106. * @param name The name of the effect.
  108107. * @param kernelMatrix The matrix to be applied to the image
  108108. * @param options The required width/height ratio to downsize to before computing the render pass.
  108109. * @param camera The camera to apply the render pass to.
  108110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108111. * @param engine The engine which the post process will be applied. (default: current engine)
  108112. * @param reusable If the post process can be reused on the same frame. (default: false)
  108113. */
  108114. constructor(name: string,
  108115. /** The matrix to be applied to the image */
  108116. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108117. }
  108118. }
  108119. declare module BABYLON {
  108120. /** @hidden */
  108121. export var fxaaPixelShader: {
  108122. name: string;
  108123. shader: string;
  108124. };
  108125. }
  108126. declare module BABYLON {
  108127. /** @hidden */
  108128. export var fxaaVertexShader: {
  108129. name: string;
  108130. shader: string;
  108131. };
  108132. }
  108133. declare module BABYLON {
  108134. /**
  108135. * Fxaa post process
  108136. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108137. */
  108138. export class FxaaPostProcess extends PostProcess {
  108139. /** @hidden */
  108140. texelWidth: number;
  108141. /** @hidden */
  108142. texelHeight: number;
  108143. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108144. private _getDefines;
  108145. }
  108146. }
  108147. declare module BABYLON {
  108148. /** @hidden */
  108149. export var grainPixelShader: {
  108150. name: string;
  108151. shader: string;
  108152. };
  108153. }
  108154. declare module BABYLON {
  108155. /**
  108156. * The GrainPostProcess adds noise to the image at mid luminance levels
  108157. */
  108158. export class GrainPostProcess extends PostProcess {
  108159. /**
  108160. * The intensity of the grain added (default: 30)
  108161. */
  108162. intensity: number;
  108163. /**
  108164. * If the grain should be randomized on every frame
  108165. */
  108166. animated: boolean;
  108167. /**
  108168. * Creates a new instance of @see GrainPostProcess
  108169. * @param name The name of the effect.
  108170. * @param options The required width/height ratio to downsize to before computing the render pass.
  108171. * @param camera The camera to apply the render pass to.
  108172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108173. * @param engine The engine which the post process will be applied. (default: current engine)
  108174. * @param reusable If the post process can be reused on the same frame. (default: false)
  108175. * @param textureType Type of textures used when performing the post process. (default: 0)
  108176. * @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)
  108177. */
  108178. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108179. }
  108180. }
  108181. declare module BABYLON {
  108182. /** @hidden */
  108183. export var highlightsPixelShader: {
  108184. name: string;
  108185. shader: string;
  108186. };
  108187. }
  108188. declare module BABYLON {
  108189. /**
  108190. * Extracts highlights from the image
  108191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108192. */
  108193. export class HighlightsPostProcess extends PostProcess {
  108194. /**
  108195. * Extracts highlights from the image
  108196. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108197. * @param name The name of the effect.
  108198. * @param options The required width/height ratio to downsize to before computing the render pass.
  108199. * @param camera The camera to apply the render pass to.
  108200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108201. * @param engine The engine which the post process will be applied. (default: current engine)
  108202. * @param reusable If the post process can be reused on the same frame. (default: false)
  108203. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108204. */
  108205. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108206. }
  108207. }
  108208. declare module BABYLON {
  108209. /** @hidden */
  108210. export var mrtFragmentDeclaration: {
  108211. name: string;
  108212. shader: string;
  108213. };
  108214. }
  108215. declare module BABYLON {
  108216. /** @hidden */
  108217. export var geometryPixelShader: {
  108218. name: string;
  108219. shader: string;
  108220. };
  108221. }
  108222. declare module BABYLON {
  108223. /** @hidden */
  108224. export var geometryVertexShader: {
  108225. name: string;
  108226. shader: string;
  108227. };
  108228. }
  108229. declare module BABYLON {
  108230. /**
  108231. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108232. */
  108233. export class GeometryBufferRenderer {
  108234. /**
  108235. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108236. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108237. */
  108238. static readonly POSITION_TEXTURE_TYPE: number;
  108239. /**
  108240. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108241. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108242. */
  108243. static readonly VELOCITY_TEXTURE_TYPE: number;
  108244. /**
  108245. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108246. * in order to compute objects velocities when enableVelocity is set to "true"
  108247. * @hidden
  108248. */
  108249. _previousTransformationMatrices: {
  108250. [index: number]: Matrix;
  108251. };
  108252. private _scene;
  108253. private _multiRenderTarget;
  108254. private _ratio;
  108255. private _enablePosition;
  108256. private _enableVelocity;
  108257. private _positionIndex;
  108258. private _velocityIndex;
  108259. protected _effect: Effect;
  108260. protected _cachedDefines: string;
  108261. /**
  108262. * Set the render list (meshes to be rendered) used in the G buffer.
  108263. */
  108264. renderList: Mesh[];
  108265. /**
  108266. * Gets wether or not G buffer are supported by the running hardware.
  108267. * This requires draw buffer supports
  108268. */
  108269. readonly isSupported: boolean;
  108270. /**
  108271. * Returns the index of the given texture type in the G-Buffer textures array
  108272. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108273. * @returns the index of the given texture type in the G-Buffer textures array
  108274. */
  108275. getTextureIndex(textureType: number): number;
  108276. /**
  108277. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108278. */
  108279. /**
  108280. * Sets whether or not objects positions are enabled for the G buffer.
  108281. */
  108282. enablePosition: boolean;
  108283. /**
  108284. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108285. */
  108286. /**
  108287. * Sets wether or not objects velocities are enabled for the G buffer.
  108288. */
  108289. enableVelocity: boolean;
  108290. /**
  108291. * Gets the scene associated with the buffer.
  108292. */
  108293. readonly scene: Scene;
  108294. /**
  108295. * Gets the ratio used by the buffer during its creation.
  108296. * How big is the buffer related to the main canvas.
  108297. */
  108298. readonly ratio: number;
  108299. /** @hidden */
  108300. static _SceneComponentInitialization: (scene: Scene) => void;
  108301. /**
  108302. * Creates a new G Buffer for the scene
  108303. * @param scene The scene the buffer belongs to
  108304. * @param ratio How big is the buffer related to the main canvas.
  108305. */
  108306. constructor(scene: Scene, ratio?: number);
  108307. /**
  108308. * Checks wether everything is ready to render a submesh to the G buffer.
  108309. * @param subMesh the submesh to check readiness for
  108310. * @param useInstances is the mesh drawn using instance or not
  108311. * @returns true if ready otherwise false
  108312. */
  108313. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108314. /**
  108315. * Gets the current underlying G Buffer.
  108316. * @returns the buffer
  108317. */
  108318. getGBuffer(): MultiRenderTarget;
  108319. /**
  108320. * Gets the number of samples used to render the buffer (anti aliasing).
  108321. */
  108322. /**
  108323. * Sets the number of samples used to render the buffer (anti aliasing).
  108324. */
  108325. samples: number;
  108326. /**
  108327. * Disposes the renderer and frees up associated resources.
  108328. */
  108329. dispose(): void;
  108330. protected _createRenderTargets(): void;
  108331. }
  108332. }
  108333. declare module BABYLON {
  108334. /** @hidden */
  108335. export var motionBlurPixelShader: {
  108336. name: string;
  108337. shader: string;
  108338. };
  108339. }
  108340. declare module BABYLON {
  108341. /**
  108342. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  108343. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  108344. * As an example, all you have to do is to create the post-process:
  108345. * var mb = new BABYLON.MotionBlurPostProcess(
  108346. * 'mb', // The name of the effect.
  108347. * scene, // The scene containing the objects to blur according to their velocity.
  108348. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  108349. * camera // The camera to apply the render pass to.
  108350. * );
  108351. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  108352. */
  108353. export class MotionBlurPostProcess extends PostProcess {
  108354. /**
  108355. * Defines how much the image is blurred by the movement. Default value is equal to 1
  108356. */
  108357. motionStrength: number;
  108358. /**
  108359. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  108360. */
  108361. /**
  108362. * Sets the number of iterations to be used for motion blur quality
  108363. */
  108364. motionBlurSamples: number;
  108365. private _motionBlurSamples;
  108366. private _geometryBufferRenderer;
  108367. /**
  108368. * Creates a new instance MotionBlurPostProcess
  108369. * @param name The name of the effect.
  108370. * @param scene The scene containing the objects to blur according to their velocity.
  108371. * @param options The required width/height ratio to downsize to before computing the render pass.
  108372. * @param camera The camera to apply the render pass to.
  108373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108374. * @param engine The engine which the post process will be applied. (default: current engine)
  108375. * @param reusable If the post process can be reused on the same frame. (default: false)
  108376. * @param textureType Type of textures used when performing the post process. (default: 0)
  108377. * @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)
  108378. */
  108379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108380. /**
  108381. * Disposes the post process.
  108382. * @param camera The camera to dispose the post process on.
  108383. */
  108384. dispose(camera?: Camera): void;
  108385. }
  108386. }
  108387. declare module BABYLON {
  108388. /** @hidden */
  108389. export var refractionPixelShader: {
  108390. name: string;
  108391. shader: string;
  108392. };
  108393. }
  108394. declare module BABYLON {
  108395. /**
  108396. * Post process which applies a refractin texture
  108397. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108398. */
  108399. export class RefractionPostProcess extends PostProcess {
  108400. /** the base color of the refraction (used to taint the rendering) */
  108401. color: Color3;
  108402. /** simulated refraction depth */
  108403. depth: number;
  108404. /** the coefficient of the base color (0 to remove base color tainting) */
  108405. colorLevel: number;
  108406. private _refTexture;
  108407. private _ownRefractionTexture;
  108408. /**
  108409. * Gets or sets the refraction texture
  108410. * Please note that you are responsible for disposing the texture if you set it manually
  108411. */
  108412. refractionTexture: Texture;
  108413. /**
  108414. * Initializes the RefractionPostProcess
  108415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108416. * @param name The name of the effect.
  108417. * @param refractionTextureUrl Url of the refraction texture to use
  108418. * @param color the base color of the refraction (used to taint the rendering)
  108419. * @param depth simulated refraction depth
  108420. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  108421. * @param camera The camera to apply the render pass to.
  108422. * @param options The required width/height ratio to downsize to before computing the render pass.
  108423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108424. * @param engine The engine which the post process will be applied. (default: current engine)
  108425. * @param reusable If the post process can be reused on the same frame. (default: false)
  108426. */
  108427. constructor(name: string, refractionTextureUrl: string,
  108428. /** the base color of the refraction (used to taint the rendering) */
  108429. color: Color3,
  108430. /** simulated refraction depth */
  108431. depth: number,
  108432. /** the coefficient of the base color (0 to remove base color tainting) */
  108433. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108434. /**
  108435. * Disposes of the post process
  108436. * @param camera Camera to dispose post process on
  108437. */
  108438. dispose(camera: Camera): void;
  108439. }
  108440. }
  108441. declare module BABYLON {
  108442. /** @hidden */
  108443. export var sharpenPixelShader: {
  108444. name: string;
  108445. shader: string;
  108446. };
  108447. }
  108448. declare module BABYLON {
  108449. /**
  108450. * The SharpenPostProcess applies a sharpen kernel to every pixel
  108451. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108452. */
  108453. export class SharpenPostProcess extends PostProcess {
  108454. /**
  108455. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  108456. */
  108457. colorAmount: number;
  108458. /**
  108459. * How much sharpness should be applied (default: 0.3)
  108460. */
  108461. edgeAmount: number;
  108462. /**
  108463. * Creates a new instance ConvolutionPostProcess
  108464. * @param name The name of the effect.
  108465. * @param options The required width/height ratio to downsize to before computing the render pass.
  108466. * @param camera The camera to apply the render pass to.
  108467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108468. * @param engine The engine which the post process will be applied. (default: current engine)
  108469. * @param reusable If the post process can be reused on the same frame. (default: false)
  108470. * @param textureType Type of textures used when performing the post process. (default: 0)
  108471. * @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)
  108472. */
  108473. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108474. }
  108475. }
  108476. declare module BABYLON {
  108477. /**
  108478. * PostProcessRenderPipeline
  108479. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108480. */
  108481. export class PostProcessRenderPipeline {
  108482. private engine;
  108483. private _renderEffects;
  108484. private _renderEffectsForIsolatedPass;
  108485. /**
  108486. * @hidden
  108487. */
  108488. protected _cameras: Camera[];
  108489. /** @hidden */
  108490. _name: string;
  108491. /**
  108492. * Gets pipeline name
  108493. */
  108494. readonly name: string;
  108495. /**
  108496. * Initializes a PostProcessRenderPipeline
  108497. * @param engine engine to add the pipeline to
  108498. * @param name name of the pipeline
  108499. */
  108500. constructor(engine: Engine, name: string);
  108501. /**
  108502. * Gets the class name
  108503. * @returns "PostProcessRenderPipeline"
  108504. */
  108505. getClassName(): string;
  108506. /**
  108507. * If all the render effects in the pipeline are supported
  108508. */
  108509. readonly isSupported: boolean;
  108510. /**
  108511. * Adds an effect to the pipeline
  108512. * @param renderEffect the effect to add
  108513. */
  108514. addEffect(renderEffect: PostProcessRenderEffect): void;
  108515. /** @hidden */
  108516. _rebuild(): void;
  108517. /** @hidden */
  108518. _enableEffect(renderEffectName: string, cameras: Camera): void;
  108519. /** @hidden */
  108520. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  108521. /** @hidden */
  108522. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  108523. /** @hidden */
  108524. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  108525. /** @hidden */
  108526. _attachCameras(cameras: Camera, unique: boolean): void;
  108527. /** @hidden */
  108528. _attachCameras(cameras: Camera[], unique: boolean): void;
  108529. /** @hidden */
  108530. _detachCameras(cameras: Camera): void;
  108531. /** @hidden */
  108532. _detachCameras(cameras: Nullable<Camera[]>): void;
  108533. /** @hidden */
  108534. _update(): void;
  108535. /** @hidden */
  108536. _reset(): void;
  108537. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  108538. /**
  108539. * Disposes of the pipeline
  108540. */
  108541. dispose(): void;
  108542. }
  108543. }
  108544. declare module BABYLON {
  108545. /**
  108546. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  108547. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  108548. */
  108549. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  108550. private _scene;
  108551. private _camerasToBeAttached;
  108552. /**
  108553. * ID of the sharpen post process,
  108554. */
  108555. private readonly SharpenPostProcessId;
  108556. /**
  108557. * @ignore
  108558. * ID of the image processing post process;
  108559. */
  108560. readonly ImageProcessingPostProcessId: string;
  108561. /**
  108562. * @ignore
  108563. * ID of the Fast Approximate Anti-Aliasing post process;
  108564. */
  108565. readonly FxaaPostProcessId: string;
  108566. /**
  108567. * ID of the chromatic aberration post process,
  108568. */
  108569. private readonly ChromaticAberrationPostProcessId;
  108570. /**
  108571. * ID of the grain post process
  108572. */
  108573. private readonly GrainPostProcessId;
  108574. /**
  108575. * Sharpen post process which will apply a sharpen convolution to enhance edges
  108576. */
  108577. sharpen: SharpenPostProcess;
  108578. private _sharpenEffect;
  108579. private bloom;
  108580. /**
  108581. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  108582. */
  108583. depthOfField: DepthOfFieldEffect;
  108584. /**
  108585. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  108586. */
  108587. fxaa: FxaaPostProcess;
  108588. /**
  108589. * Image post processing pass used to perform operations such as tone mapping or color grading.
  108590. */
  108591. imageProcessing: ImageProcessingPostProcess;
  108592. /**
  108593. * Chromatic aberration post process which will shift rgb colors in the image
  108594. */
  108595. chromaticAberration: ChromaticAberrationPostProcess;
  108596. private _chromaticAberrationEffect;
  108597. /**
  108598. * Grain post process which add noise to the image
  108599. */
  108600. grain: GrainPostProcess;
  108601. private _grainEffect;
  108602. /**
  108603. * Glow post process which adds a glow to emissive areas of the image
  108604. */
  108605. private _glowLayer;
  108606. /**
  108607. * Animations which can be used to tweak settings over a period of time
  108608. */
  108609. animations: Animation[];
  108610. private _imageProcessingConfigurationObserver;
  108611. private _sharpenEnabled;
  108612. private _bloomEnabled;
  108613. private _depthOfFieldEnabled;
  108614. private _depthOfFieldBlurLevel;
  108615. private _fxaaEnabled;
  108616. private _imageProcessingEnabled;
  108617. private _defaultPipelineTextureType;
  108618. private _bloomScale;
  108619. private _chromaticAberrationEnabled;
  108620. private _grainEnabled;
  108621. private _buildAllowed;
  108622. /**
  108623. * Gets active scene
  108624. */
  108625. readonly scene: Scene;
  108626. /**
  108627. * Enable or disable the sharpen process from the pipeline
  108628. */
  108629. sharpenEnabled: boolean;
  108630. private _resizeObserver;
  108631. private _hardwareScaleLevel;
  108632. private _bloomKernel;
  108633. /**
  108634. * Specifies the size of the bloom blur kernel, relative to the final output size
  108635. */
  108636. bloomKernel: number;
  108637. /**
  108638. * Specifies the weight of the bloom in the final rendering
  108639. */
  108640. private _bloomWeight;
  108641. /**
  108642. * Specifies the luma threshold for the area that will be blurred by the bloom
  108643. */
  108644. private _bloomThreshold;
  108645. private _hdr;
  108646. /**
  108647. * The strength of the bloom.
  108648. */
  108649. bloomWeight: number;
  108650. /**
  108651. * The strength of the bloom.
  108652. */
  108653. bloomThreshold: number;
  108654. /**
  108655. * The scale of the bloom, lower value will provide better performance.
  108656. */
  108657. bloomScale: number;
  108658. /**
  108659. * Enable or disable the bloom from the pipeline
  108660. */
  108661. bloomEnabled: boolean;
  108662. private _rebuildBloom;
  108663. /**
  108664. * If the depth of field is enabled.
  108665. */
  108666. depthOfFieldEnabled: boolean;
  108667. /**
  108668. * Blur level of the depth of field effect. (Higher blur will effect performance)
  108669. */
  108670. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  108671. /**
  108672. * If the anti aliasing is enabled.
  108673. */
  108674. fxaaEnabled: boolean;
  108675. private _samples;
  108676. /**
  108677. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  108678. */
  108679. samples: number;
  108680. /**
  108681. * If image processing is enabled.
  108682. */
  108683. imageProcessingEnabled: boolean;
  108684. /**
  108685. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  108686. */
  108687. glowLayerEnabled: boolean;
  108688. /**
  108689. * Enable or disable the chromaticAberration process from the pipeline
  108690. */
  108691. chromaticAberrationEnabled: boolean;
  108692. /**
  108693. * Enable or disable the grain process from the pipeline
  108694. */
  108695. grainEnabled: boolean;
  108696. /**
  108697. * @constructor
  108698. * @param name - The rendering pipeline name (default: "")
  108699. * @param hdr - If high dynamic range textures should be used (default: true)
  108700. * @param scene - The scene linked to this pipeline (default: the last created scene)
  108701. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  108702. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  108703. */
  108704. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  108705. /**
  108706. * Get the class name
  108707. * @returns "DefaultRenderingPipeline"
  108708. */
  108709. getClassName(): string;
  108710. /**
  108711. * Force the compilation of the entire pipeline.
  108712. */
  108713. prepare(): void;
  108714. private _hasCleared;
  108715. private _prevPostProcess;
  108716. private _prevPrevPostProcess;
  108717. private _setAutoClearAndTextureSharing;
  108718. private _depthOfFieldSceneObserver;
  108719. private _buildPipeline;
  108720. private _disposePostProcesses;
  108721. /**
  108722. * Adds a camera to the pipeline
  108723. * @param camera the camera to be added
  108724. */
  108725. addCamera(camera: Camera): void;
  108726. /**
  108727. * Removes a camera from the pipeline
  108728. * @param camera the camera to remove
  108729. */
  108730. removeCamera(camera: Camera): void;
  108731. /**
  108732. * Dispose of the pipeline and stop all post processes
  108733. */
  108734. dispose(): void;
  108735. /**
  108736. * Serialize the rendering pipeline (Used when exporting)
  108737. * @returns the serialized object
  108738. */
  108739. serialize(): any;
  108740. /**
  108741. * Parse the serialized pipeline
  108742. * @param source Source pipeline.
  108743. * @param scene The scene to load the pipeline to.
  108744. * @param rootUrl The URL of the serialized pipeline.
  108745. * @returns An instantiated pipeline from the serialized object.
  108746. */
  108747. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  108748. }
  108749. }
  108750. declare module BABYLON {
  108751. /** @hidden */
  108752. export var lensHighlightsPixelShader: {
  108753. name: string;
  108754. shader: string;
  108755. };
  108756. }
  108757. declare module BABYLON {
  108758. /** @hidden */
  108759. export var depthOfFieldPixelShader: {
  108760. name: string;
  108761. shader: string;
  108762. };
  108763. }
  108764. declare module BABYLON {
  108765. /**
  108766. * BABYLON.JS Chromatic Aberration GLSL Shader
  108767. * Author: Olivier Guyot
  108768. * Separates very slightly R, G and B colors on the edges of the screen
  108769. * Inspired by Francois Tarlier & Martins Upitis
  108770. */
  108771. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  108772. /**
  108773. * @ignore
  108774. * The chromatic aberration PostProcess id in the pipeline
  108775. */
  108776. LensChromaticAberrationEffect: string;
  108777. /**
  108778. * @ignore
  108779. * The highlights enhancing PostProcess id in the pipeline
  108780. */
  108781. HighlightsEnhancingEffect: string;
  108782. /**
  108783. * @ignore
  108784. * The depth-of-field PostProcess id in the pipeline
  108785. */
  108786. LensDepthOfFieldEffect: string;
  108787. private _scene;
  108788. private _depthTexture;
  108789. private _grainTexture;
  108790. private _chromaticAberrationPostProcess;
  108791. private _highlightsPostProcess;
  108792. private _depthOfFieldPostProcess;
  108793. private _edgeBlur;
  108794. private _grainAmount;
  108795. private _chromaticAberration;
  108796. private _distortion;
  108797. private _highlightsGain;
  108798. private _highlightsThreshold;
  108799. private _dofDistance;
  108800. private _dofAperture;
  108801. private _dofDarken;
  108802. private _dofPentagon;
  108803. private _blurNoise;
  108804. /**
  108805. * @constructor
  108806. *
  108807. * Effect parameters are as follow:
  108808. * {
  108809. * chromatic_aberration: number; // from 0 to x (1 for realism)
  108810. * edge_blur: number; // from 0 to x (1 for realism)
  108811. * distortion: number; // from 0 to x (1 for realism)
  108812. * grain_amount: number; // from 0 to 1
  108813. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  108814. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  108815. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  108816. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  108817. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  108818. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  108819. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  108820. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  108821. * }
  108822. * Note: if an effect parameter is unset, effect is disabled
  108823. *
  108824. * @param name The rendering pipeline name
  108825. * @param parameters - An object containing all parameters (see above)
  108826. * @param scene The scene linked to this pipeline
  108827. * @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)
  108828. * @param cameras The array of cameras that the rendering pipeline will be attached to
  108829. */
  108830. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  108831. /**
  108832. * Sets the amount of blur at the edges
  108833. * @param amount blur amount
  108834. */
  108835. setEdgeBlur(amount: number): void;
  108836. /**
  108837. * Sets edge blur to 0
  108838. */
  108839. disableEdgeBlur(): void;
  108840. /**
  108841. * Sets the amout of grain
  108842. * @param amount Amount of grain
  108843. */
  108844. setGrainAmount(amount: number): void;
  108845. /**
  108846. * Set grain amount to 0
  108847. */
  108848. disableGrain(): void;
  108849. /**
  108850. * Sets the chromatic aberration amount
  108851. * @param amount amount of chromatic aberration
  108852. */
  108853. setChromaticAberration(amount: number): void;
  108854. /**
  108855. * Sets chromatic aberration amount to 0
  108856. */
  108857. disableChromaticAberration(): void;
  108858. /**
  108859. * Sets the EdgeDistortion amount
  108860. * @param amount amount of EdgeDistortion
  108861. */
  108862. setEdgeDistortion(amount: number): void;
  108863. /**
  108864. * Sets edge distortion to 0
  108865. */
  108866. disableEdgeDistortion(): void;
  108867. /**
  108868. * Sets the FocusDistance amount
  108869. * @param amount amount of FocusDistance
  108870. */
  108871. setFocusDistance(amount: number): void;
  108872. /**
  108873. * Disables depth of field
  108874. */
  108875. disableDepthOfField(): void;
  108876. /**
  108877. * Sets the Aperture amount
  108878. * @param amount amount of Aperture
  108879. */
  108880. setAperture(amount: number): void;
  108881. /**
  108882. * Sets the DarkenOutOfFocus amount
  108883. * @param amount amount of DarkenOutOfFocus
  108884. */
  108885. setDarkenOutOfFocus(amount: number): void;
  108886. /**
  108887. * Creates a pentagon bokeh effect
  108888. */
  108889. enablePentagonBokeh(): void;
  108890. /**
  108891. * Disables the pentagon bokeh effect
  108892. */
  108893. disablePentagonBokeh(): void;
  108894. /**
  108895. * Enables noise blur
  108896. */
  108897. enableNoiseBlur(): void;
  108898. /**
  108899. * Disables noise blur
  108900. */
  108901. disableNoiseBlur(): void;
  108902. /**
  108903. * Sets the HighlightsGain amount
  108904. * @param amount amount of HighlightsGain
  108905. */
  108906. setHighlightsGain(amount: number): void;
  108907. /**
  108908. * Sets the HighlightsThreshold amount
  108909. * @param amount amount of HighlightsThreshold
  108910. */
  108911. setHighlightsThreshold(amount: number): void;
  108912. /**
  108913. * Disables highlights
  108914. */
  108915. disableHighlights(): void;
  108916. /**
  108917. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  108918. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  108919. */
  108920. dispose(disableDepthRender?: boolean): void;
  108921. private _createChromaticAberrationPostProcess;
  108922. private _createHighlightsPostProcess;
  108923. private _createDepthOfFieldPostProcess;
  108924. private _createGrainTexture;
  108925. }
  108926. }
  108927. declare module BABYLON {
  108928. /** @hidden */
  108929. export var ssao2PixelShader: {
  108930. name: string;
  108931. shader: string;
  108932. };
  108933. }
  108934. declare module BABYLON {
  108935. /** @hidden */
  108936. export var ssaoCombinePixelShader: {
  108937. name: string;
  108938. shader: string;
  108939. };
  108940. }
  108941. declare module BABYLON {
  108942. /**
  108943. * Render pipeline to produce ssao effect
  108944. */
  108945. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  108946. /**
  108947. * @ignore
  108948. * The PassPostProcess id in the pipeline that contains the original scene color
  108949. */
  108950. SSAOOriginalSceneColorEffect: string;
  108951. /**
  108952. * @ignore
  108953. * The SSAO PostProcess id in the pipeline
  108954. */
  108955. SSAORenderEffect: string;
  108956. /**
  108957. * @ignore
  108958. * The horizontal blur PostProcess id in the pipeline
  108959. */
  108960. SSAOBlurHRenderEffect: string;
  108961. /**
  108962. * @ignore
  108963. * The vertical blur PostProcess id in the pipeline
  108964. */
  108965. SSAOBlurVRenderEffect: string;
  108966. /**
  108967. * @ignore
  108968. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  108969. */
  108970. SSAOCombineRenderEffect: string;
  108971. /**
  108972. * The output strength of the SSAO post-process. Default value is 1.0.
  108973. */
  108974. totalStrength: number;
  108975. /**
  108976. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  108977. */
  108978. maxZ: number;
  108979. /**
  108980. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  108981. */
  108982. minZAspect: number;
  108983. private _samples;
  108984. /**
  108985. * Number of samples used for the SSAO calculations. Default value is 8
  108986. */
  108987. samples: number;
  108988. private _textureSamples;
  108989. /**
  108990. * Number of samples to use for antialiasing
  108991. */
  108992. textureSamples: number;
  108993. /**
  108994. * Ratio object used for SSAO ratio and blur ratio
  108995. */
  108996. private _ratio;
  108997. /**
  108998. * Dynamically generated sphere sampler.
  108999. */
  109000. private _sampleSphere;
  109001. /**
  109002. * Blur filter offsets
  109003. */
  109004. private _samplerOffsets;
  109005. private _expensiveBlur;
  109006. /**
  109007. * If bilateral blur should be used
  109008. */
  109009. expensiveBlur: boolean;
  109010. /**
  109011. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  109012. */
  109013. radius: number;
  109014. /**
  109015. * The base color of the SSAO post-process
  109016. * The final result is "base + ssao" between [0, 1]
  109017. */
  109018. base: number;
  109019. /**
  109020. * Support test.
  109021. */
  109022. static readonly IsSupported: boolean;
  109023. private _scene;
  109024. private _depthTexture;
  109025. private _normalTexture;
  109026. private _randomTexture;
  109027. private _originalColorPostProcess;
  109028. private _ssaoPostProcess;
  109029. private _blurHPostProcess;
  109030. private _blurVPostProcess;
  109031. private _ssaoCombinePostProcess;
  109032. private _firstUpdate;
  109033. /**
  109034. * Gets active scene
  109035. */
  109036. readonly scene: Scene;
  109037. /**
  109038. * @constructor
  109039. * @param name The rendering pipeline name
  109040. * @param scene The scene linked to this pipeline
  109041. * @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 }
  109042. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109043. */
  109044. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109045. /**
  109046. * Get the class name
  109047. * @returns "SSAO2RenderingPipeline"
  109048. */
  109049. getClassName(): string;
  109050. /**
  109051. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109052. */
  109053. dispose(disableGeometryBufferRenderer?: boolean): void;
  109054. private _createBlurPostProcess;
  109055. /** @hidden */
  109056. _rebuild(): void;
  109057. private _bits;
  109058. private _radicalInverse_VdC;
  109059. private _hammersley;
  109060. private _hemisphereSample_uniform;
  109061. private _generateHemisphere;
  109062. private _createSSAOPostProcess;
  109063. private _createSSAOCombinePostProcess;
  109064. private _createRandomTexture;
  109065. /**
  109066. * Serialize the rendering pipeline (Used when exporting)
  109067. * @returns the serialized object
  109068. */
  109069. serialize(): any;
  109070. /**
  109071. * Parse the serialized pipeline
  109072. * @param source Source pipeline.
  109073. * @param scene The scene to load the pipeline to.
  109074. * @param rootUrl The URL of the serialized pipeline.
  109075. * @returns An instantiated pipeline from the serialized object.
  109076. */
  109077. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  109078. }
  109079. }
  109080. declare module BABYLON {
  109081. /** @hidden */
  109082. export var ssaoPixelShader: {
  109083. name: string;
  109084. shader: string;
  109085. };
  109086. }
  109087. declare module BABYLON {
  109088. /**
  109089. * Render pipeline to produce ssao effect
  109090. */
  109091. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  109092. /**
  109093. * @ignore
  109094. * The PassPostProcess id in the pipeline that contains the original scene color
  109095. */
  109096. SSAOOriginalSceneColorEffect: string;
  109097. /**
  109098. * @ignore
  109099. * The SSAO PostProcess id in the pipeline
  109100. */
  109101. SSAORenderEffect: string;
  109102. /**
  109103. * @ignore
  109104. * The horizontal blur PostProcess id in the pipeline
  109105. */
  109106. SSAOBlurHRenderEffect: string;
  109107. /**
  109108. * @ignore
  109109. * The vertical blur PostProcess id in the pipeline
  109110. */
  109111. SSAOBlurVRenderEffect: string;
  109112. /**
  109113. * @ignore
  109114. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109115. */
  109116. SSAOCombineRenderEffect: string;
  109117. /**
  109118. * The output strength of the SSAO post-process. Default value is 1.0.
  109119. */
  109120. totalStrength: number;
  109121. /**
  109122. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109123. */
  109124. radius: number;
  109125. /**
  109126. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109127. * Must not be equal to fallOff and superior to fallOff.
  109128. * Default value is 0.0075
  109129. */
  109130. area: number;
  109131. /**
  109132. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  109133. * Must not be equal to area and inferior to area.
  109134. * Default value is 0.000001
  109135. */
  109136. fallOff: number;
  109137. /**
  109138. * The base color of the SSAO post-process
  109139. * The final result is "base + ssao" between [0, 1]
  109140. */
  109141. base: number;
  109142. private _scene;
  109143. private _depthTexture;
  109144. private _randomTexture;
  109145. private _originalColorPostProcess;
  109146. private _ssaoPostProcess;
  109147. private _blurHPostProcess;
  109148. private _blurVPostProcess;
  109149. private _ssaoCombinePostProcess;
  109150. private _firstUpdate;
  109151. /**
  109152. * Gets active scene
  109153. */
  109154. readonly scene: Scene;
  109155. /**
  109156. * @constructor
  109157. * @param name - The rendering pipeline name
  109158. * @param scene - The scene linked to this pipeline
  109159. * @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 }
  109160. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  109161. */
  109162. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109163. /**
  109164. * Get the class name
  109165. * @returns "SSAORenderingPipeline"
  109166. */
  109167. getClassName(): string;
  109168. /**
  109169. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109170. */
  109171. dispose(disableDepthRender?: boolean): void;
  109172. private _createBlurPostProcess;
  109173. /** @hidden */
  109174. _rebuild(): void;
  109175. private _createSSAOPostProcess;
  109176. private _createSSAOCombinePostProcess;
  109177. private _createRandomTexture;
  109178. }
  109179. }
  109180. declare module BABYLON {
  109181. /** @hidden */
  109182. export var standardPixelShader: {
  109183. name: string;
  109184. shader: string;
  109185. };
  109186. }
  109187. declare module BABYLON {
  109188. /**
  109189. * Standard rendering pipeline
  109190. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109191. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  109192. */
  109193. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109194. /**
  109195. * Public members
  109196. */
  109197. /**
  109198. * Post-process which contains the original scene color before the pipeline applies all the effects
  109199. */
  109200. originalPostProcess: Nullable<PostProcess>;
  109201. /**
  109202. * Post-process used to down scale an image x4
  109203. */
  109204. downSampleX4PostProcess: Nullable<PostProcess>;
  109205. /**
  109206. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  109207. */
  109208. brightPassPostProcess: Nullable<PostProcess>;
  109209. /**
  109210. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  109211. */
  109212. blurHPostProcesses: PostProcess[];
  109213. /**
  109214. * Post-process array storing all the vertical blur post-processes used by the pipeline
  109215. */
  109216. blurVPostProcesses: PostProcess[];
  109217. /**
  109218. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  109219. */
  109220. textureAdderPostProcess: Nullable<PostProcess>;
  109221. /**
  109222. * Post-process used to create volumetric lighting effect
  109223. */
  109224. volumetricLightPostProcess: Nullable<PostProcess>;
  109225. /**
  109226. * Post-process used to smooth the previous volumetric light post-process on the X axis
  109227. */
  109228. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  109229. /**
  109230. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  109231. */
  109232. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  109233. /**
  109234. * Post-process used to merge the volumetric light effect and the real scene color
  109235. */
  109236. volumetricLightMergePostProces: Nullable<PostProcess>;
  109237. /**
  109238. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  109239. */
  109240. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  109241. /**
  109242. * Base post-process used to calculate the average luminance of the final image for HDR
  109243. */
  109244. luminancePostProcess: Nullable<PostProcess>;
  109245. /**
  109246. * Post-processes used to create down sample post-processes in order to get
  109247. * the average luminance of the final image for HDR
  109248. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  109249. */
  109250. luminanceDownSamplePostProcesses: PostProcess[];
  109251. /**
  109252. * Post-process used to create a HDR effect (light adaptation)
  109253. */
  109254. hdrPostProcess: Nullable<PostProcess>;
  109255. /**
  109256. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  109257. */
  109258. textureAdderFinalPostProcess: Nullable<PostProcess>;
  109259. /**
  109260. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  109261. */
  109262. lensFlareFinalPostProcess: Nullable<PostProcess>;
  109263. /**
  109264. * Post-process used to merge the final HDR post-process and the real scene color
  109265. */
  109266. hdrFinalPostProcess: Nullable<PostProcess>;
  109267. /**
  109268. * Post-process used to create a lens flare effect
  109269. */
  109270. lensFlarePostProcess: Nullable<PostProcess>;
  109271. /**
  109272. * Post-process that merges the result of the lens flare post-process and the real scene color
  109273. */
  109274. lensFlareComposePostProcess: Nullable<PostProcess>;
  109275. /**
  109276. * Post-process used to create a motion blur effect
  109277. */
  109278. motionBlurPostProcess: Nullable<PostProcess>;
  109279. /**
  109280. * Post-process used to create a depth of field effect
  109281. */
  109282. depthOfFieldPostProcess: Nullable<PostProcess>;
  109283. /**
  109284. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109285. */
  109286. fxaaPostProcess: Nullable<FxaaPostProcess>;
  109287. /**
  109288. * Represents the brightness threshold in order to configure the illuminated surfaces
  109289. */
  109290. brightThreshold: number;
  109291. /**
  109292. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  109293. */
  109294. blurWidth: number;
  109295. /**
  109296. * Sets if the blur for highlighted surfaces must be only horizontal
  109297. */
  109298. horizontalBlur: boolean;
  109299. /**
  109300. * Sets the overall exposure used by the pipeline
  109301. */
  109302. exposure: number;
  109303. /**
  109304. * Texture used typically to simulate "dirty" on camera lens
  109305. */
  109306. lensTexture: Nullable<Texture>;
  109307. /**
  109308. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  109309. */
  109310. volumetricLightCoefficient: number;
  109311. /**
  109312. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  109313. */
  109314. volumetricLightPower: number;
  109315. /**
  109316. * Used the set the blur intensity to smooth the volumetric lights
  109317. */
  109318. volumetricLightBlurScale: number;
  109319. /**
  109320. * Light (spot or directional) used to generate the volumetric lights rays
  109321. * The source light must have a shadow generate so the pipeline can get its
  109322. * depth map
  109323. */
  109324. sourceLight: Nullable<SpotLight | DirectionalLight>;
  109325. /**
  109326. * For eye adaptation, represents the minimum luminance the eye can see
  109327. */
  109328. hdrMinimumLuminance: number;
  109329. /**
  109330. * For eye adaptation, represents the decrease luminance speed
  109331. */
  109332. hdrDecreaseRate: number;
  109333. /**
  109334. * For eye adaptation, represents the increase luminance speed
  109335. */
  109336. hdrIncreaseRate: number;
  109337. /**
  109338. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  109339. */
  109340. lensColorTexture: Nullable<Texture>;
  109341. /**
  109342. * The overall strengh for the lens flare effect
  109343. */
  109344. lensFlareStrength: number;
  109345. /**
  109346. * Dispersion coefficient for lens flare ghosts
  109347. */
  109348. lensFlareGhostDispersal: number;
  109349. /**
  109350. * Main lens flare halo width
  109351. */
  109352. lensFlareHaloWidth: number;
  109353. /**
  109354. * Based on the lens distortion effect, defines how much the lens flare result
  109355. * is distorted
  109356. */
  109357. lensFlareDistortionStrength: number;
  109358. /**
  109359. * Lens star texture must be used to simulate rays on the flares and is available
  109360. * in the documentation
  109361. */
  109362. lensStarTexture: Nullable<Texture>;
  109363. /**
  109364. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  109365. * flare effect by taking account of the dirt texture
  109366. */
  109367. lensFlareDirtTexture: Nullable<Texture>;
  109368. /**
  109369. * Represents the focal length for the depth of field effect
  109370. */
  109371. depthOfFieldDistance: number;
  109372. /**
  109373. * Represents the blur intensity for the blurred part of the depth of field effect
  109374. */
  109375. depthOfFieldBlurWidth: number;
  109376. /**
  109377. * For motion blur, defines how much the image is blurred by the movement
  109378. */
  109379. motionStrength: number;
  109380. /**
  109381. * List of animations for the pipeline (IAnimatable implementation)
  109382. */
  109383. animations: Animation[];
  109384. /**
  109385. * Private members
  109386. */
  109387. private _scene;
  109388. private _currentDepthOfFieldSource;
  109389. private _basePostProcess;
  109390. private _hdrCurrentLuminance;
  109391. private _floatTextureType;
  109392. private _ratio;
  109393. private _bloomEnabled;
  109394. private _depthOfFieldEnabled;
  109395. private _vlsEnabled;
  109396. private _lensFlareEnabled;
  109397. private _hdrEnabled;
  109398. private _motionBlurEnabled;
  109399. private _fxaaEnabled;
  109400. private _motionBlurSamples;
  109401. private _volumetricLightStepsCount;
  109402. private _samples;
  109403. /**
  109404. * @ignore
  109405. * Specifies if the bloom pipeline is enabled
  109406. */
  109407. BloomEnabled: boolean;
  109408. /**
  109409. * @ignore
  109410. * Specifies if the depth of field pipeline is enabed
  109411. */
  109412. DepthOfFieldEnabled: boolean;
  109413. /**
  109414. * @ignore
  109415. * Specifies if the lens flare pipeline is enabed
  109416. */
  109417. LensFlareEnabled: boolean;
  109418. /**
  109419. * @ignore
  109420. * Specifies if the HDR pipeline is enabled
  109421. */
  109422. HDREnabled: boolean;
  109423. /**
  109424. * @ignore
  109425. * Specifies if the volumetric lights scattering effect is enabled
  109426. */
  109427. VLSEnabled: boolean;
  109428. /**
  109429. * @ignore
  109430. * Specifies if the motion blur effect is enabled
  109431. */
  109432. MotionBlurEnabled: boolean;
  109433. /**
  109434. * Specifies if anti-aliasing is enabled
  109435. */
  109436. fxaaEnabled: boolean;
  109437. /**
  109438. * Specifies the number of steps used to calculate the volumetric lights
  109439. * Typically in interval [50, 200]
  109440. */
  109441. volumetricLightStepsCount: number;
  109442. /**
  109443. * Specifies the number of samples used for the motion blur effect
  109444. * Typically in interval [16, 64]
  109445. */
  109446. motionBlurSamples: number;
  109447. /**
  109448. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109449. */
  109450. samples: number;
  109451. /**
  109452. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109453. * @constructor
  109454. * @param name The rendering pipeline name
  109455. * @param scene The scene linked to this pipeline
  109456. * @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)
  109457. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  109458. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109459. */
  109460. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  109461. private _buildPipeline;
  109462. private _createDownSampleX4PostProcess;
  109463. private _createBrightPassPostProcess;
  109464. private _createBlurPostProcesses;
  109465. private _createTextureAdderPostProcess;
  109466. private _createVolumetricLightPostProcess;
  109467. private _createLuminancePostProcesses;
  109468. private _createHdrPostProcess;
  109469. private _createLensFlarePostProcess;
  109470. private _createDepthOfFieldPostProcess;
  109471. private _createMotionBlurPostProcess;
  109472. private _getDepthTexture;
  109473. private _disposePostProcesses;
  109474. /**
  109475. * Dispose of the pipeline and stop all post processes
  109476. */
  109477. dispose(): void;
  109478. /**
  109479. * Serialize the rendering pipeline (Used when exporting)
  109480. * @returns the serialized object
  109481. */
  109482. serialize(): any;
  109483. /**
  109484. * Parse the serialized pipeline
  109485. * @param source Source pipeline.
  109486. * @param scene The scene to load the pipeline to.
  109487. * @param rootUrl The URL of the serialized pipeline.
  109488. * @returns An instantiated pipeline from the serialized object.
  109489. */
  109490. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  109491. /**
  109492. * Luminance steps
  109493. */
  109494. static LuminanceSteps: number;
  109495. }
  109496. }
  109497. declare module BABYLON {
  109498. /**
  109499. * PostProcessRenderPipelineManager class
  109500. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109501. */
  109502. export class PostProcessRenderPipelineManager {
  109503. private _renderPipelines;
  109504. /**
  109505. * Initializes a PostProcessRenderPipelineManager
  109506. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109507. */
  109508. constructor();
  109509. /**
  109510. * Gets the list of supported render pipelines
  109511. */
  109512. readonly supportedPipelines: PostProcessRenderPipeline[];
  109513. /**
  109514. * Adds a pipeline to the manager
  109515. * @param renderPipeline The pipeline to add
  109516. */
  109517. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109518. /**
  109519. * Attaches a camera to the pipeline
  109520. * @param renderPipelineName The name of the pipeline to attach to
  109521. * @param cameras the camera to attach
  109522. * @param unique if the camera can be attached multiple times to the pipeline
  109523. */
  109524. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109525. /**
  109526. * Detaches a camera from the pipeline
  109527. * @param renderPipelineName The name of the pipeline to detach from
  109528. * @param cameras the camera to detach
  109529. */
  109530. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109531. /**
  109532. * Enables an effect by name on a pipeline
  109533. * @param renderPipelineName the name of the pipeline to enable the effect in
  109534. * @param renderEffectName the name of the effect to enable
  109535. * @param cameras the cameras that the effect should be enabled on
  109536. */
  109537. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109538. /**
  109539. * Disables an effect by name on a pipeline
  109540. * @param renderPipelineName the name of the pipeline to disable the effect in
  109541. * @param renderEffectName the name of the effect to disable
  109542. * @param cameras the cameras that the effect should be disabled on
  109543. */
  109544. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109545. /**
  109546. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109547. */
  109548. update(): void;
  109549. /** @hidden */
  109550. _rebuild(): void;
  109551. /**
  109552. * Disposes of the manager and pipelines
  109553. */
  109554. dispose(): void;
  109555. }
  109556. }
  109557. declare module BABYLON {
  109558. interface Scene {
  109559. /** @hidden (Backing field) */
  109560. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109561. /**
  109562. * Gets the postprocess render pipeline manager
  109563. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109564. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109565. */
  109566. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109567. }
  109568. /**
  109569. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109570. */
  109571. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109572. /**
  109573. * The component name helpfull to identify the component in the list of scene components.
  109574. */
  109575. readonly name: string;
  109576. /**
  109577. * The scene the component belongs to.
  109578. */
  109579. scene: Scene;
  109580. /**
  109581. * Creates a new instance of the component for the given scene
  109582. * @param scene Defines the scene to register the component in
  109583. */
  109584. constructor(scene: Scene);
  109585. /**
  109586. * Registers the component in a given scene
  109587. */
  109588. register(): void;
  109589. /**
  109590. * Rebuilds the elements related to this component in case of
  109591. * context lost for instance.
  109592. */
  109593. rebuild(): void;
  109594. /**
  109595. * Disposes the component and the associated ressources
  109596. */
  109597. dispose(): void;
  109598. private _gatherRenderTargets;
  109599. }
  109600. }
  109601. declare module BABYLON {
  109602. /** @hidden */
  109603. export var tonemapPixelShader: {
  109604. name: string;
  109605. shader: string;
  109606. };
  109607. }
  109608. declare module BABYLON {
  109609. /** Defines operator used for tonemapping */
  109610. export enum TonemappingOperator {
  109611. /** Hable */
  109612. Hable = 0,
  109613. /** Reinhard */
  109614. Reinhard = 1,
  109615. /** HejiDawson */
  109616. HejiDawson = 2,
  109617. /** Photographic */
  109618. Photographic = 3
  109619. }
  109620. /**
  109621. * Defines a post process to apply tone mapping
  109622. */
  109623. export class TonemapPostProcess extends PostProcess {
  109624. private _operator;
  109625. /** Defines the required exposure adjustement */
  109626. exposureAdjustment: number;
  109627. /**
  109628. * Creates a new TonemapPostProcess
  109629. * @param name defines the name of the postprocess
  109630. * @param _operator defines the operator to use
  109631. * @param exposureAdjustment defines the required exposure adjustement
  109632. * @param camera defines the camera to use (can be null)
  109633. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  109634. * @param engine defines the hosting engine (can be ignore if camera is set)
  109635. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109636. */
  109637. constructor(name: string, _operator: TonemappingOperator,
  109638. /** Defines the required exposure adjustement */
  109639. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  109640. }
  109641. }
  109642. declare module BABYLON {
  109643. /** @hidden */
  109644. export var depthVertexShader: {
  109645. name: string;
  109646. shader: string;
  109647. };
  109648. }
  109649. declare module BABYLON {
  109650. /** @hidden */
  109651. export var volumetricLightScatteringPixelShader: {
  109652. name: string;
  109653. shader: string;
  109654. };
  109655. }
  109656. declare module BABYLON {
  109657. /** @hidden */
  109658. export var volumetricLightScatteringPassPixelShader: {
  109659. name: string;
  109660. shader: string;
  109661. };
  109662. }
  109663. declare module BABYLON {
  109664. /**
  109665. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  109666. */
  109667. export class VolumetricLightScatteringPostProcess extends PostProcess {
  109668. private _volumetricLightScatteringPass;
  109669. private _volumetricLightScatteringRTT;
  109670. private _viewPort;
  109671. private _screenCoordinates;
  109672. private _cachedDefines;
  109673. /**
  109674. * If not undefined, the mesh position is computed from the attached node position
  109675. */
  109676. attachedNode: {
  109677. position: Vector3;
  109678. };
  109679. /**
  109680. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  109681. */
  109682. customMeshPosition: Vector3;
  109683. /**
  109684. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  109685. */
  109686. useCustomMeshPosition: boolean;
  109687. /**
  109688. * If the post-process should inverse the light scattering direction
  109689. */
  109690. invert: boolean;
  109691. /**
  109692. * The internal mesh used by the post-process
  109693. */
  109694. mesh: Mesh;
  109695. /**
  109696. * @hidden
  109697. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  109698. */
  109699. useDiffuseColor: boolean;
  109700. /**
  109701. * Array containing the excluded meshes not rendered in the internal pass
  109702. */
  109703. excludedMeshes: AbstractMesh[];
  109704. /**
  109705. * Controls the overall intensity of the post-process
  109706. */
  109707. exposure: number;
  109708. /**
  109709. * Dissipates each sample's contribution in range [0, 1]
  109710. */
  109711. decay: number;
  109712. /**
  109713. * Controls the overall intensity of each sample
  109714. */
  109715. weight: number;
  109716. /**
  109717. * Controls the density of each sample
  109718. */
  109719. density: number;
  109720. /**
  109721. * @constructor
  109722. * @param name The post-process name
  109723. * @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)
  109724. * @param camera The camera that the post-process will be attached to
  109725. * @param mesh The mesh used to create the light scattering
  109726. * @param samples The post-process quality, default 100
  109727. * @param samplingModeThe post-process filtering mode
  109728. * @param engine The babylon engine
  109729. * @param reusable If the post-process is reusable
  109730. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  109731. */
  109732. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  109733. /**
  109734. * Returns the string "VolumetricLightScatteringPostProcess"
  109735. * @returns "VolumetricLightScatteringPostProcess"
  109736. */
  109737. getClassName(): string;
  109738. private _isReady;
  109739. /**
  109740. * Sets the new light position for light scattering effect
  109741. * @param position The new custom light position
  109742. */
  109743. setCustomMeshPosition(position: Vector3): void;
  109744. /**
  109745. * Returns the light position for light scattering effect
  109746. * @return Vector3 The custom light position
  109747. */
  109748. getCustomMeshPosition(): Vector3;
  109749. /**
  109750. * Disposes the internal assets and detaches the post-process from the camera
  109751. */
  109752. dispose(camera: Camera): void;
  109753. /**
  109754. * Returns the render target texture used by the post-process
  109755. * @return the render target texture used by the post-process
  109756. */
  109757. getPass(): RenderTargetTexture;
  109758. private _meshExcluded;
  109759. private _createPass;
  109760. private _updateMeshScreenCoordinates;
  109761. /**
  109762. * Creates a default mesh for the Volumeric Light Scattering post-process
  109763. * @param name The mesh name
  109764. * @param scene The scene where to create the mesh
  109765. * @return the default mesh
  109766. */
  109767. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  109768. }
  109769. }
  109770. declare module BABYLON {
  109771. interface Scene {
  109772. /** @hidden (Backing field) */
  109773. _boundingBoxRenderer: BoundingBoxRenderer;
  109774. /** @hidden (Backing field) */
  109775. _forceShowBoundingBoxes: boolean;
  109776. /**
  109777. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  109778. */
  109779. forceShowBoundingBoxes: boolean;
  109780. /**
  109781. * Gets the bounding box renderer associated with the scene
  109782. * @returns a BoundingBoxRenderer
  109783. */
  109784. getBoundingBoxRenderer(): BoundingBoxRenderer;
  109785. }
  109786. interface AbstractMesh {
  109787. /** @hidden (Backing field) */
  109788. _showBoundingBox: boolean;
  109789. /**
  109790. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  109791. */
  109792. showBoundingBox: boolean;
  109793. }
  109794. /**
  109795. * Component responsible of rendering the bounding box of the meshes in a scene.
  109796. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  109797. */
  109798. export class BoundingBoxRenderer implements ISceneComponent {
  109799. /**
  109800. * The component name helpfull to identify the component in the list of scene components.
  109801. */
  109802. readonly name: string;
  109803. /**
  109804. * The scene the component belongs to.
  109805. */
  109806. scene: Scene;
  109807. /**
  109808. * Color of the bounding box lines placed in front of an object
  109809. */
  109810. frontColor: Color3;
  109811. /**
  109812. * Color of the bounding box lines placed behind an object
  109813. */
  109814. backColor: Color3;
  109815. /**
  109816. * Defines if the renderer should show the back lines or not
  109817. */
  109818. showBackLines: boolean;
  109819. /**
  109820. * @hidden
  109821. */
  109822. renderList: SmartArray<BoundingBox>;
  109823. private _colorShader;
  109824. private _vertexBuffers;
  109825. private _indexBuffer;
  109826. /**
  109827. * Instantiates a new bounding box renderer in a scene.
  109828. * @param scene the scene the renderer renders in
  109829. */
  109830. constructor(scene: Scene);
  109831. /**
  109832. * Registers the component in a given scene
  109833. */
  109834. register(): void;
  109835. private _evaluateSubMesh;
  109836. private _activeMesh;
  109837. private _prepareRessources;
  109838. private _createIndexBuffer;
  109839. /**
  109840. * Rebuilds the elements related to this component in case of
  109841. * context lost for instance.
  109842. */
  109843. rebuild(): void;
  109844. /**
  109845. * @hidden
  109846. */
  109847. reset(): void;
  109848. /**
  109849. * Render the bounding boxes of a specific rendering group
  109850. * @param renderingGroupId defines the rendering group to render
  109851. */
  109852. render(renderingGroupId: number): void;
  109853. /**
  109854. * In case of occlusion queries, we can render the occlusion bounding box through this method
  109855. * @param mesh Define the mesh to render the occlusion bounding box for
  109856. */
  109857. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  109858. /**
  109859. * Dispose and release the resources attached to this renderer.
  109860. */
  109861. dispose(): void;
  109862. }
  109863. }
  109864. declare module BABYLON {
  109865. /** @hidden */
  109866. export var depthPixelShader: {
  109867. name: string;
  109868. shader: string;
  109869. };
  109870. }
  109871. declare module BABYLON {
  109872. /**
  109873. * This represents a depth renderer in Babylon.
  109874. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  109875. */
  109876. export class DepthRenderer {
  109877. private _scene;
  109878. private _depthMap;
  109879. private _effect;
  109880. private _cachedDefines;
  109881. private _camera;
  109882. /**
  109883. * Specifiess that the depth renderer will only be used within
  109884. * the camera it is created for.
  109885. * This can help forcing its rendering during the camera processing.
  109886. */
  109887. useOnlyInActiveCamera: boolean;
  109888. /** @hidden */
  109889. static _SceneComponentInitialization: (scene: Scene) => void;
  109890. /**
  109891. * Instantiates a depth renderer
  109892. * @param scene The scene the renderer belongs to
  109893. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  109894. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  109895. */
  109896. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  109897. /**
  109898. * Creates the depth rendering effect and checks if the effect is ready.
  109899. * @param subMesh The submesh to be used to render the depth map of
  109900. * @param useInstances If multiple world instances should be used
  109901. * @returns if the depth renderer is ready to render the depth map
  109902. */
  109903. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109904. /**
  109905. * Gets the texture which the depth map will be written to.
  109906. * @returns The depth map texture
  109907. */
  109908. getDepthMap(): RenderTargetTexture;
  109909. /**
  109910. * Disposes of the depth renderer.
  109911. */
  109912. dispose(): void;
  109913. }
  109914. }
  109915. declare module BABYLON {
  109916. interface Scene {
  109917. /** @hidden (Backing field) */
  109918. _depthRenderer: {
  109919. [id: string]: DepthRenderer;
  109920. };
  109921. /**
  109922. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  109923. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  109924. * @returns the created depth renderer
  109925. */
  109926. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  109927. /**
  109928. * Disables a depth renderer for a given camera
  109929. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  109930. */
  109931. disableDepthRenderer(camera?: Nullable<Camera>): void;
  109932. }
  109933. /**
  109934. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  109935. * in several rendering techniques.
  109936. */
  109937. export class DepthRendererSceneComponent implements ISceneComponent {
  109938. /**
  109939. * The component name helpfull to identify the component in the list of scene components.
  109940. */
  109941. readonly name: string;
  109942. /**
  109943. * The scene the component belongs to.
  109944. */
  109945. scene: Scene;
  109946. /**
  109947. * Creates a new instance of the component for the given scene
  109948. * @param scene Defines the scene to register the component in
  109949. */
  109950. constructor(scene: Scene);
  109951. /**
  109952. * Registers the component in a given scene
  109953. */
  109954. register(): void;
  109955. /**
  109956. * Rebuilds the elements related to this component in case of
  109957. * context lost for instance.
  109958. */
  109959. rebuild(): void;
  109960. /**
  109961. * Disposes the component and the associated ressources
  109962. */
  109963. dispose(): void;
  109964. private _gatherRenderTargets;
  109965. private _gatherActiveCameraRenderTargets;
  109966. }
  109967. }
  109968. declare module BABYLON {
  109969. interface Scene {
  109970. /** @hidden (Backing field) */
  109971. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109972. /**
  109973. * Gets or Sets the current geometry buffer associated to the scene.
  109974. */
  109975. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109976. /**
  109977. * Enables a GeometryBufferRender and associates it with the scene
  109978. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  109979. * @returns the GeometryBufferRenderer
  109980. */
  109981. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  109982. /**
  109983. * Disables the GeometryBufferRender associated with the scene
  109984. */
  109985. disableGeometryBufferRenderer(): void;
  109986. }
  109987. /**
  109988. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  109989. * in several rendering techniques.
  109990. */
  109991. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  109992. /**
  109993. * The component name helpful to identify the component in the list of scene components.
  109994. */
  109995. readonly name: string;
  109996. /**
  109997. * The scene the component belongs to.
  109998. */
  109999. scene: Scene;
  110000. /**
  110001. * Creates a new instance of the component for the given scene
  110002. * @param scene Defines the scene to register the component in
  110003. */
  110004. constructor(scene: Scene);
  110005. /**
  110006. * Registers the component in a given scene
  110007. */
  110008. register(): void;
  110009. /**
  110010. * Rebuilds the elements related to this component in case of
  110011. * context lost for instance.
  110012. */
  110013. rebuild(): void;
  110014. /**
  110015. * Disposes the component and the associated ressources
  110016. */
  110017. dispose(): void;
  110018. private _gatherRenderTargets;
  110019. }
  110020. }
  110021. declare module BABYLON {
  110022. /** @hidden */
  110023. export var outlinePixelShader: {
  110024. name: string;
  110025. shader: string;
  110026. };
  110027. }
  110028. declare module BABYLON {
  110029. /** @hidden */
  110030. export var outlineVertexShader: {
  110031. name: string;
  110032. shader: string;
  110033. };
  110034. }
  110035. declare module BABYLON {
  110036. interface Scene {
  110037. /** @hidden */
  110038. _outlineRenderer: OutlineRenderer;
  110039. /**
  110040. * Gets the outline renderer associated with the scene
  110041. * @returns a OutlineRenderer
  110042. */
  110043. getOutlineRenderer(): OutlineRenderer;
  110044. }
  110045. interface AbstractMesh {
  110046. /** @hidden (Backing field) */
  110047. _renderOutline: boolean;
  110048. /**
  110049. * Gets or sets a boolean indicating if the outline must be rendered as well
  110050. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110051. */
  110052. renderOutline: boolean;
  110053. /** @hidden (Backing field) */
  110054. _renderOverlay: boolean;
  110055. /**
  110056. * Gets or sets a boolean indicating if the overlay must be rendered as well
  110057. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  110058. */
  110059. renderOverlay: boolean;
  110060. }
  110061. /**
  110062. * This class is responsible to draw bothe outline/overlay of meshes.
  110063. * It should not be used directly but through the available method on mesh.
  110064. */
  110065. export class OutlineRenderer implements ISceneComponent {
  110066. /**
  110067. * The name of the component. Each component must have a unique name.
  110068. */
  110069. name: string;
  110070. /**
  110071. * The scene the component belongs to.
  110072. */
  110073. scene: Scene;
  110074. /**
  110075. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  110076. */
  110077. zOffset: number;
  110078. private _engine;
  110079. private _effect;
  110080. private _cachedDefines;
  110081. private _savedDepthWrite;
  110082. /**
  110083. * Instantiates a new outline renderer. (There could be only one per scene).
  110084. * @param scene Defines the scene it belongs to
  110085. */
  110086. constructor(scene: Scene);
  110087. /**
  110088. * Register the component to one instance of a scene.
  110089. */
  110090. register(): void;
  110091. /**
  110092. * Rebuilds the elements related to this component in case of
  110093. * context lost for instance.
  110094. */
  110095. rebuild(): void;
  110096. /**
  110097. * Disposes the component and the associated ressources.
  110098. */
  110099. dispose(): void;
  110100. /**
  110101. * Renders the outline in the canvas.
  110102. * @param subMesh Defines the sumesh to render
  110103. * @param batch Defines the batch of meshes in case of instances
  110104. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110105. */
  110106. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110107. /**
  110108. * Returns whether or not the outline renderer is ready for a given submesh.
  110109. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110110. * @param subMesh Defines the submesh to check readyness for
  110111. * @param useInstances Defines wheter wee are trying to render instances or not
  110112. * @returns true if ready otherwise false
  110113. */
  110114. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110115. private _beforeRenderingMesh;
  110116. private _afterRenderingMesh;
  110117. }
  110118. }
  110119. declare module BABYLON {
  110120. /**
  110121. * Defines the list of states available for a task inside a AssetsManager
  110122. */
  110123. export enum AssetTaskState {
  110124. /**
  110125. * Initialization
  110126. */
  110127. INIT = 0,
  110128. /**
  110129. * Running
  110130. */
  110131. RUNNING = 1,
  110132. /**
  110133. * Done
  110134. */
  110135. DONE = 2,
  110136. /**
  110137. * Error
  110138. */
  110139. ERROR = 3
  110140. }
  110141. /**
  110142. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110143. */
  110144. export abstract class AbstractAssetTask {
  110145. /**
  110146. * Task name
  110147. */ name: string;
  110148. /**
  110149. * Callback called when the task is successful
  110150. */
  110151. onSuccess: (task: any) => void;
  110152. /**
  110153. * Callback called when the task is not successful
  110154. */
  110155. onError: (task: any, message?: string, exception?: any) => void;
  110156. /**
  110157. * Creates a new AssetsManager
  110158. * @param name defines the name of the task
  110159. */
  110160. constructor(
  110161. /**
  110162. * Task name
  110163. */ name: string);
  110164. private _isCompleted;
  110165. private _taskState;
  110166. private _errorObject;
  110167. /**
  110168. * Get if the task is completed
  110169. */
  110170. readonly isCompleted: boolean;
  110171. /**
  110172. * Gets the current state of the task
  110173. */
  110174. readonly taskState: AssetTaskState;
  110175. /**
  110176. * Gets the current error object (if task is in error)
  110177. */
  110178. readonly errorObject: {
  110179. message?: string;
  110180. exception?: any;
  110181. };
  110182. /**
  110183. * Internal only
  110184. * @hidden
  110185. */
  110186. _setErrorObject(message?: string, exception?: any): void;
  110187. /**
  110188. * Execute the current task
  110189. * @param scene defines the scene where you want your assets to be loaded
  110190. * @param onSuccess is a callback called when the task is successfully executed
  110191. * @param onError is a callback called if an error occurs
  110192. */
  110193. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110194. /**
  110195. * Execute the current task
  110196. * @param scene defines the scene where you want your assets to be loaded
  110197. * @param onSuccess is a callback called when the task is successfully executed
  110198. * @param onError is a callback called if an error occurs
  110199. */
  110200. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110201. /**
  110202. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110203. * This can be used with failed tasks that have the reason for failure fixed.
  110204. */
  110205. reset(): void;
  110206. private onErrorCallback;
  110207. private onDoneCallback;
  110208. }
  110209. /**
  110210. * Define the interface used by progress events raised during assets loading
  110211. */
  110212. export interface IAssetsProgressEvent {
  110213. /**
  110214. * Defines the number of remaining tasks to process
  110215. */
  110216. remainingCount: number;
  110217. /**
  110218. * Defines the total number of tasks
  110219. */
  110220. totalCount: number;
  110221. /**
  110222. * Defines the task that was just processed
  110223. */
  110224. task: AbstractAssetTask;
  110225. }
  110226. /**
  110227. * Class used to share progress information about assets loading
  110228. */
  110229. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110230. /**
  110231. * Defines the number of remaining tasks to process
  110232. */
  110233. remainingCount: number;
  110234. /**
  110235. * Defines the total number of tasks
  110236. */
  110237. totalCount: number;
  110238. /**
  110239. * Defines the task that was just processed
  110240. */
  110241. task: AbstractAssetTask;
  110242. /**
  110243. * Creates a AssetsProgressEvent
  110244. * @param remainingCount defines the number of remaining tasks to process
  110245. * @param totalCount defines the total number of tasks
  110246. * @param task defines the task that was just processed
  110247. */
  110248. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110249. }
  110250. /**
  110251. * Define a task used by AssetsManager to load meshes
  110252. */
  110253. export class MeshAssetTask extends AbstractAssetTask {
  110254. /**
  110255. * Defines the name of the task
  110256. */
  110257. name: string;
  110258. /**
  110259. * Defines the list of mesh's names you want to load
  110260. */
  110261. meshesNames: any;
  110262. /**
  110263. * Defines the root url to use as a base to load your meshes and associated resources
  110264. */
  110265. rootUrl: string;
  110266. /**
  110267. * Defines the filename of the scene to load from
  110268. */
  110269. sceneFilename: string;
  110270. /**
  110271. * Gets the list of loaded meshes
  110272. */
  110273. loadedMeshes: Array<AbstractMesh>;
  110274. /**
  110275. * Gets the list of loaded particle systems
  110276. */
  110277. loadedParticleSystems: Array<IParticleSystem>;
  110278. /**
  110279. * Gets the list of loaded skeletons
  110280. */
  110281. loadedSkeletons: Array<Skeleton>;
  110282. /**
  110283. * Gets the list of loaded animation groups
  110284. */
  110285. loadedAnimationGroups: Array<AnimationGroup>;
  110286. /**
  110287. * Callback called when the task is successful
  110288. */
  110289. onSuccess: (task: MeshAssetTask) => void;
  110290. /**
  110291. * Callback called when the task is successful
  110292. */
  110293. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  110294. /**
  110295. * Creates a new MeshAssetTask
  110296. * @param name defines the name of the task
  110297. * @param meshesNames defines the list of mesh's names you want to load
  110298. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  110299. * @param sceneFilename defines the filename of the scene to load from
  110300. */
  110301. constructor(
  110302. /**
  110303. * Defines the name of the task
  110304. */
  110305. name: string,
  110306. /**
  110307. * Defines the list of mesh's names you want to load
  110308. */
  110309. meshesNames: any,
  110310. /**
  110311. * Defines the root url to use as a base to load your meshes and associated resources
  110312. */
  110313. rootUrl: string,
  110314. /**
  110315. * Defines the filename of the scene to load from
  110316. */
  110317. sceneFilename: string);
  110318. /**
  110319. * Execute the current task
  110320. * @param scene defines the scene where you want your assets to be loaded
  110321. * @param onSuccess is a callback called when the task is successfully executed
  110322. * @param onError is a callback called if an error occurs
  110323. */
  110324. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110325. }
  110326. /**
  110327. * Define a task used by AssetsManager to load text content
  110328. */
  110329. export class TextFileAssetTask extends AbstractAssetTask {
  110330. /**
  110331. * Defines the name of the task
  110332. */
  110333. name: string;
  110334. /**
  110335. * Defines the location of the file to load
  110336. */
  110337. url: string;
  110338. /**
  110339. * Gets the loaded text string
  110340. */
  110341. text: string;
  110342. /**
  110343. * Callback called when the task is successful
  110344. */
  110345. onSuccess: (task: TextFileAssetTask) => void;
  110346. /**
  110347. * Callback called when the task is successful
  110348. */
  110349. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  110350. /**
  110351. * Creates a new TextFileAssetTask object
  110352. * @param name defines the name of the task
  110353. * @param url defines the location of the file to load
  110354. */
  110355. constructor(
  110356. /**
  110357. * Defines the name of the task
  110358. */
  110359. name: string,
  110360. /**
  110361. * Defines the location of the file to load
  110362. */
  110363. url: string);
  110364. /**
  110365. * Execute the current task
  110366. * @param scene defines the scene where you want your assets to be loaded
  110367. * @param onSuccess is a callback called when the task is successfully executed
  110368. * @param onError is a callback called if an error occurs
  110369. */
  110370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110371. }
  110372. /**
  110373. * Define a task used by AssetsManager to load binary data
  110374. */
  110375. export class BinaryFileAssetTask extends AbstractAssetTask {
  110376. /**
  110377. * Defines the name of the task
  110378. */
  110379. name: string;
  110380. /**
  110381. * Defines the location of the file to load
  110382. */
  110383. url: string;
  110384. /**
  110385. * Gets the lodaded data (as an array buffer)
  110386. */
  110387. data: ArrayBuffer;
  110388. /**
  110389. * Callback called when the task is successful
  110390. */
  110391. onSuccess: (task: BinaryFileAssetTask) => void;
  110392. /**
  110393. * Callback called when the task is successful
  110394. */
  110395. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  110396. /**
  110397. * Creates a new BinaryFileAssetTask object
  110398. * @param name defines the name of the new task
  110399. * @param url defines the location of the file to load
  110400. */
  110401. constructor(
  110402. /**
  110403. * Defines the name of the task
  110404. */
  110405. name: string,
  110406. /**
  110407. * Defines the location of the file to load
  110408. */
  110409. url: string);
  110410. /**
  110411. * Execute the current task
  110412. * @param scene defines the scene where you want your assets to be loaded
  110413. * @param onSuccess is a callback called when the task is successfully executed
  110414. * @param onError is a callback called if an error occurs
  110415. */
  110416. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110417. }
  110418. /**
  110419. * Define a task used by AssetsManager to load images
  110420. */
  110421. export class ImageAssetTask extends AbstractAssetTask {
  110422. /**
  110423. * Defines the name of the task
  110424. */
  110425. name: string;
  110426. /**
  110427. * Defines the location of the image to load
  110428. */
  110429. url: string;
  110430. /**
  110431. * Gets the loaded images
  110432. */
  110433. image: HTMLImageElement;
  110434. /**
  110435. * Callback called when the task is successful
  110436. */
  110437. onSuccess: (task: ImageAssetTask) => void;
  110438. /**
  110439. * Callback called when the task is successful
  110440. */
  110441. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  110442. /**
  110443. * Creates a new ImageAssetTask
  110444. * @param name defines the name of the task
  110445. * @param url defines the location of the image to load
  110446. */
  110447. constructor(
  110448. /**
  110449. * Defines the name of the task
  110450. */
  110451. name: string,
  110452. /**
  110453. * Defines the location of the image to load
  110454. */
  110455. url: string);
  110456. /**
  110457. * Execute the current task
  110458. * @param scene defines the scene where you want your assets to be loaded
  110459. * @param onSuccess is a callback called when the task is successfully executed
  110460. * @param onError is a callback called if an error occurs
  110461. */
  110462. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110463. }
  110464. /**
  110465. * Defines the interface used by texture loading tasks
  110466. */
  110467. export interface ITextureAssetTask<TEX extends BaseTexture> {
  110468. /**
  110469. * Gets the loaded texture
  110470. */
  110471. texture: TEX;
  110472. }
  110473. /**
  110474. * Define a task used by AssetsManager to load 2D textures
  110475. */
  110476. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  110477. /**
  110478. * Defines the name of the task
  110479. */
  110480. name: string;
  110481. /**
  110482. * Defines the location of the file to load
  110483. */
  110484. url: string;
  110485. /**
  110486. * Defines if mipmap should not be generated (default is false)
  110487. */
  110488. noMipmap?: boolean | undefined;
  110489. /**
  110490. * Defines if texture must be inverted on Y axis (default is false)
  110491. */
  110492. invertY?: boolean | undefined;
  110493. /**
  110494. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110495. */
  110496. samplingMode: number;
  110497. /**
  110498. * Gets the loaded texture
  110499. */
  110500. texture: Texture;
  110501. /**
  110502. * Callback called when the task is successful
  110503. */
  110504. onSuccess: (task: TextureAssetTask) => void;
  110505. /**
  110506. * Callback called when the task is successful
  110507. */
  110508. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  110509. /**
  110510. * Creates a new TextureAssetTask object
  110511. * @param name defines the name of the task
  110512. * @param url defines the location of the file to load
  110513. * @param noMipmap defines if mipmap should not be generated (default is false)
  110514. * @param invertY defines if texture must be inverted on Y axis (default is false)
  110515. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110516. */
  110517. constructor(
  110518. /**
  110519. * Defines the name of the task
  110520. */
  110521. name: string,
  110522. /**
  110523. * Defines the location of the file to load
  110524. */
  110525. url: string,
  110526. /**
  110527. * Defines if mipmap should not be generated (default is false)
  110528. */
  110529. noMipmap?: boolean | undefined,
  110530. /**
  110531. * Defines if texture must be inverted on Y axis (default is false)
  110532. */
  110533. invertY?: boolean | undefined,
  110534. /**
  110535. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110536. */
  110537. samplingMode?: number);
  110538. /**
  110539. * Execute the current task
  110540. * @param scene defines the scene where you want your assets to be loaded
  110541. * @param onSuccess is a callback called when the task is successfully executed
  110542. * @param onError is a callback called if an error occurs
  110543. */
  110544. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110545. }
  110546. /**
  110547. * Define a task used by AssetsManager to load cube textures
  110548. */
  110549. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  110550. /**
  110551. * Defines the name of the task
  110552. */
  110553. name: string;
  110554. /**
  110555. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110556. */
  110557. url: string;
  110558. /**
  110559. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110560. */
  110561. extensions?: string[] | undefined;
  110562. /**
  110563. * Defines if mipmaps should not be generated (default is false)
  110564. */
  110565. noMipmap?: boolean | undefined;
  110566. /**
  110567. * Defines the explicit list of files (undefined by default)
  110568. */
  110569. files?: string[] | undefined;
  110570. /**
  110571. * Gets the loaded texture
  110572. */
  110573. texture: CubeTexture;
  110574. /**
  110575. * Callback called when the task is successful
  110576. */
  110577. onSuccess: (task: CubeTextureAssetTask) => void;
  110578. /**
  110579. * Callback called when the task is successful
  110580. */
  110581. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  110582. /**
  110583. * Creates a new CubeTextureAssetTask
  110584. * @param name defines the name of the task
  110585. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110586. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110587. * @param noMipmap defines if mipmaps should not be generated (default is false)
  110588. * @param files defines the explicit list of files (undefined by default)
  110589. */
  110590. constructor(
  110591. /**
  110592. * Defines the name of the task
  110593. */
  110594. name: string,
  110595. /**
  110596. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110597. */
  110598. url: string,
  110599. /**
  110600. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110601. */
  110602. extensions?: string[] | undefined,
  110603. /**
  110604. * Defines if mipmaps should not be generated (default is false)
  110605. */
  110606. noMipmap?: boolean | undefined,
  110607. /**
  110608. * Defines the explicit list of files (undefined by default)
  110609. */
  110610. files?: string[] | undefined);
  110611. /**
  110612. * Execute the current task
  110613. * @param scene defines the scene where you want your assets to be loaded
  110614. * @param onSuccess is a callback called when the task is successfully executed
  110615. * @param onError is a callback called if an error occurs
  110616. */
  110617. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110618. }
  110619. /**
  110620. * Define a task used by AssetsManager to load HDR cube textures
  110621. */
  110622. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  110623. /**
  110624. * Defines the name of the task
  110625. */
  110626. name: string;
  110627. /**
  110628. * Defines the location of the file to load
  110629. */
  110630. url: string;
  110631. /**
  110632. * Defines the desired size (the more it increases the longer the generation will be)
  110633. */
  110634. size: number;
  110635. /**
  110636. * Defines if mipmaps should not be generated (default is false)
  110637. */
  110638. noMipmap: boolean;
  110639. /**
  110640. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110641. */
  110642. generateHarmonics: boolean;
  110643. /**
  110644. * 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)
  110645. */
  110646. gammaSpace: boolean;
  110647. /**
  110648. * Internal Use Only
  110649. */
  110650. reserved: boolean;
  110651. /**
  110652. * Gets the loaded texture
  110653. */
  110654. texture: HDRCubeTexture;
  110655. /**
  110656. * Callback called when the task is successful
  110657. */
  110658. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  110659. /**
  110660. * Callback called when the task is successful
  110661. */
  110662. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  110663. /**
  110664. * Creates a new HDRCubeTextureAssetTask object
  110665. * @param name defines the name of the task
  110666. * @param url defines the location of the file to load
  110667. * @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.
  110668. * @param noMipmap defines if mipmaps should not be generated (default is false)
  110669. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110670. * @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)
  110671. * @param reserved Internal use only
  110672. */
  110673. constructor(
  110674. /**
  110675. * Defines the name of the task
  110676. */
  110677. name: string,
  110678. /**
  110679. * Defines the location of the file to load
  110680. */
  110681. url: string,
  110682. /**
  110683. * Defines the desired size (the more it increases the longer the generation will be)
  110684. */
  110685. size: number,
  110686. /**
  110687. * Defines if mipmaps should not be generated (default is false)
  110688. */
  110689. noMipmap?: boolean,
  110690. /**
  110691. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110692. */
  110693. generateHarmonics?: boolean,
  110694. /**
  110695. * 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)
  110696. */
  110697. gammaSpace?: boolean,
  110698. /**
  110699. * Internal Use Only
  110700. */
  110701. reserved?: boolean);
  110702. /**
  110703. * Execute the current task
  110704. * @param scene defines the scene where you want your assets to be loaded
  110705. * @param onSuccess is a callback called when the task is successfully executed
  110706. * @param onError is a callback called if an error occurs
  110707. */
  110708. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110709. }
  110710. /**
  110711. * This class can be used to easily import assets into a scene
  110712. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  110713. */
  110714. export class AssetsManager {
  110715. private _scene;
  110716. private _isLoading;
  110717. protected _tasks: AbstractAssetTask[];
  110718. protected _waitingTasksCount: number;
  110719. protected _totalTasksCount: number;
  110720. /**
  110721. * Callback called when all tasks are processed
  110722. */
  110723. onFinish: (tasks: AbstractAssetTask[]) => void;
  110724. /**
  110725. * Callback called when a task is successful
  110726. */
  110727. onTaskSuccess: (task: AbstractAssetTask) => void;
  110728. /**
  110729. * Callback called when a task had an error
  110730. */
  110731. onTaskError: (task: AbstractAssetTask) => void;
  110732. /**
  110733. * Callback called when a task is done (whatever the result is)
  110734. */
  110735. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  110736. /**
  110737. * Observable called when all tasks are processed
  110738. */
  110739. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  110740. /**
  110741. * Observable called when a task had an error
  110742. */
  110743. onTaskErrorObservable: Observable<AbstractAssetTask>;
  110744. /**
  110745. * Observable called when a task is successful
  110746. */
  110747. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  110748. /**
  110749. * Observable called when a task is done (whatever the result is)
  110750. */
  110751. onProgressObservable: Observable<IAssetsProgressEvent>;
  110752. /**
  110753. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  110754. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110755. */
  110756. useDefaultLoadingScreen: boolean;
  110757. /**
  110758. * Creates a new AssetsManager
  110759. * @param scene defines the scene to work on
  110760. */
  110761. constructor(scene: Scene);
  110762. /**
  110763. * Add a MeshAssetTask to the list of active tasks
  110764. * @param taskName defines the name of the new task
  110765. * @param meshesNames defines the name of meshes to load
  110766. * @param rootUrl defines the root url to use to locate files
  110767. * @param sceneFilename defines the filename of the scene file
  110768. * @returns a new MeshAssetTask object
  110769. */
  110770. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  110771. /**
  110772. * Add a TextFileAssetTask to the list of active tasks
  110773. * @param taskName defines the name of the new task
  110774. * @param url defines the url of the file to load
  110775. * @returns a new TextFileAssetTask object
  110776. */
  110777. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  110778. /**
  110779. * Add a BinaryFileAssetTask to the list of active tasks
  110780. * @param taskName defines the name of the new task
  110781. * @param url defines the url of the file to load
  110782. * @returns a new BinaryFileAssetTask object
  110783. */
  110784. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  110785. /**
  110786. * Add a ImageAssetTask to the list of active tasks
  110787. * @param taskName defines the name of the new task
  110788. * @param url defines the url of the file to load
  110789. * @returns a new ImageAssetTask object
  110790. */
  110791. addImageTask(taskName: string, url: string): ImageAssetTask;
  110792. /**
  110793. * Add a TextureAssetTask to the list of active tasks
  110794. * @param taskName defines the name of the new task
  110795. * @param url defines the url of the file to load
  110796. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110797. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  110798. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  110799. * @returns a new TextureAssetTask object
  110800. */
  110801. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  110802. /**
  110803. * Add a CubeTextureAssetTask to the list of active tasks
  110804. * @param taskName defines the name of the new task
  110805. * @param url defines the url of the file to load
  110806. * @param extensions defines the extension to use to load the cube map (can be null)
  110807. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110808. * @param files defines the list of files to load (can be null)
  110809. * @returns a new CubeTextureAssetTask object
  110810. */
  110811. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  110812. /**
  110813. *
  110814. * Add a HDRCubeTextureAssetTask to the list of active tasks
  110815. * @param taskName defines the name of the new task
  110816. * @param url defines the url of the file to load
  110817. * @param size defines the size you want for the cubemap (can be null)
  110818. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110819. * @param generateHarmonics defines if you want to automatically generate (true by default)
  110820. * @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)
  110821. * @param reserved Internal use only
  110822. * @returns a new HDRCubeTextureAssetTask object
  110823. */
  110824. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  110825. /**
  110826. * Remove a task from the assets manager.
  110827. * @param task the task to remove
  110828. */
  110829. removeTask(task: AbstractAssetTask): void;
  110830. private _decreaseWaitingTasksCount;
  110831. private _runTask;
  110832. /**
  110833. * Reset the AssetsManager and remove all tasks
  110834. * @return the current instance of the AssetsManager
  110835. */
  110836. reset(): AssetsManager;
  110837. /**
  110838. * Start the loading process
  110839. * @return the current instance of the AssetsManager
  110840. */
  110841. load(): AssetsManager;
  110842. }
  110843. }
  110844. declare module BABYLON {
  110845. /**
  110846. * Wrapper class for promise with external resolve and reject.
  110847. */
  110848. export class Deferred<T> {
  110849. /**
  110850. * The promise associated with this deferred object.
  110851. */
  110852. readonly promise: Promise<T>;
  110853. private _resolve;
  110854. private _reject;
  110855. /**
  110856. * The resolve method of the promise associated with this deferred object.
  110857. */
  110858. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  110859. /**
  110860. * The reject method of the promise associated with this deferred object.
  110861. */
  110862. readonly reject: (reason?: any) => void;
  110863. /**
  110864. * Constructor for this deferred object.
  110865. */
  110866. constructor();
  110867. }
  110868. }
  110869. declare module BABYLON {
  110870. /**
  110871. * Class used to help managing file picking and drag'n'drop
  110872. */
  110873. export class FilesInput {
  110874. /**
  110875. * List of files ready to be loaded
  110876. */
  110877. static readonly FilesToLoad: {
  110878. [key: string]: File;
  110879. };
  110880. /**
  110881. * Callback called when a file is processed
  110882. */
  110883. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  110884. private _engine;
  110885. private _currentScene;
  110886. private _sceneLoadedCallback;
  110887. private _progressCallback;
  110888. private _additionalRenderLoopLogicCallback;
  110889. private _textureLoadingCallback;
  110890. private _startingProcessingFilesCallback;
  110891. private _onReloadCallback;
  110892. private _errorCallback;
  110893. private _elementToMonitor;
  110894. private _sceneFileToLoad;
  110895. private _filesToLoad;
  110896. /**
  110897. * Creates a new FilesInput
  110898. * @param engine defines the rendering engine
  110899. * @param scene defines the hosting scene
  110900. * @param sceneLoadedCallback callback called when scene is loaded
  110901. * @param progressCallback callback called to track progress
  110902. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  110903. * @param textureLoadingCallback callback called when a texture is loading
  110904. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  110905. * @param onReloadCallback callback called when a reload is requested
  110906. * @param errorCallback callback call if an error occurs
  110907. */
  110908. 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);
  110909. private _dragEnterHandler;
  110910. private _dragOverHandler;
  110911. private _dropHandler;
  110912. /**
  110913. * Calls this function to listen to drag'n'drop events on a specific DOM element
  110914. * @param elementToMonitor defines the DOM element to track
  110915. */
  110916. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  110917. /**
  110918. * Release all associated resources
  110919. */
  110920. dispose(): void;
  110921. private renderFunction;
  110922. private drag;
  110923. private drop;
  110924. private _traverseFolder;
  110925. private _processFiles;
  110926. /**
  110927. * Load files from a drop event
  110928. * @param event defines the drop event to use as source
  110929. */
  110930. loadFiles(event: any): void;
  110931. private _processReload;
  110932. /**
  110933. * Reload the current scene from the loaded files
  110934. */
  110935. reload(): void;
  110936. }
  110937. }
  110938. declare module BABYLON {
  110939. /**
  110940. * Defines the root class used to create scene optimization to use with SceneOptimizer
  110941. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110942. */
  110943. export class SceneOptimization {
  110944. /**
  110945. * Defines the priority of this optimization (0 by default which means first in the list)
  110946. */
  110947. priority: number;
  110948. /**
  110949. * Gets a string describing the action executed by the current optimization
  110950. * @returns description string
  110951. */
  110952. getDescription(): string;
  110953. /**
  110954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110955. * @param scene defines the current scene where to apply this optimization
  110956. * @param optimizer defines the current optimizer
  110957. * @returns true if everything that can be done was applied
  110958. */
  110959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110960. /**
  110961. * Creates the SceneOptimization object
  110962. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110963. * @param desc defines the description associated with the optimization
  110964. */
  110965. constructor(
  110966. /**
  110967. * Defines the priority of this optimization (0 by default which means first in the list)
  110968. */
  110969. priority?: number);
  110970. }
  110971. /**
  110972. * Defines an optimization used to reduce the size of render target textures
  110973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110974. */
  110975. export class TextureOptimization extends SceneOptimization {
  110976. /**
  110977. * Defines the priority of this optimization (0 by default which means first in the list)
  110978. */
  110979. priority: number;
  110980. /**
  110981. * 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
  110982. */
  110983. maximumSize: number;
  110984. /**
  110985. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110986. */
  110987. step: number;
  110988. /**
  110989. * Gets a string describing the action executed by the current optimization
  110990. * @returns description string
  110991. */
  110992. getDescription(): string;
  110993. /**
  110994. * Creates the TextureOptimization object
  110995. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110996. * @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
  110997. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110998. */
  110999. constructor(
  111000. /**
  111001. * Defines the priority of this optimization (0 by default which means first in the list)
  111002. */
  111003. priority?: number,
  111004. /**
  111005. * 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
  111006. */
  111007. maximumSize?: number,
  111008. /**
  111009. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111010. */
  111011. step?: number);
  111012. /**
  111013. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111014. * @param scene defines the current scene where to apply this optimization
  111015. * @param optimizer defines the current optimizer
  111016. * @returns true if everything that can be done was applied
  111017. */
  111018. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111019. }
  111020. /**
  111021. * Defines an optimization used to increase or decrease the rendering resolution
  111022. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111023. */
  111024. export class HardwareScalingOptimization extends SceneOptimization {
  111025. /**
  111026. * Defines the priority of this optimization (0 by default which means first in the list)
  111027. */
  111028. priority: number;
  111029. /**
  111030. * Defines the maximum scale to use (2 by default)
  111031. */
  111032. maximumScale: number;
  111033. /**
  111034. * Defines the step to use between two passes (0.5 by default)
  111035. */
  111036. step: number;
  111037. private _currentScale;
  111038. private _directionOffset;
  111039. /**
  111040. * Gets a string describing the action executed by the current optimization
  111041. * @return description string
  111042. */
  111043. getDescription(): string;
  111044. /**
  111045. * Creates the HardwareScalingOptimization object
  111046. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111047. * @param maximumScale defines the maximum scale to use (2 by default)
  111048. * @param step defines the step to use between two passes (0.5 by default)
  111049. */
  111050. constructor(
  111051. /**
  111052. * Defines the priority of this optimization (0 by default which means first in the list)
  111053. */
  111054. priority?: number,
  111055. /**
  111056. * Defines the maximum scale to use (2 by default)
  111057. */
  111058. maximumScale?: number,
  111059. /**
  111060. * Defines the step to use between two passes (0.5 by default)
  111061. */
  111062. step?: number);
  111063. /**
  111064. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111065. * @param scene defines the current scene where to apply this optimization
  111066. * @param optimizer defines the current optimizer
  111067. * @returns true if everything that can be done was applied
  111068. */
  111069. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111070. }
  111071. /**
  111072. * Defines an optimization used to remove shadows
  111073. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111074. */
  111075. export class ShadowsOptimization extends SceneOptimization {
  111076. /**
  111077. * Gets a string describing the action executed by the current optimization
  111078. * @return description string
  111079. */
  111080. getDescription(): string;
  111081. /**
  111082. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111083. * @param scene defines the current scene where to apply this optimization
  111084. * @param optimizer defines the current optimizer
  111085. * @returns true if everything that can be done was applied
  111086. */
  111087. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111088. }
  111089. /**
  111090. * Defines an optimization used to turn post-processes off
  111091. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111092. */
  111093. export class PostProcessesOptimization extends SceneOptimization {
  111094. /**
  111095. * Gets a string describing the action executed by the current optimization
  111096. * @return description string
  111097. */
  111098. getDescription(): string;
  111099. /**
  111100. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111101. * @param scene defines the current scene where to apply this optimization
  111102. * @param optimizer defines the current optimizer
  111103. * @returns true if everything that can be done was applied
  111104. */
  111105. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111106. }
  111107. /**
  111108. * Defines an optimization used to turn lens flares off
  111109. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111110. */
  111111. export class LensFlaresOptimization extends SceneOptimization {
  111112. /**
  111113. * Gets a string describing the action executed by the current optimization
  111114. * @return description string
  111115. */
  111116. getDescription(): string;
  111117. /**
  111118. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111119. * @param scene defines the current scene where to apply this optimization
  111120. * @param optimizer defines the current optimizer
  111121. * @returns true if everything that can be done was applied
  111122. */
  111123. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111124. }
  111125. /**
  111126. * Defines an optimization based on user defined callback.
  111127. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111128. */
  111129. export class CustomOptimization extends SceneOptimization {
  111130. /**
  111131. * Callback called to apply the custom optimization.
  111132. */
  111133. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111134. /**
  111135. * Callback called to get custom description
  111136. */
  111137. onGetDescription: () => string;
  111138. /**
  111139. * Gets a string describing the action executed by the current optimization
  111140. * @returns description string
  111141. */
  111142. getDescription(): string;
  111143. /**
  111144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111145. * @param scene defines the current scene where to apply this optimization
  111146. * @param optimizer defines the current optimizer
  111147. * @returns true if everything that can be done was applied
  111148. */
  111149. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111150. }
  111151. /**
  111152. * Defines an optimization used to turn particles off
  111153. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111154. */
  111155. export class ParticlesOptimization extends SceneOptimization {
  111156. /**
  111157. * Gets a string describing the action executed by the current optimization
  111158. * @return description string
  111159. */
  111160. getDescription(): string;
  111161. /**
  111162. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111163. * @param scene defines the current scene where to apply this optimization
  111164. * @param optimizer defines the current optimizer
  111165. * @returns true if everything that can be done was applied
  111166. */
  111167. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111168. }
  111169. /**
  111170. * Defines an optimization used to turn render targets off
  111171. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111172. */
  111173. export class RenderTargetsOptimization extends SceneOptimization {
  111174. /**
  111175. * Gets a string describing the action executed by the current optimization
  111176. * @return description string
  111177. */
  111178. getDescription(): string;
  111179. /**
  111180. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111181. * @param scene defines the current scene where to apply this optimization
  111182. * @param optimizer defines the current optimizer
  111183. * @returns true if everything that can be done was applied
  111184. */
  111185. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111186. }
  111187. /**
  111188. * Defines an optimization used to merge meshes with compatible materials
  111189. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111190. */
  111191. export class MergeMeshesOptimization extends SceneOptimization {
  111192. private static _UpdateSelectionTree;
  111193. /**
  111194. * Gets or sets a boolean which defines if optimization octree has to be updated
  111195. */
  111196. /**
  111197. * Gets or sets a boolean which defines if optimization octree has to be updated
  111198. */
  111199. static UpdateSelectionTree: boolean;
  111200. /**
  111201. * Gets a string describing the action executed by the current optimization
  111202. * @return description string
  111203. */
  111204. getDescription(): string;
  111205. private _canBeMerged;
  111206. /**
  111207. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111208. * @param scene defines the current scene where to apply this optimization
  111209. * @param optimizer defines the current optimizer
  111210. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111211. * @returns true if everything that can be done was applied
  111212. */
  111213. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111214. }
  111215. /**
  111216. * Defines a list of options used by SceneOptimizer
  111217. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111218. */
  111219. export class SceneOptimizerOptions {
  111220. /**
  111221. * Defines the target frame rate to reach (60 by default)
  111222. */
  111223. targetFrameRate: number;
  111224. /**
  111225. * Defines the interval between two checkes (2000ms by default)
  111226. */
  111227. trackerDuration: number;
  111228. /**
  111229. * Gets the list of optimizations to apply
  111230. */
  111231. optimizations: SceneOptimization[];
  111232. /**
  111233. * Creates a new list of options used by SceneOptimizer
  111234. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111235. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111236. */
  111237. constructor(
  111238. /**
  111239. * Defines the target frame rate to reach (60 by default)
  111240. */
  111241. targetFrameRate?: number,
  111242. /**
  111243. * Defines the interval between two checkes (2000ms by default)
  111244. */
  111245. trackerDuration?: number);
  111246. /**
  111247. * Add a new optimization
  111248. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  111249. * @returns the current SceneOptimizerOptions
  111250. */
  111251. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  111252. /**
  111253. * Add a new custom optimization
  111254. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  111255. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  111256. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111257. * @returns the current SceneOptimizerOptions
  111258. */
  111259. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  111260. /**
  111261. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  111262. * @param targetFrameRate defines the target frame rate (60 by default)
  111263. * @returns a SceneOptimizerOptions object
  111264. */
  111265. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111266. /**
  111267. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  111268. * @param targetFrameRate defines the target frame rate (60 by default)
  111269. * @returns a SceneOptimizerOptions object
  111270. */
  111271. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111272. /**
  111273. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  111274. * @param targetFrameRate defines the target frame rate (60 by default)
  111275. * @returns a SceneOptimizerOptions object
  111276. */
  111277. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111278. }
  111279. /**
  111280. * Class used to run optimizations in order to reach a target frame rate
  111281. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111282. */
  111283. export class SceneOptimizer implements IDisposable {
  111284. private _isRunning;
  111285. private _options;
  111286. private _scene;
  111287. private _currentPriorityLevel;
  111288. private _targetFrameRate;
  111289. private _trackerDuration;
  111290. private _currentFrameRate;
  111291. private _sceneDisposeObserver;
  111292. private _improvementMode;
  111293. /**
  111294. * Defines an observable called when the optimizer reaches the target frame rate
  111295. */
  111296. onSuccessObservable: Observable<SceneOptimizer>;
  111297. /**
  111298. * Defines an observable called when the optimizer enables an optimization
  111299. */
  111300. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  111301. /**
  111302. * Defines an observable called when the optimizer is not able to reach the target frame rate
  111303. */
  111304. onFailureObservable: Observable<SceneOptimizer>;
  111305. /**
  111306. * Gets a boolean indicating if the optimizer is in improvement mode
  111307. */
  111308. readonly isInImprovementMode: boolean;
  111309. /**
  111310. * Gets the current priority level (0 at start)
  111311. */
  111312. readonly currentPriorityLevel: number;
  111313. /**
  111314. * Gets the current frame rate checked by the SceneOptimizer
  111315. */
  111316. readonly currentFrameRate: number;
  111317. /**
  111318. * Gets or sets the current target frame rate (60 by default)
  111319. */
  111320. /**
  111321. * Gets or sets the current target frame rate (60 by default)
  111322. */
  111323. targetFrameRate: number;
  111324. /**
  111325. * Gets or sets the current interval between two checks (every 2000ms by default)
  111326. */
  111327. /**
  111328. * Gets or sets the current interval between two checks (every 2000ms by default)
  111329. */
  111330. trackerDuration: number;
  111331. /**
  111332. * Gets the list of active optimizations
  111333. */
  111334. readonly optimizations: SceneOptimization[];
  111335. /**
  111336. * Creates a new SceneOptimizer
  111337. * @param scene defines the scene to work on
  111338. * @param options defines the options to use with the SceneOptimizer
  111339. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  111340. * @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)
  111341. */
  111342. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  111343. /**
  111344. * Stops the current optimizer
  111345. */
  111346. stop(): void;
  111347. /**
  111348. * Reset the optimizer to initial step (current priority level = 0)
  111349. */
  111350. reset(): void;
  111351. /**
  111352. * Start the optimizer. By default it will try to reach a specific framerate
  111353. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  111354. */
  111355. start(): void;
  111356. private _checkCurrentState;
  111357. /**
  111358. * Release all resources
  111359. */
  111360. dispose(): void;
  111361. /**
  111362. * Helper function to create a SceneOptimizer with one single line of code
  111363. * @param scene defines the scene to work on
  111364. * @param options defines the options to use with the SceneOptimizer
  111365. * @param onSuccess defines a callback to call on success
  111366. * @param onFailure defines a callback to call on failure
  111367. * @returns the new SceneOptimizer object
  111368. */
  111369. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  111370. }
  111371. }
  111372. declare module BABYLON {
  111373. /**
  111374. * Class used to serialize a scene into a string
  111375. */
  111376. export class SceneSerializer {
  111377. /**
  111378. * Clear cache used by a previous serialization
  111379. */
  111380. static ClearCache(): void;
  111381. /**
  111382. * Serialize a scene into a JSON compatible object
  111383. * @param scene defines the scene to serialize
  111384. * @returns a JSON compatible object
  111385. */
  111386. static Serialize(scene: Scene): any;
  111387. /**
  111388. * Serialize a mesh into a JSON compatible object
  111389. * @param toSerialize defines the mesh to serialize
  111390. * @param withParents defines if parents must be serialized as well
  111391. * @param withChildren defines if children must be serialized as well
  111392. * @returns a JSON compatible object
  111393. */
  111394. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  111395. }
  111396. }
  111397. declare module BABYLON {
  111398. /**
  111399. * This represents the different options avilable for the video capture.
  111400. */
  111401. export interface VideoRecorderOptions {
  111402. /** Defines the mime type of the video */
  111403. mimeType: string;
  111404. /** Defines the video the video should be recorded at */
  111405. fps: number;
  111406. /** Defines the chunk size for the recording data */
  111407. recordChunckSize: number;
  111408. /** The audio tracks to attach to the record */
  111409. audioTracks?: MediaStreamTrack[];
  111410. }
  111411. /**
  111412. * This can helps recording videos from BabylonJS.
  111413. * This is based on the available WebRTC functionalities of the browser.
  111414. *
  111415. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  111416. */
  111417. export class VideoRecorder {
  111418. private static readonly _defaultOptions;
  111419. /**
  111420. * Returns wehther or not the VideoRecorder is available in your browser.
  111421. * @param engine Defines the Babylon Engine to check the support for
  111422. * @returns true if supported otherwise false
  111423. */
  111424. static IsSupported(engine: Engine): boolean;
  111425. private readonly _options;
  111426. private _canvas;
  111427. private _mediaRecorder;
  111428. private _recordedChunks;
  111429. private _fileName;
  111430. private _resolve;
  111431. private _reject;
  111432. /**
  111433. * True wether a recording is already in progress.
  111434. */
  111435. readonly isRecording: boolean;
  111436. /**
  111437. * Create a new VideoCapture object which can help converting what you see in Babylon to
  111438. * a video file.
  111439. * @param engine Defines the BabylonJS Engine you wish to record
  111440. * @param options Defines options that can be used to customized the capture
  111441. */
  111442. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  111443. /**
  111444. * Stops the current recording before the default capture timeout passed in the startRecording
  111445. * functions.
  111446. */
  111447. stopRecording(): void;
  111448. /**
  111449. * Starts recording the canvas for a max duration specified in parameters.
  111450. * @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.
  111451. * @param maxDuration Defines the maximum recording time in seconds.
  111452. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  111453. * @return a promise callback at the end of the recording with the video data in Blob.
  111454. */
  111455. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  111456. /**
  111457. * Releases internal resources used during the recording.
  111458. */
  111459. dispose(): void;
  111460. private _handleDataAvailable;
  111461. private _handleError;
  111462. private _handleStop;
  111463. }
  111464. }
  111465. declare module BABYLON {
  111466. /**
  111467. * Helper class to push actions to a pool of workers.
  111468. */
  111469. export class WorkerPool implements IDisposable {
  111470. private _workerInfos;
  111471. private _pendingActions;
  111472. /**
  111473. * Constructor
  111474. * @param workers Array of workers to use for actions
  111475. */
  111476. constructor(workers: Array<Worker>);
  111477. /**
  111478. * Terminates all workers and clears any pending actions.
  111479. */
  111480. dispose(): void;
  111481. /**
  111482. * Pushes an action to the worker pool. If all the workers are active, the action will be
  111483. * pended until a worker has completed its action.
  111484. * @param action The action to perform. Call onComplete when the action is complete.
  111485. */
  111486. push(action: (worker: Worker, onComplete: () => void) => void): void;
  111487. private _execute;
  111488. }
  111489. }
  111490. declare module BABYLON {
  111491. /**
  111492. * Class containing a set of static utilities functions for screenshots
  111493. */
  111494. export class ScreenshotTools {
  111495. /**
  111496. * Captures a screenshot of the current rendering
  111497. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111498. * @param engine defines the rendering engine
  111499. * @param camera defines the source camera
  111500. * @param size This parameter can be set to a single number or to an object with the
  111501. * following (optional) properties: precision, width, height. If a single number is passed,
  111502. * it will be used for both width and height. If an object is passed, the screenshot size
  111503. * will be derived from the parameters. The precision property is a multiplier allowing
  111504. * rendering at a higher or lower resolution
  111505. * @param successCallback defines the callback receives a single parameter which contains the
  111506. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111507. * src parameter of an <img> to display it
  111508. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  111509. * Check your browser for supported MIME types
  111510. */
  111511. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  111512. /**
  111513. * Generates an image screenshot from the specified camera.
  111514. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111515. * @param engine The engine to use for rendering
  111516. * @param camera The camera to use for rendering
  111517. * @param size This parameter can be set to a single number or to an object with the
  111518. * following (optional) properties: precision, width, height. If a single number is passed,
  111519. * it will be used for both width and height. If an object is passed, the screenshot size
  111520. * will be derived from the parameters. The precision property is a multiplier allowing
  111521. * rendering at a higher or lower resolution
  111522. * @param successCallback The callback receives a single parameter which contains the
  111523. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111524. * src parameter of an <img> to display it
  111525. * @param mimeType The MIME type of the screenshot image (default: image/png).
  111526. * Check your browser for supported MIME types
  111527. * @param samples Texture samples (default: 1)
  111528. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  111529. * @param fileName A name for for the downloaded file.
  111530. */
  111531. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  111532. }
  111533. }
  111534. declare module BABYLON {
  111535. /**
  111536. * A cursor which tracks a point on a path
  111537. */
  111538. export class PathCursor {
  111539. private path;
  111540. /**
  111541. * Stores path cursor callbacks for when an onchange event is triggered
  111542. */
  111543. private _onchange;
  111544. /**
  111545. * The value of the path cursor
  111546. */
  111547. value: number;
  111548. /**
  111549. * The animation array of the path cursor
  111550. */
  111551. animations: Animation[];
  111552. /**
  111553. * Initializes the path cursor
  111554. * @param path The path to track
  111555. */
  111556. constructor(path: Path2);
  111557. /**
  111558. * Gets the cursor point on the path
  111559. * @returns A point on the path cursor at the cursor location
  111560. */
  111561. getPoint(): Vector3;
  111562. /**
  111563. * Moves the cursor ahead by the step amount
  111564. * @param step The amount to move the cursor forward
  111565. * @returns This path cursor
  111566. */
  111567. moveAhead(step?: number): PathCursor;
  111568. /**
  111569. * Moves the cursor behind by the step amount
  111570. * @param step The amount to move the cursor back
  111571. * @returns This path cursor
  111572. */
  111573. moveBack(step?: number): PathCursor;
  111574. /**
  111575. * Moves the cursor by the step amount
  111576. * If the step amount is greater than one, an exception is thrown
  111577. * @param step The amount to move the cursor
  111578. * @returns This path cursor
  111579. */
  111580. move(step: number): PathCursor;
  111581. /**
  111582. * Ensures that the value is limited between zero and one
  111583. * @returns This path cursor
  111584. */
  111585. private ensureLimits;
  111586. /**
  111587. * Runs onchange callbacks on change (used by the animation engine)
  111588. * @returns This path cursor
  111589. */
  111590. private raiseOnChange;
  111591. /**
  111592. * Executes a function on change
  111593. * @param f A path cursor onchange callback
  111594. * @returns This path cursor
  111595. */
  111596. onchange(f: (cursor: PathCursor) => void): PathCursor;
  111597. }
  111598. }
  111599. declare module BABYLON {
  111600. /** @hidden */
  111601. export var blurPixelShader: {
  111602. name: string;
  111603. shader: string;
  111604. };
  111605. }
  111606. declare module BABYLON {
  111607. /** @hidden */
  111608. export var bones300Declaration: {
  111609. name: string;
  111610. shader: string;
  111611. };
  111612. }
  111613. declare module BABYLON {
  111614. /** @hidden */
  111615. export var instances300Declaration: {
  111616. name: string;
  111617. shader: string;
  111618. };
  111619. }
  111620. declare module BABYLON {
  111621. /** @hidden */
  111622. export var pointCloudVertexDeclaration: {
  111623. name: string;
  111624. shader: string;
  111625. };
  111626. }
  111627. // Mixins
  111628. interface Window {
  111629. mozIndexedDB: IDBFactory;
  111630. webkitIndexedDB: IDBFactory;
  111631. msIndexedDB: IDBFactory;
  111632. webkitURL: typeof URL;
  111633. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  111634. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  111635. WebGLRenderingContext: WebGLRenderingContext;
  111636. MSGesture: MSGesture;
  111637. CANNON: any;
  111638. AudioContext: AudioContext;
  111639. webkitAudioContext: AudioContext;
  111640. PointerEvent: any;
  111641. Math: Math;
  111642. Uint8Array: Uint8ArrayConstructor;
  111643. Float32Array: Float32ArrayConstructor;
  111644. mozURL: typeof URL;
  111645. msURL: typeof URL;
  111646. VRFrameData: any; // WebVR, from specs 1.1
  111647. DracoDecoderModule: any;
  111648. setImmediate(handler: (...args: any[]) => void): number;
  111649. }
  111650. interface Document {
  111651. mozCancelFullScreen(): void;
  111652. msCancelFullScreen(): void;
  111653. webkitCancelFullScreen(): void;
  111654. requestPointerLock(): void;
  111655. exitPointerLock(): void;
  111656. mozFullScreen: boolean;
  111657. msIsFullScreen: boolean;
  111658. readonly webkitIsFullScreen: boolean;
  111659. readonly pointerLockElement: Element;
  111660. mozPointerLockElement: HTMLElement;
  111661. msPointerLockElement: HTMLElement;
  111662. webkitPointerLockElement: HTMLElement;
  111663. }
  111664. interface HTMLCanvasElement {
  111665. requestPointerLock(): void;
  111666. msRequestPointerLock?(): void;
  111667. mozRequestPointerLock?(): void;
  111668. webkitRequestPointerLock?(): void;
  111669. /** Track wether a record is in progress */
  111670. isRecording: boolean;
  111671. /** Capture Stream method defined by some browsers */
  111672. captureStream(fps?: number): MediaStream;
  111673. }
  111674. interface CanvasRenderingContext2D {
  111675. msImageSmoothingEnabled: boolean;
  111676. }
  111677. interface MouseEvent {
  111678. mozMovementX: number;
  111679. mozMovementY: number;
  111680. webkitMovementX: number;
  111681. webkitMovementY: number;
  111682. msMovementX: number;
  111683. msMovementY: number;
  111684. }
  111685. interface Navigator {
  111686. mozGetVRDevices: (any: any) => any;
  111687. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111688. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111689. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111690. webkitGetGamepads(): Gamepad[];
  111691. msGetGamepads(): Gamepad[];
  111692. webkitGamepads(): Gamepad[];
  111693. }
  111694. interface HTMLVideoElement {
  111695. mozSrcObject: any;
  111696. }
  111697. interface Math {
  111698. fround(x: number): number;
  111699. imul(a: number, b: number): number;
  111700. }
  111701. interface WebGLProgram {
  111702. context?: WebGLRenderingContext;
  111703. vertexShader?: WebGLShader;
  111704. fragmentShader?: WebGLShader;
  111705. isParallelCompiled: boolean;
  111706. onCompiled?: () => void;
  111707. }
  111708. interface WebGLRenderingContext {
  111709. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  111710. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  111711. vertexAttribDivisor(index: number, divisor: number): void;
  111712. createVertexArray(): any;
  111713. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  111714. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  111715. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  111716. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  111717. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  111718. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  111719. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  111720. // Queries
  111721. createQuery(): WebGLQuery;
  111722. deleteQuery(query: WebGLQuery): void;
  111723. beginQuery(target: number, query: WebGLQuery): void;
  111724. endQuery(target: number): void;
  111725. getQueryParameter(query: WebGLQuery, pname: number): any;
  111726. getQuery(target: number, pname: number): any;
  111727. MAX_SAMPLES: number;
  111728. RGBA8: number;
  111729. READ_FRAMEBUFFER: number;
  111730. DRAW_FRAMEBUFFER: number;
  111731. UNIFORM_BUFFER: number;
  111732. HALF_FLOAT_OES: number;
  111733. RGBA16F: number;
  111734. RGBA32F: number;
  111735. R32F: number;
  111736. RG32F: number;
  111737. RGB32F: number;
  111738. R16F: number;
  111739. RG16F: number;
  111740. RGB16F: number;
  111741. RED: number;
  111742. RG: number;
  111743. R8: number;
  111744. RG8: number;
  111745. UNSIGNED_INT_24_8: number;
  111746. DEPTH24_STENCIL8: number;
  111747. /* Multiple Render Targets */
  111748. drawBuffers(buffers: number[]): void;
  111749. readBuffer(src: number): void;
  111750. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  111751. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  111752. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  111753. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  111754. // Occlusion Query
  111755. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  111756. ANY_SAMPLES_PASSED: number;
  111757. QUERY_RESULT_AVAILABLE: number;
  111758. QUERY_RESULT: number;
  111759. }
  111760. interface WebGLBuffer {
  111761. references: number;
  111762. capacity: number;
  111763. is32Bits: boolean;
  111764. }
  111765. interface WebGLProgram {
  111766. transformFeedback?: WebGLTransformFeedback | null;
  111767. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  111768. }
  111769. interface EXT_disjoint_timer_query {
  111770. QUERY_COUNTER_BITS_EXT: number;
  111771. TIME_ELAPSED_EXT: number;
  111772. TIMESTAMP_EXT: number;
  111773. GPU_DISJOINT_EXT: number;
  111774. QUERY_RESULT_EXT: number;
  111775. QUERY_RESULT_AVAILABLE_EXT: number;
  111776. queryCounterEXT(query: WebGLQuery, target: number): void;
  111777. createQueryEXT(): WebGLQuery;
  111778. beginQueryEXT(target: number, query: WebGLQuery): void;
  111779. endQueryEXT(target: number): void;
  111780. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  111781. deleteQueryEXT(query: WebGLQuery): void;
  111782. }
  111783. interface WebGLUniformLocation {
  111784. _currentState: any;
  111785. }
  111786. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  111787. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  111788. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  111789. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111790. interface WebGLRenderingContext {
  111791. readonly RASTERIZER_DISCARD: number;
  111792. readonly DEPTH_COMPONENT24: number;
  111793. readonly TEXTURE_3D: number;
  111794. readonly TEXTURE_2D_ARRAY: number;
  111795. readonly TEXTURE_COMPARE_FUNC: number;
  111796. readonly TEXTURE_COMPARE_MODE: number;
  111797. readonly COMPARE_REF_TO_TEXTURE: number;
  111798. readonly TEXTURE_WRAP_R: number;
  111799. readonly HALF_FLOAT: number;
  111800. readonly RGB8: number;
  111801. readonly RED_INTEGER: number;
  111802. readonly RG_INTEGER: number;
  111803. readonly RGB_INTEGER: number;
  111804. readonly RGBA_INTEGER: number;
  111805. readonly R8_SNORM: number;
  111806. readonly RG8_SNORM: number;
  111807. readonly RGB8_SNORM: number;
  111808. readonly RGBA8_SNORM: number;
  111809. readonly R8I: number;
  111810. readonly RG8I: number;
  111811. readonly RGB8I: number;
  111812. readonly RGBA8I: number;
  111813. readonly R8UI: number;
  111814. readonly RG8UI: number;
  111815. readonly RGB8UI: number;
  111816. readonly RGBA8UI: number;
  111817. readonly R16I: number;
  111818. readonly RG16I: number;
  111819. readonly RGB16I: number;
  111820. readonly RGBA16I: number;
  111821. readonly R16UI: number;
  111822. readonly RG16UI: number;
  111823. readonly RGB16UI: number;
  111824. readonly RGBA16UI: number;
  111825. readonly R32I: number;
  111826. readonly RG32I: number;
  111827. readonly RGB32I: number;
  111828. readonly RGBA32I: number;
  111829. readonly R32UI: number;
  111830. readonly RG32UI: number;
  111831. readonly RGB32UI: number;
  111832. readonly RGBA32UI: number;
  111833. readonly RGB10_A2UI: number;
  111834. readonly R11F_G11F_B10F: number;
  111835. readonly RGB9_E5: number;
  111836. readonly RGB10_A2: number;
  111837. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  111838. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  111839. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  111840. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  111841. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  111842. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  111843. 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;
  111844. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  111845. readonly TRANSFORM_FEEDBACK: number;
  111846. readonly INTERLEAVED_ATTRIBS: number;
  111847. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  111848. createTransformFeedback(): WebGLTransformFeedback;
  111849. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  111850. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  111851. beginTransformFeedback(primitiveMode: number): void;
  111852. endTransformFeedback(): void;
  111853. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  111854. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111855. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111856. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111857. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  111858. }
  111859. interface ImageBitmap {
  111860. readonly width: number;
  111861. readonly height: number;
  111862. close(): void;
  111863. }
  111864. interface WebGLQuery extends WebGLObject {
  111865. }
  111866. declare var WebGLQuery: {
  111867. prototype: WebGLQuery;
  111868. new(): WebGLQuery;
  111869. };
  111870. interface WebGLSampler extends WebGLObject {
  111871. }
  111872. declare var WebGLSampler: {
  111873. prototype: WebGLSampler;
  111874. new(): WebGLSampler;
  111875. };
  111876. interface WebGLSync extends WebGLObject {
  111877. }
  111878. declare var WebGLSync: {
  111879. prototype: WebGLSync;
  111880. new(): WebGLSync;
  111881. };
  111882. interface WebGLTransformFeedback extends WebGLObject {
  111883. }
  111884. declare var WebGLTransformFeedback: {
  111885. prototype: WebGLTransformFeedback;
  111886. new(): WebGLTransformFeedback;
  111887. };
  111888. interface WebGLVertexArrayObject extends WebGLObject {
  111889. }
  111890. declare var WebGLVertexArrayObject: {
  111891. prototype: WebGLVertexArrayObject;
  111892. new(): WebGLVertexArrayObject;
  111893. };
  111894. // Type definitions for WebVR API
  111895. // Project: https://w3c.github.io/webvr/
  111896. // Definitions by: six a <https://github.com/lostfictions>
  111897. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111898. interface VRDisplay extends EventTarget {
  111899. /**
  111900. * Dictionary of capabilities describing the VRDisplay.
  111901. */
  111902. readonly capabilities: VRDisplayCapabilities;
  111903. /**
  111904. * z-depth defining the far plane of the eye view frustum
  111905. * enables mapping of values in the render target depth
  111906. * attachment to scene coordinates. Initially set to 10000.0.
  111907. */
  111908. depthFar: number;
  111909. /**
  111910. * z-depth defining the near plane of the eye view frustum
  111911. * enables mapping of values in the render target depth
  111912. * attachment to scene coordinates. Initially set to 0.01.
  111913. */
  111914. depthNear: number;
  111915. /**
  111916. * An identifier for this distinct VRDisplay. Used as an
  111917. * association point in the Gamepad API.
  111918. */
  111919. readonly displayId: number;
  111920. /**
  111921. * A display name, a user-readable name identifying it.
  111922. */
  111923. readonly displayName: string;
  111924. readonly isConnected: boolean;
  111925. readonly isPresenting: boolean;
  111926. /**
  111927. * If this VRDisplay supports room-scale experiences, the optional
  111928. * stage attribute contains details on the room-scale parameters.
  111929. */
  111930. readonly stageParameters: VRStageParameters | null;
  111931. /**
  111932. * Passing the value returned by `requestAnimationFrame` to
  111933. * `cancelAnimationFrame` will unregister the callback.
  111934. * @param handle Define the hanle of the request to cancel
  111935. */
  111936. cancelAnimationFrame(handle: number): void;
  111937. /**
  111938. * Stops presenting to the VRDisplay.
  111939. * @returns a promise to know when it stopped
  111940. */
  111941. exitPresent(): Promise<void>;
  111942. /**
  111943. * Return the current VREyeParameters for the given eye.
  111944. * @param whichEye Define the eye we want the parameter for
  111945. * @returns the eye parameters
  111946. */
  111947. getEyeParameters(whichEye: string): VREyeParameters;
  111948. /**
  111949. * Populates the passed VRFrameData with the information required to render
  111950. * the current frame.
  111951. * @param frameData Define the data structure to populate
  111952. * @returns true if ok otherwise false
  111953. */
  111954. getFrameData(frameData: VRFrameData): boolean;
  111955. /**
  111956. * Get the layers currently being presented.
  111957. * @returns the list of VR layers
  111958. */
  111959. getLayers(): VRLayer[];
  111960. /**
  111961. * Return a VRPose containing the future predicted pose of the VRDisplay
  111962. * when the current frame will be presented. The value returned will not
  111963. * change until JavaScript has returned control to the browser.
  111964. *
  111965. * The VRPose will contain the position, orientation, velocity,
  111966. * and acceleration of each of these properties.
  111967. * @returns the pose object
  111968. */
  111969. getPose(): VRPose;
  111970. /**
  111971. * Return the current instantaneous pose of the VRDisplay, with no
  111972. * prediction applied.
  111973. * @returns the current instantaneous pose
  111974. */
  111975. getImmediatePose(): VRPose;
  111976. /**
  111977. * The callback passed to `requestAnimationFrame` will be called
  111978. * any time a new frame should be rendered. When the VRDisplay is
  111979. * presenting the callback will be called at the native refresh
  111980. * rate of the HMD. When not presenting this function acts
  111981. * identically to how window.requestAnimationFrame acts. Content should
  111982. * make no assumptions of frame rate or vsync behavior as the HMD runs
  111983. * asynchronously from other displays and at differing refresh rates.
  111984. * @param callback Define the eaction to run next frame
  111985. * @returns the request handle it
  111986. */
  111987. requestAnimationFrame(callback: FrameRequestCallback): number;
  111988. /**
  111989. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  111990. * Repeat calls while already presenting will update the VRLayers being displayed.
  111991. * @param layers Define the list of layer to present
  111992. * @returns a promise to know when the request has been fulfilled
  111993. */
  111994. requestPresent(layers: VRLayer[]): Promise<void>;
  111995. /**
  111996. * Reset the pose for this display, treating its current position and
  111997. * orientation as the "origin/zero" values. VRPose.position,
  111998. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  111999. * updated when calling resetPose(). This should be called in only
  112000. * sitting-space experiences.
  112001. */
  112002. resetPose(): void;
  112003. /**
  112004. * The VRLayer provided to the VRDisplay will be captured and presented
  112005. * in the HMD. Calling this function has the same effect on the source
  112006. * canvas as any other operation that uses its source image, and canvases
  112007. * created without preserveDrawingBuffer set to true will be cleared.
  112008. * @param pose Define the pose to submit
  112009. */
  112010. submitFrame(pose?: VRPose): void;
  112011. }
  112012. declare var VRDisplay: {
  112013. prototype: VRDisplay;
  112014. new(): VRDisplay;
  112015. };
  112016. interface VRLayer {
  112017. leftBounds?: number[] | Float32Array | null;
  112018. rightBounds?: number[] | Float32Array | null;
  112019. source?: HTMLCanvasElement | null;
  112020. }
  112021. interface VRDisplayCapabilities {
  112022. readonly canPresent: boolean;
  112023. readonly hasExternalDisplay: boolean;
  112024. readonly hasOrientation: boolean;
  112025. readonly hasPosition: boolean;
  112026. readonly maxLayers: number;
  112027. }
  112028. interface VREyeParameters {
  112029. /** @deprecated */
  112030. readonly fieldOfView: VRFieldOfView;
  112031. readonly offset: Float32Array;
  112032. readonly renderHeight: number;
  112033. readonly renderWidth: number;
  112034. }
  112035. interface VRFieldOfView {
  112036. readonly downDegrees: number;
  112037. readonly leftDegrees: number;
  112038. readonly rightDegrees: number;
  112039. readonly upDegrees: number;
  112040. }
  112041. interface VRFrameData {
  112042. readonly leftProjectionMatrix: Float32Array;
  112043. readonly leftViewMatrix: Float32Array;
  112044. readonly pose: VRPose;
  112045. readonly rightProjectionMatrix: Float32Array;
  112046. readonly rightViewMatrix: Float32Array;
  112047. readonly timestamp: number;
  112048. }
  112049. interface VRPose {
  112050. readonly angularAcceleration: Float32Array | null;
  112051. readonly angularVelocity: Float32Array | null;
  112052. readonly linearAcceleration: Float32Array | null;
  112053. readonly linearVelocity: Float32Array | null;
  112054. readonly orientation: Float32Array | null;
  112055. readonly position: Float32Array | null;
  112056. readonly timestamp: number;
  112057. }
  112058. interface VRStageParameters {
  112059. sittingToStandingTransform?: Float32Array;
  112060. sizeX?: number;
  112061. sizeY?: number;
  112062. }
  112063. interface Navigator {
  112064. getVRDisplays(): Promise<VRDisplay[]>;
  112065. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  112066. }
  112067. interface Window {
  112068. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  112069. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  112070. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  112071. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112072. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112073. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  112074. }
  112075. interface Gamepad {
  112076. readonly displayId: number;
  112077. }
  112078. interface XRDevice {
  112079. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  112080. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  112081. }
  112082. interface XRSession {
  112083. getInputSources(): Array<any>;
  112084. baseLayer: XRWebGLLayer;
  112085. requestFrameOfReference(type: string): Promise<void>;
  112086. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  112087. end(): Promise<void>;
  112088. requestAnimationFrame: Function;
  112089. addEventListener: Function;
  112090. }
  112091. interface XRSessionCreationOptions {
  112092. outputContext?: WebGLRenderingContext | null;
  112093. immersive?: boolean;
  112094. environmentIntegration?: boolean;
  112095. }
  112096. interface XRLayer {
  112097. getViewport: Function;
  112098. framebufferWidth: number;
  112099. framebufferHeight: number;
  112100. }
  112101. interface XRView {
  112102. projectionMatrix: Float32Array;
  112103. }
  112104. interface XRFrame {
  112105. getDevicePose: Function;
  112106. getInputPose: Function;
  112107. views: Array<XRView>;
  112108. baseLayer: XRLayer;
  112109. }
  112110. interface XRFrameOfReference {
  112111. }
  112112. interface XRWebGLLayer extends XRLayer {
  112113. framebuffer: WebGLFramebuffer;
  112114. }
  112115. declare var XRWebGLLayer: {
  112116. prototype: XRWebGLLayer;
  112117. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112118. };